Skip to content

Add export_unsampled option to batch processor (export recording but unsampled spans) #891

@agent-adam

Description

@agent-adam

Background / Problem

By default, the Erlang SDK only exports sampled spans. The OpenTelemetry Trace SDK specification states that exporters MUST receive sampled spans and SHOULD NOT receive non-sampled spans. That “SHOULD NOT” allows for language-level opt-in behaviors.

In the Java SDK, this was discussed and tracked in:

  • Issue #4990 — Proposal to forward non-sampled spans to processors/exporters
  • PR #6057 — Merged implementation adding setExportUnsampledSpans(true) option

The Erlang SDK has improved handling of non-recording spans (for example, not inserting them into ETS tables). However, there is no knob to export recording but unsampled spans, which can be useful for collector-side metrics and tail-based sampling where full request counts are needed.


Motivation / Use Cases

  • Allow users to forward recording but unsampled spans to the Collector so that RED metrics, error ratios, and SLO burn rates can be computed with full coverage.
  • Support Collector-level tail-based sampling with complete data, without forcing 100% head sampling at the agent.
  • Preserve default spec-compliant behavior while enabling advanced users to opt-in.

Proposed Design

Add a new option to the batch processor:

%% sys.config / app env example
{opentelemetry, [
  {traces, [
    {processors, [
      {batch, #{
          exporter => otlp,
          export_unsampled => true
      }}
    ]}
  ]}
]}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions