Skip to content

Commit

Permalink
[transformprocessor]: Remove unnecessary data copy when transform sum…
Browse files Browse the repository at this point in the history
… to/from gauge

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Sep 13, 2024
1 parent 91751e5 commit 698d25c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func convertGaugeToSum(stringAggTemp string, monotonic bool) (ottl.ExprFunc[ottl
metric.SetEmptySum().SetAggregationTemporality(aggTemp)
metric.Sum().SetIsMonotonic(monotonic)

// Setting the data type removed all the data points, so we must copy them back to the metric.
dps.CopyTo(metric.Sum().DataPoints())
// Setting the data type removed all the data points, so we must move them back to the metric.
dps.MoveAndAppendTo(metric.Sum().DataPoints())

return nil, nil
}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func convertDatapointGaugeToSum(stringAggTemp string, monotonic bool) (ottl.Expr
metric.SetEmptySum().SetAggregationTemporality(aggTemp)
metric.Sum().SetIsMonotonic(monotonic)

// Setting the data type removed all the data points, so we must copy them back to the metric.
dps.CopyTo(metric.Sum().DataPoints())
// Setting the data type removed all the data points, so we must move them back to the metric.
dps.MoveAndAppendTo(metric.Sum().DataPoints())

return nil, nil
}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func convertSumToGauge() (ottl.ExprFunc[ottlmetric.TransformContext], error) {
dps := metric.Sum().DataPoints()

// Setting the data type removed all the data points, so we must copy them back to the metric.
dps.CopyTo(metric.SetEmptyGauge().DataPoints())
dps.MoveAndAppendTo(metric.SetEmptyGauge().DataPoints())

return nil, nil
}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func convertDatapointSumToGauge() (ottl.ExprFunc[ottldatapoint.TransformContext]

dps := metric.Sum().DataPoints()

// Setting the data type removed all the data points, so we must copy them back to the metric.
dps.CopyTo(metric.SetEmptyGauge().DataPoints())
// Setting the data type removed all the data points, so we must move them back to the metric.
dps.MoveAndAppendTo(metric.SetEmptyGauge().DataPoints())

return nil, nil
}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func createExtractSumMetricFunction(_ ottl.FunctionContext, oArgs ottl.Arguments
return extractSumMetric(args.Monotonic)
}

// this interface helps unify the logic for extracting data from different histogram types
// SumCountDataPoint interface helps unify the logic for extracting data from different histogram types
// all supported metric types' datapoints implement it
type SumCountDataPoint interface {
Attributes() pcommon.Map
Expand Down

0 comments on commit 698d25c

Please sign in to comment.