Skip to content

[BUG] using has-root-span with root.duration_ms in a rule causing rules to be skipped #1757

@howardyoo

Description

@howardyoo

Versions

  • Go: N/A
  • Refinery: 3.0

Steps to reproduce

  1. Define a rule
rules:
  RulesVersion: 2

  Samplers:
    __default__:
      RulesBasedSampler:
        Rules:
          ...
          - Name: Small Fast Traces
            Scope: span
            Conditions:
              - Operator: has-root-span
                Value: true
              - Field: root.duration_ms
                Operator: '<'
                Value: 1000
                Datatype: int
              - Field: "?.NUM_DESCENDANTS"
                Operator: '<='
                Value: 2
                Datatype: int
            Sampler:
              EMADynamicSampler:
                GoalSampleRate: 1000
                FieldList:
                  - service.name
                  - name
           ...

Notice that the rule has has-root-span: true
and also root.duration_ms on certain condition. When testing the refinery, even though a trace would have the matching condition, the rule would not be triggered, and the trace would go into the default sampler.

However, when I removed the has-root-span condition, the sampling would work fine, getting triggered with trace having shorter duration than 1000 and also num of descendants less than 2.

Additional context
Logically, the above condition should work, as the subject trace has a root span, as well as descendants of less than 2, and the duration_ms of the root span is less than 1000. Therefore, it feels likely to be a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Github SyncedIssue is synced with a private project management tool.type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions