Skip to content

Commit 0595231

Browse files
committed
[transformprocessor]: Remove unnecessary data copy when transform sum to/from gauge
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 91751e5 commit 0595231

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'enhancement'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: transformprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove unnecessary data copy when transform sum to/from gauge
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [35177]
14+
15+
# If your change doesn't affect end users or the exported elements of any package,
16+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
17+
# Optional: The change log or logs in which this entry should be included.
18+
# e.g. '[user]' or '[user, api]'
19+
# Include 'user' if the change is relevant to end users.
20+
# Include 'api' if there is a change to a library API.
21+
# Default: '[user]'
22+
change_logs: [user]

processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func convertGaugeToSum(stringAggTemp string, monotonic bool) (ottl.ExprFunc[ottl
5454
metric.SetEmptySum().SetAggregationTemporality(aggTemp)
5555
metric.Sum().SetIsMonotonic(monotonic)
5656

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

6060
return nil, nil
6161
}, nil

processor/transformprocessor/internal/metrics/func_convert_gauge_to_sum_datapoint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ func convertDatapointGaugeToSum(stringAggTemp string, monotonic bool) (ottl.Expr
5050
metric.SetEmptySum().SetAggregationTemporality(aggTemp)
5151
metric.Sum().SetIsMonotonic(monotonic)
5252

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

5656
return nil, nil
5757
}, nil

processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func convertSumToGauge() (ottl.ExprFunc[ottlmetric.TransformContext], error) {
3030
dps := metric.Sum().DataPoints()
3131

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

3535
return nil, nil
3636
}, nil

processor/transformprocessor/internal/metrics/func_convert_sum_to_gauge_datapoint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func convertDatapointSumToGauge() (ottl.ExprFunc[ottldatapoint.TransformContext]
2929

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

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

3535
return nil, nil
3636
}, nil

processor/transformprocessor/internal/metrics/func_extract_sum_metric.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func createExtractSumMetricFunction(_ ottl.FunctionContext, oArgs ottl.Arguments
3232
return extractSumMetric(args.Monotonic)
3333
}
3434

35-
// this interface helps unify the logic for extracting data from different histogram types
35+
// SumCountDataPoint interface helps unify the logic for extracting data from different histogram types
3636
// all supported metric types' datapoints implement it
3737
type SumCountDataPoint interface {
3838
Attributes() pcommon.Map

0 commit comments

Comments
 (0)