You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
**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
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.
The text was updated successfully, but these errors were encountered: