Skip to content

[SDK] Align CompositeSampler / ComposableSampler with spec (#5161), add ComposableAnnotating, and fix ParentThreshold / ValidateRatio edge cases #4798

Open

Description

@dashpole

Problem

During a cross-implementation audit of C++'s CompositeSampler and Composable* samplers against the OpenTelemetry Tracing SDK specification (open-telemetry/opentelemetry-specification#5441), four spec alignment gaps were found (separate from empty th: parsing already addressed in #4582):

  1. Missing ComposableAnnotating built-in sampler:
    The spec defines 6 built-in composable samplers; ComposableAnnotating is not yet implemented under sdk/include/opentelemetry/sdk/trace/samplers/.
  2. Incomplete alignment with Amend the description of Composite/Composable samplers opentelemetry-specification#5161 (composable_sampler.h:53-76,101-107):
    CompositeSampler already generates fresh 56-bit randomness when unreliable, but ComposableSampler::GetSamplingIntent still accepts trace_id, SamplingIntent uses threshold_reliable instead of adjusted_count_reliable, and TraceStateProvider omits the final Decision.
  3. ComposableParentThresholdSampler does not check parent th consistency with IsSampled() (composable_parent_threshold.cc:53-59):
    Any parsed ot_state.threshold is propagated with threshold_reliable = true without verifying parent_context.IsSampled() == (R >= ot_state.threshold). Per the consistent probability sampling spec, an inconsistent parent threshold should be erased and treated as absent.
  4. ValidateRatio silently falls back to 1.0 (100% sampling) for 0 < ratio < 2^-56 (ot_trace_state.cc:112-123):
    Called by ComposableProbabilitySampler (composable_probability.cc:23), ValidateRatio rejects ratios in (0, 2^-56) and resets them to 1.0, sampling 100% of traces instead of dropping them like ComposableAlwaysOff (or rejecting the configuration).

Expected Behavior

  1. Implement ComposableAnnotating.
  2. Align ComposableSampler::GetSamplingIntent (remove trace_id), SamplingIntent (adjusted_count_reliable), and TraceStateProvider (pass Decision) with Amend the description of Composite/Composable samplers opentelemetry-specification#5161.
  3. Verify parent_context.IsSampled() == (R >= ot_state.threshold) in ComposableParentThresholdSampler before propagating the parent threshold.
  4. Do not fall back to 1.0 (100% sampling) for positive ratios below 2^-56; treat them as 0 / non-sampling (ComposableAlwaysOff) instead.

Activity

  1. added
    needs-triage
    on Nov 20, 2026
  2. added
    triage/accepted
    spec-compliance
    and removed
    needs-triage
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec-compliancetriage/accepted

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions