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

OTTP: Add math expression for logarithm #18076

Closed
mterhar opened this issue Jan 27, 2023 · 6 comments
Closed

OTTP: Add math expression for logarithm #18076

mterhar opened this issue Jan 27, 2023 · 6 comments
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium processor/transform Transform processor

Comments

@mterhar
Copy link
Contributor

mterhar commented Jan 27, 2023

Component(s)

processor/transform

Is your feature request related to a problem? Please describe.

The transform processor has the ability to do a lot of very cool stuff. One thing it can't do is log(duraion). The example has sum([1, 2, 3, 4]) but that doesn't seem implemented.

Describe the solution you'd like

I'd like to see the a log(x) function that can be called as a math expression and return the log of the number. This could be combined with rounding down or coercing to integer to make buckets with durations which can then be used for sampling.

Describe alternatives you've considered

The existing soution is just to have a bunch of set() where statements. To get good resolution out of this, there would need to be a ton more and they don't seem to have an "else" option so it always evaluates all of them even if the 1st or 2nd one is the only one that would be true.

transform:
  trace_statements:
    - context: span
      statements:
        - set(attributes["tp_duration"], end_time_unix_nano - start_time_unix_nano)
        - set(attributes["duration_bucket"], "quick") where attributes["tp_duration"] < 1000000
        - set(attributes["duration_bucket"], "slow") where attributes["tp_duration"] >= 1000000 and attributes["tp_duration"] < 5000000
        - set(attributes["duration_bucket"], "veryslow") where attributes["tp_duration"] >= 5000000

Additional context

No response

@mterhar mterhar added enhancement New feature or request needs triage New item requiring triage labels Jan 27, 2023
@github-actions github-actions bot added the processor/transform Transform processor label Jan 27, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

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

@TylerHelmuth TylerHelmuth added pkg/ottl priority:p2 Medium and removed needs triage New item requiring triage labels Jan 27, 2023
@TylerHelmuth
Copy link
Member

@mterhar I imagine this would be a Converter function that would take a number and return a number, so it would still need to be used with set if you wanted to modify any of the telemetry being processed. Can you give an example of how you'd use the Log function?

Also, do you think it is worth defining the base as a parameter?

mterhar added a commit to mterhar/opentelemetry-collector-contrib that referenced this issue Jan 31, 2023
@mterhar
Copy link
Contributor Author

mterhar commented Jan 31, 2023

Thanks for pointing me toward the place to add it. The pattern seemed simple enough to replicate from how Int is implemented, tested, and documented in the readme.

@mterhar
Copy link
Contributor Author

mterhar commented Jan 31, 2023

I looked at some logs with different bases and it does not seem important at this point. If there's a compelling reason to follow a slightly different curve at the expense of double (or more) complexity, then I'll let someone else make the case.

mterhar added a commit to mterhar/opentelemetry-collector-contrib that referenced this issue Feb 15, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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

@github-actions github-actions bot added the Stale label Apr 3, 2023
@TylerHelmuth TylerHelmuth removed the Stale label Apr 3, 2023
mterhar added a commit to mterhar/opentelemetry-collector-contrib that referenced this issue May 11, 2023
mterhar added a commit to mterhar/opentelemetry-collector-contrib that referenced this issue May 15, 2023
TylerHelmuth added a commit that referenced this issue May 15, 2023
* Add Log() to ottlfuncs

Addresses issue #18076

* redo the logarithm ottl with the new format

* Handle negatives and zero as nil rather than NaN

* replace lots of logic with FloatLikeGetter

* Updated tests to work with FloatLikeGetter

* Update readme with suggestion

Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>

---------

Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
varunraiko pushed a commit to varunraiko/opentelemetry-collector-contrib that referenced this issue May 17, 2023
* Add Log() to ottlfuncs

Addresses issue open-telemetry#18076

* redo the logarithm ottl with the new format

* Handle negatives and zero as nil rather than NaN

* replace lots of logic with FloatLikeGetter

* Updated tests to work with FloatLikeGetter

* Update readme with suggestion

Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>

---------

Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
@TylerHelmuth
Copy link
Member

closed via #22014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium processor/transform Transform processor
Projects
None yet
Development

No branches or pull requests

2 participants