-
Notifications
You must be signed in to change notification settings - Fork 837
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
draft: fetch instrumentation header attributes #5354
base: main
Are you sure you want to change the base?
draft: fetch instrumentation header attributes #5354
Conversation
b363791
to
6aaf318
Compare
// whenever it is possible, this is needed only when PerformanceObserver | ||
// is not available | ||
/** Function for adding custom attributes on the span */ | ||
applyCustomAttributesOnSpan?: FetchCustomAttributeFunction; |
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.
Just rearranging these config options into alphabetical order.
/** List of request headers to include as attributes on the span. */ | ||
requestHeadersAsAttributes?: string[]; | ||
|
||
/** List of request headers to include as attributes on the span. */ |
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.
/** List of request headers to include as attributes on the span. */ | |
/** List of response headers to include as attributes on the span. */ |
responseHeadersAsAttributes?: string[]; | ||
|
||
/** Ignore adding network events as span events */ | ||
ignoreNetworkEvents?: boolean; |
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.
Question: Is there any hard dependency of requestHeadersAsAttributes
/responseHeadersAsAttributes
on ignoreNetworkEvents
/propagateTraceHeaderCorsUrls
/applyCustomAttributesOnSpan
? If not, maybe they can be separated them into two PRs.
propagateTraceHeaderCorsUrls?: web.PropagateTraceHeaderCorsUrls; | ||
|
||
/** List of request headers to include as attributes on the span. */ | ||
requestHeadersAsAttributes?: string[]; |
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.
Q: is it on the roadmap to add requestHeadersAsAttributes
/responseHeadersAsAttributes
to Xhr instrumentation?
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.
Specifically give consideration to naming of config options (thanks!)
I think the two new config names requestHeadersAsAtributes
and responseHeadersAsAttributes
are wise.
Anything else would be kind of awkward. For example
- applyRequestHeadersAsAttributesOnSpan
- applyReqHeadersAsAttrOnSpan
propagateTraceHeaderCorsUrls?: web.PropagateTraceHeaderCorsUrls; | ||
|
||
/** List of request headers to include as attributes on the span. */ | ||
requestHeadersAsAttributes?: string[]; |
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.
Not proposing that we consider support for declarative config here, but should these properties try to match naming for properties defined in opentelemetry-configuration
, like HttpInstrumentation which will ultimately get support following that schema?
I believe instrumentation.general.http.client.request_captured_headers
would be the corresponding property here. Would something like requestCapturedHeaders
make it clearer fo folks that want to move to file config in the future?
A couple of general notes:
|
const span: tracing.ReadableSpan = exportSpy.args[1][0][0]; | ||
assert.ok(span.attributes[ATTR_HTTP_REQUEST_HEADER('foo')] === 'bar'); | ||
assert.ok( | ||
span.attributes[ATTR_HTTP_REQUEST_HEADER('Content-Type')] === |
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.
The spec expects "normalized HTTP Header name (lowercase)" so this test is a bit misleading/wrong
Which problem is this PR solving?
This PR adds options to add headers as attributes for the browser request fetch instrumentation. The http.request.header. and http.response.header. are stable semantic attributes so we should have support for them in the fetch instrumentation.
Short description of the changes
requestHeadersAsAttributes
as a config param, an allowlist of request headers that should be included as attributes. By default no headers are added as attributes so that we avoid any security concerns.responseHeadersAsAttributes
as a config param, an allowlist of response headers that should be included as attributes.Documentation updates to come once we feel like the config API makes sense.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Unit tests.
Checklist: