From dd600c17034e1e4cbee80a07274b65777fdf9eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Wed, 4 Dec 2024 22:18:23 +0100 Subject: [PATCH] [processor/tailsampling] Allow invert matches in composite policy to continue processing (#36673) --- .../tailsampling-composite-inverted-not-sample.yaml | 12 ++++++++++++ .../tailsamplingprocessor/internal/sampling/and.go | 4 ++-- .../internal/sampling/and_test.go | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .chloggen/tailsampling-composite-inverted-not-sample.yaml diff --git a/.chloggen/tailsampling-composite-inverted-not-sample.yaml b/.chloggen/tailsampling-composite-inverted-not-sample.yaml new file mode 100644 index 000000000000..dcbc067e5575 --- /dev/null +++ b/.chloggen/tailsampling-composite-inverted-not-sample.yaml @@ -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] + diff --git a/processor/tailsamplingprocessor/internal/sampling/and.go b/processor/tailsamplingprocessor/internal/sampling/and.go index 408fedfbd240..0be2a52e60f7 100644 --- a/processor/tailsamplingprocessor/internal/sampling/and.go +++ b/processor/tailsamplingprocessor/internal/sampling/and.go @@ -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 diff --git a/processor/tailsamplingprocessor/internal/sampling/and_test.go b/processor/tailsamplingprocessor/internal/sampling/and_test.go index 29a771971665..4fe8a081cba3 100644 --- a/processor/tailsamplingprocessor/internal/sampling/and_test.go +++ b/processor/tailsamplingprocessor/internal/sampling/and_test.go @@ -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) }