-
Notifications
You must be signed in to change notification settings - Fork 795
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
feat: HTTP instrumentation: add the option to capture headers as span attributes #2492
feat: HTTP instrumentation: add the option to capture headers as span attributes #2492
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2492 +/- ##
==========================================
+ Coverage 93.20% 93.23% +0.03%
==========================================
Files 137 137
Lines 5017 5043 +26
Branches 1060 1067 +7
==========================================
+ Hits 4676 4702 +26
Misses 341 341
|
Please update the readme with documentation of this new option. |
}); | ||
instrumentation.enable(); | ||
server = http.createServer((request, response) => { | ||
response.setHeader('X-Server-Header1', 'server123'); |
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.
response.setHeader('X-Server-Header1', 'server123'); | |
response.setHeader('X-ServEr-hEeader1', 'server123'); |
or similar to verify that casing doesn't matter
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.
Thanks, added it!
experimental/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts
Outdated
Show resolved
Hide resolved
Updated the README |
Which problem is this PR solving?
Adds the option to the HTTP instrumentation to capture headers as span attributes.
Relevant section in the spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers
The headers which need capturing need to be set explicitly, by default no headers are transformed to span attributes.
For example if
X-Forwarded-For
is set to be captured on request headers, the span will havehttp.request.header.x_forwarded_for
attribute set.