-
Notifications
You must be signed in to change notification settings - Fork 497
Description
Before opening a feature request against this repo, consider whether the feature should/could be implemented in the other OpenTelemetry client libraries. If so, please open an issue on opentelemetry-specification first.
Is your feature request related to a problem?
Yes. By default, the C++ SDK only exports sampled spans. This prevents collectors from seeing the full request volume, which makes it difficult to calculate accurate metrics (e.g., request rates, error ratios, latency percentiles) or perform tail-based sampling decisions with complete coverage.
In the Java SDK, this problem was tracked in:
- Issue #4990 — Proposal to forward non-sampled spans to SpanProcessors/Exporters
- PR #6057 — Merged implementation adding an
exportUnsampledSpans
option
C++ processors (BatchSpanProcessor
, SimpleSpanProcessor
) currently drop unsampled spans unconditionally, leaving no opt-in for users who want to forward them.
Describe the solution you'd like
Introduce an opt-in flag on the span processors (e.g., BatchSpanProcessorOptions
, SimpleSpanProcessorOptions
) that allows unsampled-but-recording spans to be forwarded to exporters.
Example pseudocode:
// sdk/include/opentelemetry/sdk/trace/batch_span_processor_options.h
struct BatchSpanProcessorOptions {
// Existing fields...
bool export_unsampled_spans = false; // default false
};
// sdk/src/trace/batch_span_processor.cc (simplified pseudocode)
void BatchSpanProcessor::OnEnd(std::unique_ptr<Recordable> &&span) noexcept {
auto *readable = static_cast<ReadableSpan*>(span.get());
bool is_sampled = readable->GetSpanContext().IsSampled();
if (!is_sampled && !options_.export_unsampled_spans) {
return;
}
this->queue_.Add(std::move(span));
}
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.