Skip to content

Commit

Permalink
[processor/tailsampling] Allow invert matches in composite policy to …
Browse files Browse the repository at this point in the history
…continue processing (#36673)
  • Loading branch information
jpkrohling authored Dec 4, 2024
1 parent ed96f74 commit dd600c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .chloggen/tailsampling-composite-inverted-not-sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: processor/tailsampling

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Reverts #33671, allowing for composite policies to specify inverted clauses in conjunction with other policies. This is a change bringing the previous state into place, breaking users who rely on what was introduced as part of #33671."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [34085]

4 changes: 2 additions & 2 deletions processor/tailsamplingprocessor/internal/sampling/and.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,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 or InvertNotSampled it returns that
// If any subpolicy returns NotSampled or InvertNotSampled, it returns NotSampled Decision.
for _, sub := range c.subpolicies {
decision, err := sub.Evaluate(ctx, traceID, trace)
if err != nil {
return Unspecified, err
}
if decision == NotSampled || decision == InvertNotSampled {
return decision, nil
return NotSampled, nil
}
}
return Sampled, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ 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, InvertNotSampled, decision)
assert.Equal(t, NotSampled, decision)
}

0 comments on commit dd600c1

Please sign in to comment.