-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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/transform] Add support for toggling scalar value types #11810
Comments
@Mrod1598 the metrics context allows accessing (Get and Set) of a scalar value using {
query: []string{`set(value_int, 2) where value_double == 1.0`},
want: func(td pmetric.Metrics) {
td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(0).SetIntVal(2)
},
}, |
Got it thanks! is that documented somewhere that I missed? |
wait actually isn't that changing the value of the actual data point and not toggling the type? my scenario is where the value is stored as a double but should be stored as an int. |
I think this is an instance where the README's statement of "everything can be accessed using the OTLP protobuf names" isn't completely honest. To handle how pdata represents the protobuf's requirements of value for NumberDataPoint the TQL had to make up a accessor and
pdata (what the Transform Processor is beholden to) doesn't have a concept of "change the value type without changing the value". pdata allows you to check the value type, but not set it. It allows you to set an int value (which updates the value type) and set a double value (which updates the value type) For your scenario I tried: set(value_int, value_double) Which doesn't work because the float64 returned by |
I think we need a new Factory function that lets you cast to a Int. then we could do set(value_int, Int(value_double)) |
Can I pick this up? |
@deepto98 It's yours |
@mcdoker18 do you plan to update the transform processor with the new function? |
@TylerHelmuth sorry for the delay, I was on vacation :) |
@TylerHelmuth qqs on this:
|
@bogdandrutu current naming guidelines are that Factory Functions be named with uppercase to differentiate from regular functions. We could probably update setters to be smarter, checking the passed in value and seeing if it can be casted. That would be a more generic solution if it works. But there might still be good reasons for a Factory Function like during comparison. I don't remember how many casting assumptions we make in there. Could also be usable when passing parameters to other functions. The factory function is pretty flexible whereas the setter is only usable when the destination is involved with needing a type change. |
…14482) [processor/transform] Added Int function to the transform processor (#14338) [processor/transform] Added the Int function to the transform processor (#11810) Co-authored-by: Vitalii Solodilov <[email protected]>
Is your feature request related to a problem? Please describe.
When collecting from prometheus, a
value_type
is assigned and sometimes incorrectly. Using this processor, it should be possible to toggle from double to int or the other way around in this processor.Describe the solution you'd like
implementation of either the ability to use the set function to change it, or a new function to toggle it for a metric separate from the set function.
The text was updated successfully, but these errors were encountered: