opentelemetry-rust
opentelemetry-rust copied to clipboard
[Feature]: Tail sampling
Related Problems?
No response
Describe the solution you'd like:
We are currently using the @microlabs/otel-cf-workers library to enable open telemetry our CloudFlare workers. The configuration allows to specify both head sampling and tail sampling, which gives greater flexibility to filter traces based on their content after the Spans have been generated:
const otelConfig = {
exporter: {
url: "http://localhost:12345/v1/traces"
},
sampling: {
headSampler: { ratio: 0.01 }, // this allows to specify head sampling rule
tailSampler: ({ localRootSpan, spans }) => // here we override the final decision
localRootSpan.status.code === SpanStatusCode.ERROR ||
localRootSpan.spanContext().traceFlags === TraceFlags.SAMPLED ||
spans.some((s) => s.status.code === SpanStatusCode.ERROR),
}
};
Would it be possible to achieve the same functionality with opentelemetry-rust?
Considered Alternatives
I was looking into customizing the SpanExporter, but its implementation seems to be quite locked down. In theory, based on this comment it should be possible, but I could not find any working example.
Additional Context
No response