Skip to content
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

[transformprocessor]: Remove unnecessary data copy when transform sum to/from gauge #35177

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .chloggen/rm-copy-transformprocessor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'enhancement'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: transformprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove unnecessary data copy when transform sum to/from gauge

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [35177]

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
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
Loading