Add ComposableAlwaysRecord sampler - #5283
Draft
aryansk wants to merge 1 commit into
Draft
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5266
Problem
Composable samplers can only delegate to other composable samplers and cannot delegate to a plain
Sampler. That is whyComposableAlwaysOnexists as the composable counterpart to plainAlwaysOn. The specification defines a plainAlwaysRecorddecorator that ensures every span is recorded (convertingDROP→RECORD_ONLY), but the corresponding composableComposableAlwaysRecordtype is missing. Without it, aCompositeSamplercannot achieve theAlwaysRecordguarantee because it only acceptsComposableSamplerdelegates.Reproduction is structural:
specification/trace/sdk.mdlistsAlwaysRecordunder Built-in samplers andComposableAlwaysOn/ComposableAlwaysOffunder Built-in ComposableSamplers, but noComposableAlwaysRecordexists. Issue #5266 reports the gap and notes it is needed for parity.Change
###### ComposableAlwaysRecordunderBuilt-in ComposableSamplersinspecification/trace/sdk.md, mirroring the style ofComposableAlwaysOn/ComposableAlwaysOff/ComposableAnnotating.ComposableAlwaysRecord.ComposableSampler; if delegate returns no threshold (DROP), return aSamplingIntentthat results inRECORD_ONLY; otherwise return the delegate intent unchanged, preserving threshold,adjusted_count_reliable,attributes_provider, andtrace_state_provider.RECORD_ONLYintent setsadjusted_count_reliable=falseand adds no attributes; threshold-present path does not alter delegate state.CHANGELOG.mdentry 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 matchesComposableAnnotating/ComposableParentThreshold(both wrap a delegate) and plainAlwaysRecord(both wrap a root). Alternative of not adding it would leaveCompositeSamplerunable to express always-record semantics needed for span-to-metrics pipelines.Testing
make markdownlint/make cspellrequirenpm ciand Docker for link-check; localgit diff --checkpasses and the markdown structure matches surrounding sections. Hosted CI will run the fullmake check.Documentation and release impact
specification/trace/sdk.md)Review notes