-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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] invert_match not given precedence when inside and policy #33656
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
@jamesrwhite, thank you for the detailed report! I agree with your assessment: the and policy should definitely return the original |
@jpkrohling thanks for taking a look at this so soon, I'll open a PR shortly 👍 |
…hen inside and sub policy (#33671) **Description:** This fixes the handling of AND policies that contain a sub-policy with invert_match=true. Previously if the decision from a policy evaluation was `NotSampled` or `InvertNotSampled` it would return a `NotSampled` decision regardless, effectively downgrading the result. This was breaking the documented behaviour that inverted decisions should take precedence over all others. This is related to the changes made in #9768 that introduced support for using invert_match within and sub policies. **Link to tracking Issue:** #33656 **Testing:** I tested manually that this fixes the issue described in #33656 and also updated the tests. If you have any suggestions for more tests we could add let me know. **Documentation:**
It looks like this was resolved by #33671, but please correct me if I'm missing something. |
I'm reopening this given what we learned in #34085. |
Component(s)
processor/tailsampling
What happened?
Description
From my understanding of the
tailsamplingprocessor
README whenever an "inverted not sample" decision is made that trace should not be sampled, regardless of any other policies. Specifically it states:The "inverted not sample" decision having the highest precedence seems to be confirmed by how this is actually implemented here.
Based upon that I have been trying to put together a policy similar to the following:
In practice our policy is more complicated than this but I've simplified it as much as possible for the purpose of explaining this issue.
The policy looks like this in config:
What I'm finding in practice though is that traces with the
job
attribute set toboring
that only contain a single span are still being sampled. Unless I'm misunderstanding how the tail sampling processor is working this seems like a bug to me.I debugged this a bit by adding several extra log statements into the processor to see what decisions it was making on each policy and I believe the issue lies in how AND policies handled not sampled decisions here.
As you can see regardless of whether the decision is
NotSampled
orInvertNotSampled
it always returnsNotSampled
. This is problematic because aNotSampled
decision won't take precedence over aSampled
decision so anyInverNotSampled
decision that occurs within an AND policy is effectively getting downgraded to aNotSampled
decision.If it's useful for confirming this behaviour these were the extra log statements I added:
I believe the fix for this would be to return the
decision
so either theNotSampled
orInvertNotSampled
are returned respectively. I have tested this and it seems to fix the problem.I've made those changes in a branch here: main...jamesrwhite:opentelemetry-collector-contrib:fix-and-policy-invert-not-sampled.
I'm happy to open a PR with the above changes if you agree that's the correct fix, also if you need any more information please let me know.
Thanks!
Steps to Reproduce
Expected Result
Trace is not sampled.
Actual Result
Trace is sampled.
Collector version
0.102.0-dev
Environment information
Environment
OS: MacOS 14.5
Go: 1.21.0
Python: 3.12.4
OpenTelemetry Collector configuration
Log output
Additional context
This is related to support being added for
invert_match
in AND policies in #9768The text was updated successfully, but these errors were encountered: