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

Allow access to the metrics slice in the OTTL metric context #24446

Closed
swiatekm opened this issue Jul 24, 2023 · 1 comment
Closed

Allow access to the metrics slice in the OTTL metric context #24446

swiatekm opened this issue Jul 24, 2023 · 1 comment
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium

Comments

@swiatekm
Copy link
Contributor

Component(s)

pkg/ottl

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

In order to write OTTL functions which create new metrics based on existing ones, the functions need access to the MetricsSlice. Currently, only the datapoint context has access to this, which requires unpleasant workarounds.

Describe the solution you'd like

I'd like to let functions running in the metric context have access to the whole MetricsSlice.

Describe alternatives you've considered

When creating a metric based on another metric, it's also possible to use the datapoint context and create a new metric for each datapoint. This, however, is inefficient, and the result may be confusing to users.

To mitigate the above, it's possible to cache the new metric in the context or the MetricsSlice, and only add datapoints to it if it already exists. These solutions either require significantly more complexity than the proposed one, or they make assumptions about the OTTL execution logic which aren't part of the spec, and may change in the future.

See the following discussion for more context: #24368 (comment)

Additional context

I want to implement functions for extracting sum and count metrics from Histograms, as described in #22853, and ran into this problem. After looking at various approaches with @TylerHelmuth in #24368, we liked this one the most. I'm creating a separate issue and PR for this change, as it's breaking for users of OTTL outside of contrib.

@swiatekm swiatekm added enhancement New feature or request needs triage New item requiring triage labels Jul 24, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

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

@mx-psi mx-psi added priority:p2 Medium and removed needs triage New item requiring triage labels Jul 24, 2023
TylerHelmuth pushed a commit that referenced this issue Jul 25, 2023
**Description:**
Allow OTTL functions to access the MetricsSlice in the metric context.
This makes it possible for functions to create new metrics without
having to use the datapoint context.


**Link to tracking Issue:**
#24446

**Testing:**
Tested this change with a new function in #24368
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
Projects
None yet
Development

No branches or pull requests

2 participants