You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to insert additional TracingInstrumentations other than the default OTEL tracing instrumentations, Faro web-tracing currently requires that we call getDefaultOtelInstrumentations() with the same arguments as https://github.com/grafana/faro-web-sdk/blob/main/packages/web-tracing/src/instrumentation.ts#L102. However, this is not possible as getIgnoreUrls() is a private function, so calling faro.getIgnoreUrls() is not possible from outside of the class.
As an example, today I was trying to add a couple of opentelemetry/instrumentation into our app (which does not already use opentelemetry on the frontend). To do this I expected I could just add them to the instrumentation list, like this:
initializeFaro({
instrumentations: [
...getWebInstrumentations(),
new TracingInstrumentation({
instrumentations: [
...getDefaultOtelInstrumentations(),
new DocumentLoadInstrumentation(),
new UserInteractionInstrumentation(),
],
})
],
})
I found as a result of this that Faro does not get the correct values for ignoreUrls or propagateTraceHeaderCorsUrls.
Proposed solution
I think one way around this -- while maintaining backwards compatibility -- would be to allow an array of additional instrumentations to be given to Faro at initialization time, so that we don't have to re-implement getIgnoreUrls, make getIgnoreUrls public, or re-implement the entire initialize() function.
Then, options.instrumentations would clearly be an override, while options.additionalInstrumentations would be to add more tracing instrumentations that are not included by default.
Example
initializeFaro({
instrumentations: [
...getWebInstrumentations(),
new TracingInstrumentation({
instrumentationOptions: {
propagateTraceHeaderCorsUrls: [ ... ],
}
additionalInstrumentations: [
new DocumentLoadInstrumentation(),
new UserInteractionInstrumentation(),
],
})
],
})
Description
When attempting to insert additional
TracingInstrumentations
other than the default OTEL tracing instrumentations, Faro web-tracing currently requires that we callgetDefaultOtelInstrumentations()
with the same arguments as https://github.com/grafana/faro-web-sdk/blob/main/packages/web-tracing/src/instrumentation.ts#L102. However, this is not possible asgetIgnoreUrls()
is a private function, so callingfaro.getIgnoreUrls()
is not possible from outside of the class.As an example, today I was trying to add a couple of
opentelemetry/instrumentation
into our app (which does not already use opentelemetry on the frontend). To do this I expected I could just add them to the instrumentation list, like this:I found as a result of this that Faro does not get the correct values for
ignoreUrls
orpropagateTraceHeaderCorsUrls
.Proposed solution
I think one way around this -- while maintaining backwards compatibility -- would be to allow an array of additional instrumentations to be given to Faro at initialization time, so that we don't have to re-implement
getIgnoreUrls
, makegetIgnoreUrls
public, or re-implement the entireinitialize()
function.Then,
options.instrumentations
would clearly be an override, whileoptions.additionalInstrumentations
would be to add more tracing instrumentations that are not included by default.Example
Context
This code block here is responsible for the default setup of OTEL instrumentations and configuration: https://github.com/grafana/faro-web-sdk/blob/main/packages/web-tracing/src/instrumentation.ts#L99-L108
The text was updated successfully, but these errors were encountered: