Open longility opened 2 weeks ago
We are working on a new set of instrumentations using the new Events API, one of which is to emit ResourceTiming events for the resources loaded (https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2152), and another to emit PageView event (https://github.com/open-telemetry/opentelemetry-sandbox-web-js/issues/81). As part of this effort, I envision an instrumentation to emit a standalone documentFetch span. We have not created an issue yet to track this as this hasn't been discussed much in the Client SIG.
For your use-case does it work if you configure a custom sampler to drop these spans?
We are working on a new set of instrumentations using the new Events API, one of which is to emit ResourceTiming events for the resources loaded (#2152), and another to emit PageView event (open-telemetry/opentelemetry-sandbox-web-js#81). As part of this effort, I envision an instrumentation to emit a standalone documentFetch span. We have not created an issue yet to track this as this hasn't been discussed much in the Client SIG.
For your use-case does it work if you configure a custom sampler to drop these spans?
@scheler thanks for the status update and a workaround! I think that could be sufficient. Do you know of a sampler that could be a good starting point? I have not done one of those before.
@longility something like this -
const provider = new WebTracerProvider({
resource,
sampler: {
shouldSample: (context, traceId, spanName, spanKind, attributes, links) => {
return spanName == 'resourceFetch' ? SamplingDecision.NOT_RECORD : SamplingDecision.RECORD_AND_SAMPLED;
}
}
});
If this is acceptable, I can do a PR to expedite our needs and contribute for others to leverage as well.
Is your feature request related to a problem? Please describe
I would like to minimize the number of spans created that may not be important to us, specifically resource spans.
Describe the solution you'd like to see
For this line, https://github.com/open-telemetry/opentelemetry-js-contrib/blob/2dc2f72e5a86aa9e1220a26f78878070acde8424/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts#L138
to be similar to this: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/2dc2f72e5a86aa9e1220a26f78878070acde8424/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts#L160C7-L162C8
to where the end result may look something like this:
Describe alternatives you've considered
None.
Additional context
None.