-
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
[pkg/ottl] Add support for scaling values #33246
[pkg/ottl] Add support for scaling values #33246
Conversation
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
|
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
…' into feat/16214/scale-metric-values
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
…' into feat/16214/scale-metric-values
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this one on, it's looking a bit more involved than I thought at first glance.
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
…' into feat/16214/scale-metric-values
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
pkg/ottl/ottlfuncs/func_scale.go
Outdated
|
||
type ScaleArguments[K any] struct { | ||
Value ottl.GetSetter[K] | ||
Multiplier float64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like @TylerHelmuth mentioned, could we add an optional parameter to adjust the unit? I think it would be nice for usability to do all scaling in one statement.
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@TylerHelmuth @evan-bradley Thanks for the reviews- I have made the requested changes (moved the implementation to the transformprocessor and added an optional unit parameter) |
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
if !args.Unit.IsEmpty() { | ||
unit, err := args.Unit.Get().Get(ctx, tCtx) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get unit from ScaleArguments: %w", err) | ||
} | ||
metric.SetUnit(unit) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do this check first - if a unit is specified and we can't retrieve it we shouldnt scale the metric. Actually setting the unit can happen after the switch statement to ensure we only update the metric if we pass the error checks in the switch statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good suggestion, I have adapted the logic accordingly
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
@TylerHelmuth can you please have another look? |
Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Description:
Adds a
Scale
function to the OTTL package. This function can be applied toint
/double
values, as well as metrics of the following types:Link to tracking Issue: #16214
Testing: Added Unit and E2E tests in the OTTL package. Tested manually in a sample environment with the following example configuration:
Documentation: Added documentation in the
README
describing all functions in theottl
package