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 the behavior of inverse numeric filters #34416

Merged

Conversation

bacherfl
Copy link
Contributor

@bacherfl bacherfl commented Aug 6, 2024

Description: This PR fixes the behaviour of numeric attribute filters with the inverse_match option set to true. In this case, the numeric filter now returns InvertNotSampled/InvertSampled if its condition matches, to make sure a span with matching attributes is not sampled even though other policies might yield a Sampled result.

Link to tracking Issue: #34296

Testing: Added unit tests

Documentation: No changes here, as the expected behavior is already described in the docs

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@github-actions github-actions bot added the processor/tailsampling Tail sampling processor label Aug 6, 2024
@github-actions github-actions bot requested a review from jpkrohling August 6, 2024 11:05
@bacherfl bacherfl marked this pull request as ready for review August 7, 2024 05:26
@bacherfl bacherfl requested a review from a team August 7, 2024 05:26
{
Desc: "span attribute at the upper limit",
Trace: newTraceIntAttrs(empty, "example", math.MaxInt32),
Decision: Sampled,
},
{
Desc: "resource attribute at the upper limit",
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32}, "non_matching", math.MinInt32),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32}, "non_matching", math.MinInt32),
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32}, "non_matching", math.MaxInt32),

},
{
Desc: "resource attribute above max limit",
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32 + 1}, "non_matching", math.MinInt32),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32 + 1}, "non_matching", math.MinInt32),
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32 + 1}, "non_matching", math.MaxInt32),

Or

Suggested change
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32 + 1}, "non_matching", math.MinInt32),
Trace: newTraceIntAttrs(map[string]any{"example": math.MinInt32 + 1}, "non_matching", math.MinInt32),

},
{
Desc: "resource attribute at the lower limit",
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32}, "non_matching", math.MinInt32),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Trace: newTraceIntAttrs(map[string]any{"example": math.MaxInt32}, "non_matching", math.MinInt32),
Trace: newTraceIntAttrs(map[string]any{"example": math.MinInt32}, "non_matching", math.MinInt32),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there's already a test a few line above with the same name. I wonder if they are the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for spotting this - in this case the name of the test is misleading as it should be resource attribute at upper limit - will fix that

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@jpkrohling jpkrohling merged commit 2d4fe3d into open-telemetry:main Aug 19, 2024
156 checks passed
@github-actions github-actions bot added this to the next release milestone Aug 19, 2024
f7o pushed a commit to f7o/opentelemetry-collector-contrib that referenced this pull request Sep 12, 2024
…pen-telemetry#34416)

**Description:** This PR fixes the behaviour of numeric attribute
filters with the `inverse_match` option set to `true`. In this case, the
numeric filter now returns `InvertNotSampled`/`InvertSampled` if its
condition matches, to make sure a span with matching attributes is not
sampled even though other policies might yield a `Sampled` result.

**Link to tracking Issue:** open-telemetry#34296

**Testing:** Added unit tests

**Documentation:** No changes here, as the expected behavior is already
described in the docs

---------

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/tailsampling Tail sampling processor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants