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] numeric attribute invert match evaluation not prioritized #34296

Open
hyang023 opened this issue Jul 29, 2024 · 5 comments
Labels
bug Something isn't working processor/tailsampling Tail sampling processor

Comments

@hyang023
Copy link

Component(s)

processor/tailsampling

What happened?

Description

as described in the tail sampling processor readme (https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor),

When there's an "inverted not sample" decision, the trace is not sampled;

this functionality does not work for numeric attribute policies because its Evaluate function only returns Sampled or NotSampled values not InvertNotSampled or InvertSampled even if invertMatch is true

The Evaluate function in https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/tailsamplingprocessor/internal/sampling/numeric_tag_filter.go#L37 needs to be updated so that it can return InvertNotSampled or InvertSampled when appropriate

This would likely require the addition of an invertHasSpanWithCondition in https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/tailsamplingprocessor/internal/sampling/util.go and then calling it from https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/tailsamplingprocessor/internal/sampling/numeric_tag_filter.go if invertMatch is true

Steps to Reproduce

  • use invert_match in numeric_attribute sampling policy
  • have other policy where spans that match overlap with the number_attribute invert_match

Expected Result

  • any trace with spans that invert_match the numeric_attribute should not be sampled

Actual Result

  • some traces with spans that invert_match the numeric_attribute will still be sampled because they match some other policy

Collector version

v0.105.0 but previous versions would also be affected

Environment information

Environment

this is not environment specific

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

@hyang023 hyang023 added bug Something isn't working needs triage New item requiring triage labels Jul 29, 2024
@github-actions github-actions bot added the processor/tailsampling Tail sampling processor label Jul 29, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@bacherfl
Copy link
Contributor

bacherfl commented Aug 6, 2024

I'd be happy to look into this and work on a fix

@bacherfl
Copy link
Contributor

bacherfl commented Aug 6, 2024

After looking into this, I have two questions related to the policy evaluators:

  1. While the string tag filter checks both the resource and the span attributes (see ), the numeric filter only considers span attributes, but no resource attributes (see
    return hasSpanWithCondition(batches, func(span ptrace.Span) bool {
    ) - Is this intended, or should the numeric tag filter also take attributes of the resource into account?
  2. Currently, the boolean tag filter seems to not support the inverse_match option at all (see https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/tailsamplingprocessor/internal/sampling/boolean_tag_filter.go) - Should that filter be extended to also suppport this option, or is there a reason to not include this option here? I guess this would need to be addressed in a separate PR as it's not directly related to this issue, but if needed I can also work on this

@jpkrohling
Copy link
Member

Is this intended, or should the numeric tag filter also take attributes of the resource into account?

Probably just an oversight/bug.

is there a reason to not include this option here

The invert match was added originally for the string only. In the name of consistency, it would be good to have it for all types though.

@bacherfl
Copy link
Contributor

Is this intended, or should the numeric tag filter also take attributes of the resource into account?

Probably just an oversight/bug.

is there a reason to not include this option here

The invert match was added originally for the string only. In the name of consistency, it would be good to have it for all types though.

Thanks @jpkrohling - In this case I will also consider the resource attributes in the numeric filter and for the boolean filter I would create a separate PR to also support the inverse option there

jpkrohling pushed a commit that referenced this issue Aug 19, 2024
…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:** #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>
f7o pushed a commit to f7o/opentelemetry-collector-contrib that referenced this issue 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>
jpkrohling pushed a commit that referenced this issue Sep 18, 2024
…ute filter (#34730)

**Description:** This PR adds the `invert_match` option for
`boolean_attribute` filters, as discussed in
#34296 (comment)

**Link to tracking Issue:** #34296

**Testing:** Added unit tests

**Documentation:** The existing documentation already covered the
semantics of the `invert_match` option

---------

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this issue Oct 4, 2024
…ute filter (open-telemetry#34730)

**Description:** This PR adds the `invert_match` option for
`boolean_attribute` filters, as discussed in
open-telemetry#34296 (comment)

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

**Testing:** Added unit tests

**Documentation:** The existing documentation already covered the
semantics of the `invert_match` option

---------

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@atoulme atoulme removed the needs triage New item requiring triage label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working processor/tailsampling Tail sampling processor
Projects
None yet
Development

No branches or pull requests

4 participants