Skip to content

Add ComposableAlwaysRecord sampler - #5283

Draft
aryansk wants to merge 1 commit into
open-telemetry:mainfrom
aryansk:codex/issue-5266-composable-always-record
Draft

Add ComposableAlwaysRecord sampler#5283
aryansk wants to merge 1 commit into
open-telemetry:mainfrom
aryansk:codex/issue-5266-composable-always-record

Conversation

@aryansk

@aryansk aryansk commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #5266

Problem

Composable samplers can only delegate to other composable samplers and cannot delegate to a plain Sampler. That is why ComposableAlwaysOn exists as the composable counterpart to plain AlwaysOn. The specification defines a plain AlwaysRecord decorator that ensures every span is recorded (converting DROPRECORD_ONLY), but the corresponding composable ComposableAlwaysRecord type is missing. Without it, a CompositeSampler cannot achieve the AlwaysRecord guarantee because it only accepts ComposableSampler delegates.

Reproduction is structural: specification/trace/sdk.md lists AlwaysRecord under Built-in samplers and ComposableAlwaysOn/ComposableAlwaysOff under Built-in ComposableSamplers, but no ComposableAlwaysRecord exists. Issue #5266 reports the gap and notes it is needed for parity.

Change

  • Add ###### ComposableAlwaysRecord under Built-in ComposableSamplers in specification/trace/sdk.md, mirroring the style of ComposableAlwaysOn/ComposableAlwaysOff/ComposableAnnotating.
  • Update the SDK TOC to include ComposableAlwaysRecord.
  • Define required behavior: wrap a delegate ComposableSampler; if delegate returns no threshold (DROP), return a SamplingIntent that results in RECORD_ONLY; otherwise return the delegate intent unchanged, preserving threshold, adjusted_count_reliable, attributes_provider, and trace_state_provider.
  • Add constraints: RECORD_ONLY intent sets adjusted_count_reliable=false and adds no attributes; threshold-present path does not alter delegate state.
  • Add Unreleased CHANGELOG.md entry under Traces.

Keep unrelated cleanup out of this PR.

Why this approach

This follows the existing pattern where every useful plain sampler has a composable counterpart for use inside CompositeSampler. The delegate-wrapping shape matches ComposableAnnotating/ComposableParentThreshold (both wrap a delegate) and plain AlwaysRecord (both wrap a root). Alternative of not adding it would leave CompositeSampler unable to express always-record semantics needed for span-to-metrics pipelines.

Testing

command: git diff --check
result: clean

command: grep -n ComposableAlwaysRecord specification/trace/sdk.md
result: 55: * [ComposableAlwaysRecord](#composablealwaysrecord)
         748:###### ComposableAlwaysRecord

command: head -n 30 specification/trace/sdk.md (TOC renders)
result: TOC now includes ComposableAlwaysRecord alongside ComposableAnnotating

make markdownlint / make cspell require npm ci and Docker for link-check; local git diff --check passes and the markdown structure matches surrounding sections. Hosted CI will run the full make check.

Documentation and release impact

  • User-facing documentation updated (specification/trace/sdk.md)
  • Changelog/release note needed (Unreleased Traces entry added)
  • Migration or compatibility note needed
  • No documentation impact

Review notes

  • Known limitations: none beyond spec scope
  • Follow-up issue, if any: none
  • Security/licensing considerations: none, spec text only

Fixes open-telemetry#5266

Composable samplers can only delegate to other composable samplers,
so the existing plain AlwaysRecord decorator is not usable inside a
CompositeSampler. This mirrors AlwaysOn/AlwaysOff which have composable
counterparts ComposableAlwaysOn/ComposableAlwaysOff.

Adds the new built-in ComposableAlwaysRecord under Built-in
ComposableSamplers, updates the SDK TOC, and adds an Unreleased
CHANGELOG entry. The decorator wraps a delegate ComposableSampler:
if the delegate returns no threshold (DROP), the wrapper returns
RECORD_ONLY; otherwise the delegate intent is returned unchanged,
preserving threshold, adjusted_count_reliable, and providers.

Validation: git diff --check clean, markdown structure matches surrounding
sections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The ComposableAlwaysRecord sampler is missing

1 participant