Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/tailsampling] fix InvertNotSampled decision precedence when inside and sub policy #33671

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions processor/tailsamplingprocessor/internal/sampling/and.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ func NewAnd(
// Evaluate looks at the trace data and returns a corresponding SamplingDecision.
func (c *And) Evaluate(ctx context.Context, traceID pcommon.TraceID, trace *TraceData) (Decision, error) {
// The policy iterates over all sub-policies and returns Sampled if all sub-policies returned a Sampled Decision.
// If any subpolicy returns NotSampled, it returns NotSampled Decision.
// If any subpolicy returns NotSampled or InvertNotSampled it returns that
for _, sub := range c.subpolicies {
decision, err := sub.Evaluate(ctx, traceID, trace)
if err != nil {
return Unspecified, err
}
if decision == NotSampled || decision == InvertNotSampled {
return NotSampled, nil
return decision, nil
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ func TestAndEvaluatorStringInvertNotSampled(t *testing.T) {
}
decision, err := and.Evaluate(context.Background(), traceID, trace)
require.NoError(t, err, "Failed to evaluate and policy: %v", err)
assert.Equal(t, decision, NotSampled)
assert.Equal(t, decision, InvertNotSampled)

}
Loading