open-telemetry / open-telemetry/opentelemetry-cpp
Add opt-in to export *unsampled but recording* Activities from trace processors
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
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
exportUnsampledSpansoption
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.