-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Tracing: populate tags based on the custom headers #690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
6d92c8e
bf1939c
84e57a7
de10434
d5c9814
bbd386a
b0ed61a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,12 +7,18 @@ Tracing | |
|
|
||
| { | ||
| "tracing": { | ||
| "operation_name": "..." | ||
| "operation_name": "...", | ||
| "request_headers_for_tags": [] | ||
| } | ||
| } | ||
|
|
||
| operation_name | ||
| *(required, string)* Span name will be derived from operation_name. "ingress" and "egress" | ||
| are the only supported values. | ||
|
|
||
| request_headers_for_tags | ||
| *(optional, array)* An optional list of header names which is used for populating tags on the an active span. | ||
| Each tag name is the header name and tag value is the header value from the request headers. | ||
| If specified header is not present in the request headers no tag is created. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. grammar |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,10 @@ class LowerCaseString { | |
|
|
||
| const std::string& get() const { return string_; } | ||
| bool operator==(const LowerCaseString& rhs) const { return string_ == rhs.string_; } | ||
| LowerCaseString& operator=(const LowerCaseString& rhs) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not be needed and is probably indicative of doing something wrong.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's because Optional does not have a support for moveable types. Would you suggest to add it there?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what the actual problem you are trying to solve is, but I think you shouldn't need any of it, so unclear on the actual problem.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as far as i can tell the following happens: That's why one solution is to explicitly define copy assignment.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. per offline convo make config a pointer to a struct and remove operator= from here (so we don't introduce accidental copies). |
||
| string_ = rhs.string_; | ||
| return *this; | ||
| } | ||
|
|
||
| private: | ||
| void lower() { std::transform(string_.begin(), string_.end(), string_.begin(), tolower); } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,15 @@ class Config { | |
| public: | ||
| virtual ~Config() {} | ||
|
|
||
| /** | ||
| * Operation name for tracing, e.g., ingress. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| */ | ||
| virtual OperationName operationName() const PURE; | ||
|
|
||
| /** | ||
| * List of headers to populate tags on the active span. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| */ | ||
| virtual const std::list<Http::LowerCaseString>& requestHeadersForTags() const PURE; | ||
| }; | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -315,6 +315,8 @@ ConnectionManagerImpl::ActiveStream::~ActiveStream() { | |
| if (request_info_.healthCheck()) { | ||
| connection_manager_.config_.tracingStats().health_check_.inc(); | ||
| } else { | ||
| Tracing::HttpTracerUtility::populateTagsBasedOnHeaders(*active_span_, *request_headers_, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just move this logic into finalizeSpan |
||
| *this); | ||
| Tracing::HttpTracerUtility::finalizeSpan(*active_span_, *request_headers_, request_info_); | ||
| } | ||
| } | ||
|
|
@@ -748,6 +750,11 @@ Tracing::OperationName ConnectionManagerImpl::ActiveStream::operationName() cons | |
| return connection_manager_.config_.tracingConfig().value().operation_name_; | ||
| } | ||
|
|
||
| const std::list<Http::LowerCaseString>& | ||
| ConnectionManagerImpl::ActiveStream::requestHeadersForTags() const { | ||
| return connection_manager_.config_.tracingConfig().value().request_headers_for_tags_; | ||
| } | ||
|
|
||
| void ConnectionManagerImpl::ActiveStreamFilterBase::addResetStreamCallback( | ||
| std::function<void()> callback) { | ||
| parent_.reset_callbacks_.push_back(callback); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,6 +104,7 @@ struct ConnectionManagerTracingStats { | |
| */ | ||
| struct TracingConnectionManagerConfig { | ||
| Tracing::OperationName operation_name_; | ||
| std::list<Http::LowerCaseString> request_headers_for_tags_; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. std::vector |
||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -384,6 +385,7 @@ class ConnectionManagerImpl : Logger::Loggable<Logger::Id::http>, | |
|
|
||
| // Tracing::TracingConfig | ||
| virtual Tracing::OperationName operationName() const override; | ||
| virtual const std::list<Http::LowerCaseString>& requestHeadersForTags() const override; | ||
|
|
||
| // All state for the stream. Put here for readability. We could move this to a bit field | ||
| // eventually if we want. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo