Skip to content

Unexpected behavior of And policy #29637

Closed as not planned
Closed as not planned
@chenlujjj

Description

@chenlujjj

Component(s)

processor/tailsampling

What happened?

Description

I tried to use the tailsampling processor to drop the health check traces of a particular service (let's name is foo here), but the behavior of the And policy was out of my expectation.

Steps to Reproduce

The first version of config:

tail_sampling:
  policies:
    - name: backwards-compatibility-policy
      type: and
      and:
        and_sub_policy:
          - name: services-using-tail_sampling-policy
            type: string_attribute
            string_attribute:
              invert_match: true
              key: service.name
              values:
                - foo
    - name: sample-others
      type: and
      and:
        and_sub_policy:
          - name: service-name-policy
            string_attribute:
              key: service.name
              values:
                - foo
            type: string_attribute
          - name: operation-policy
            string_attribute:
              invert_match: true
              key: http.route
              values:
                - /actuator/health/**
            type: string_attribute

It worked as I expected, excluding all traces with http.route=/actuator/health/** of service foo.

Then I thought maybe I could simplify the config a bit, as below:

tail_sampling:
  policies:
    - name: services-using-tail_sampling-policy
      type: string_attribute
      string_attribute:
        invert_match: true
        key: service.name
        values:
          - foo
    - name: sample-others
      type: and
      and:
        and_sub_policy:
          - name: service-name-policy
            string_attribute:
              key: service.name
              values:
                - foo
            type: string_attribute
          - name: operation-policy
            string_attribute:
              invert_match: true
              key: http.route
              values:
                - /actuator/health/**
            type: string_attribute

The only change was moving the sub policy of And to the top level.
Then I found that other traces with http.route not equal to /actuator/health/** of service foo were dropped too.

Expected Result

Moving the only one sub policy of And to the top level should not change its behavior.

Actual Result

The policy behavior is changed

Collector version

0.79.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions