[processor/tailsampling] add sampling_strategy with root-only mode and stateful-policy guard#46701
Closed
carsonip wants to merge 9 commits into
Closed
[processor/tailsampling] add sampling_strategy with root-only mode and stateful-policy guard#46701carsonip wants to merge 9 commits into
carsonip wants to merge 9 commits into
Conversation
When sample_on_root_span_only is enabled and a root span arrives, evaluate immediately and avoid appending that root-triggering batch to tail storage. For sampled traces, merge the current batch in memory with any previously buffered spans and release once; add a regression test to verify append/take behavior. Assisted-by: ChatGPT Made-with: Cursor
Resolve tailsamplingprocessor conflict by keeping root-only immediate decision path and avoiding appending the root-triggering batch before release. Made-with: Cursor
…ng_strategy Introduce a string enum sampling_strategy to describe decision timing semantics explicitly, with full-trace-way-out as default and root-span-only-way-in for immediate root-based decisions. Update processor logic, schema, docs, and tests to use the new strategy and validate unsupported values. Assisted-by: ChatGPT 5.3 Made-with: Cursor
Add IsStateful() to the samplingpolicy.Evaluator interface and implement it across all tail sampling evaluators while keeping the previous stateful semantics based on evaluator-held state across evaluations. Made-with: Cursor
…fulness Enforce root-span-only-way-in compatibility at policy construction time by rejecting evaluators that report IsStateful(), so statefulness stays defined by policy implementations and extensions without duplicating policy rules in config validation. Made-with: Cursor
Remove newTracesProcessor fallback for empty sampling_strategy and update direct Config literals in tests/benchmarks/fuzz to set full-trace-way-out explicitly, keeping validation strict while relying on default config initialization in production paths. Made-with: Cursor
Keep sampling_strategy as a typed enum but make the type and constants package-private so they are not exported outside tailsamplingprocessor, while preserving strict validation and existing behavior. Made-with: Cursor
Document sampling_strategy in the existing flat option-list style and describe both values inline with clearer behavior semantics for decision timing and root-only evaluation scope. Made-with: Cursor
Contributor
Author
|
Superseded by #46762 |
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.
Description
Alternative to #46613
This PR adds a new tail sampling processor config,
sampling_strategy, to support root-span-triggered decisioning while preserving classic tail-sampling behavior as the default.Motivation:
Implementation details:
sampling_strategyto config/schema/docs with two modes:full-trace-way-out(default): classic tail sampling from accumulated trace data.root-span-only-way-in: decide immediately on root span arrival using root-span-only trace data.decision_wait/decision_wait_after_root_receiveddo not drive decisions.IsStateful()tosamplingpolicy.Evaluatorand implements it across built-in policies/combinators.sampling_strategy=root-span-only-way-in, evaluators reportingIsStateful()==trueare rejected.Behavior notes:
full-trace-way-outremains the default behavior.root-span-only-way-in, policies that require non-root span data are not meaningful.Link to tracking issue
Fixes #46600
Testing
IsStateful()behavior in evaluators/combinators.go test ./...inprocessor/tailsamplingprocessor.Documentation
processor/tailsamplingprocessor/README.mdforsampling_strategyand mode semantics.Made with Cursor