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/tailsamplingprocessor] Is it possible to pass an array of numbers to policy #22849

Closed
koungkub opened this issue May 29, 2023 · 10 comments
Labels
needs triage New item requiring triage processor/tailsampling Tail sampling processor

Comments

@koungkub
Copy link

koungkub commented May 29, 2023

Component(s)

processor/tailsampling

Describe the issue you're reporting

I'd like to pass an array of numbers on the numeric_attribute policy. for instance

policies:
    [
        {
            name: array_of_numbers
            type: xxx
            xxx: {key: yyy, values: [2, 4, 12, 13, 14]}
        }
    ]
@koungkub koungkub added the needs triage New item requiring triage label May 29, 2023
@github-actions github-actions bot added the processor/tailsampling Tail sampling processor label May 29, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

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

@jiekun
Copy link
Member

jiekun commented May 29, 2023

I would like to check if the OTTL policy could meet your needs later. I think it should work like:

policies:
    [
        {
              name: ottl-test,
              type: ottl_condition,
              ottl_condition: {
                   error_mode: ignore,
                   span: [
                        "attributes[\"test_attr_key_1\"] == 2",
                        "attributes[\"test_attr_key_2\"] == 4",
                   ]
              }
         }
    ]

But maybe we could write a more concise OTTL expression.

@koungkub
Copy link
Author

@jiekun It's better if we have a condition that accepted an array of numbers.

@jiekun
Copy link
Member

jiekun commented May 30, 2023

@jiekun It's better if we have a condition that accepted an array of numbers.

@koungkub I think OTTL could handle array. You could check it here: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl#lists

I'm sorry that I cannot do some test myself yesterday due to limited time. I will add some test example. And maybe you could read the OTTL doc to see if it met your expectation as well.

@koungkub
Copy link
Author

@jiekun It's better if we have a condition that accepted an array of numbers.

@koungkub I think OTTL could handle array. You could check it here: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl#lists

I'm sorry that I cannot do some test myself yesterday due to limited time. I will add some test example. And maybe you could read the OTTL doc to see if it met your expectation as well.

Thanks

@jiekun
Copy link
Member

jiekun commented May 30, 2023

Alright I think the boolean expression support those operation:

The valid operators are:

Equal (==). Tests if the left and right Values are equal (see the Comparison Rules below).
Not Equal (!=). Tests if the left and right Values are not equal.
Less Than (<). Tests if left is less than right.
Greater Than (>). Tests if left is greater than right.
Less Than or Equal To (<=). Tests if left is less than or equal to right.
Greater Than or Equal to (>=). Tests if left is greater than or equal to right.

The list value is acceptable for an OTTL function tho.

I would like to ping OTTL master @TylerHelmuth for help. :P

@TylerHelmuth
Copy link
Member

OTTL supports passing lists in the grammar, but doesn't have in or contains functionality.

If I am understanding the problem statement correctly, you want to check if an attribute with a numeric value is one of several possible values. This is achievable with the OTTL condition policy exactly as @jiekun suggested:

policies:
    [
        {
              name: ottl-test,
              type: ottl_condition,
              ottl_condition: {
                   error_mode: ignore,
                   span: [
                        attributes["yyy"] == 2,
                        attributes["yyy"] == 4,
                        attributes["yyy"] == 12,
                        attributes["yyy"] == 13,
                        attributes["yyy"] == 14,
                   ]
              }
         }
    ]

If any of the statements is true the policy will resolve to true. This is functionally equivalent to

policies:
    [
        {
            name: array_of_numbers
            type: xxx
            xxx: {key: yyy, values: [2, 4, 12, 13, 14]}
        }
    ]

With some improvements to pkg/ottl we can make the statement more precise, but the functionality wouldn't change.

@koungkub
Copy link
Author

@jiekun @TylerHelmuth Thank you so much. It's working correctly.

@koungkub
Copy link
Author

@TylerHelmuth I agree with you about the precise statement of ottl. It should be accepted array of either strings or numbers

@TylerHelmuth
Copy link
Member

@koungkub if you'd like please open a new issue for pkg/ottl requesting that enhancement. Since the problem statement for this issue is solved I am going to close this issue, but ping me if you think it should be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage New item requiring triage processor/tailsampling Tail sampling processor
Projects
None yet
Development

No branches or pull requests

3 participants