In the Browser's SIG there have been comments about having a single configuration object at the SDK level to tune instrumentations to avoid duplication of options for different instrumentations.
As an example fetch instrumentation (added in #281) and xhr (added in #367) have some config options in common like sanitizeUrl and ignoreUrls. If we want to set these options we have to do it twice. One for each instrumentation that accepts it. Having a single configuration layer has its complexity and there should be an analysis and discussion about its feasibility.
Having fetch/xhr instrumentation configurations aligned would be helpful for this future analysis and work. This is the list of options for both intsrumentations
| option |
in fetch |
in xhr |
comment |
| propagateTraceHeaderCorsUrls |
YES |
YES |
identical |
| ignoreUrls |
YES |
YES |
identical |
| sanitizeUrl |
YES |
YES |
identical |
| measureRequestSize |
YES |
YES |
identical |
| requestHook |
YES |
NO |
According to fetch docs the method is used to add Span attribs or request headers. XHR could also accept a function that receives the Span and XHR object. |
| applyCustomAttributesOnSpan |
YES |
YES |
In both instrumentations the method gets a Span as 1st argument but the second depends on the instrumentation. |
I think we could align requestHook and applyCustomAttributesOnSpan options so a single function can be passed as value for both instrumentations. As an example if we implement requestHook in XHR then a user could do something like
const userRequestHook = ( span: Span, req: Request | XmlHttpRequest) => {
if (req instanceof XmlHttpRequest) {
// logic specific to XHR
} else {
// logic specific to fetch
}
// logic common to both
};
and use it for both instrumentations or pass it to the configuration layer (if we decide to do it).
In the Browser's SIG there have been comments about having a single configuration object at the SDK level to tune instrumentations to avoid duplication of options for different instrumentations.
As an example
fetchinstrumentation (added in #281) andxhr(added in #367) have some config options in common likesanitizeUrlandignoreUrls. If we want to set these options we have to do it twice. One for each instrumentation that accepts it. Having a single configuration layer has its complexity and there should be an analysis and discussion about its feasibility.Having fetch/xhr instrumentation configurations aligned would be helpful for this future analysis and work. This is the list of options for both intsrumentations
I think we could align
requestHookandapplyCustomAttributesOnSpanoptions so a single function can be passed as value for both instrumentations. As an example if we implementrequestHookin XHR then a user could do something likeand use it for both instrumentations or pass it to the configuration layer (if we decide to do it).