opentelemetry-js
opentelemetry-js copied to clipboard
Custom Sampler with TraceIdRatioBasedSampler per spanname
- [ /] This only affects the JavaScript OpenTelemetry library
- [ /] This may affect other libraries, but I would like to get opinions here first
Is there anyway that you could give certain sampling rate per span name? I was hoping to find something similar with what sentry
I currently have a custom sampler which excludes certain urls from getting trace, and I want to know if it's possible to also have custom sampling per span name. my shouldSample code is as follows
shouldSample(
context: Context,
traceId: String,
spanName: String,
spanKind: SpanKind,
attributes: SpanAttributes,
links: Link[],
): SamplingResult {
let res = {}
if (attributes['url'] === 'url1') {
res = {
decision: SamplingDecision.NOT_RECORD,
};
}
if(spanName === 'sample') {
// dont know what to do here / how to invoke TraceIdRatiobasedSampler
}
return result;
You can create your own TraceIdRatioBasedSampler in your sampler and delegate the shouldSample request to that sampler if needed. See also ParentBasedSampler, which delegates all shouldSample requests to the designated sampler if the sampling decision is not made yet.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stale for 14 days with no activity.