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

[processor/metricstransformprocessor] Add operation for conversion of camel case metric names to snake case #15379

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Change from configAction to operationAction
Signed-off-by: John Clark <[email protected]>
  • Loading branch information
clarkjohnd committed Oct 21, 2022
commit b6d719c7cd328514691d7b10dbba6c0e1f07be77
9 changes: 5 additions & 4 deletions processor/metricstransformprocessor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,9 @@ const (

// Group groups mutiple metrics matching the predicate into multiple ResourceMetrics messages
Group ConfigAction = "group"

CaseConvert ConfigAction = "case_convert"
)

var actions = []ConfigAction{Insert, Update, Combine, Group, CaseConvert}
var actions = []ConfigAction{Insert, Update, Combine, Group}

func (ca ConfigAction) isValid() bool {
for _, configAction := range actions {
Expand Down Expand Up @@ -220,9 +218,12 @@ const (
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
// otherwise the operation will be ignored.
AggregateLabelValues OperationAction = "aggregate_label_values"

// CaseConvert changes camel case metrics to snake case metrics
CaseConvert OperationAction = "case_convert"
)

var operationActions = []OperationAction{AddLabel, UpdateLabel, DeleteLabelValue, ToggleScalarDataType, ScaleValue, AggregateLabels, AggregateLabelValues}
var operationActions = []OperationAction{AddLabel, UpdateLabel, DeleteLabelValue, ToggleScalarDataType, ScaleValue, AggregateLabels, AggregateLabelValues, CaseConvert}

func (oa OperationAction) isValid() bool {
for _, operationAction := range operationActions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,6 @@ func (mtp *metricsTransformProcessor) processMetrics(_ context.Context, md pmetr
// Drop the metric if all the data points were dropped after transformations.
return !transformMetric(metric, transform)
})
case CaseConvert:
mLen := metrics.Len()
for i := 0; i < mLen; i++ {
metric := metrics.At(i)
ToSnakeCase(metric)
}
}

}
Expand Down Expand Up @@ -572,6 +566,10 @@ func transformMetric(metric pmetric.Metric, transform internalTransform) bool {
if canChangeMetric {
deleteLabelValueOp(metric, op)
}
case CaseConvert:
if canChangeMetric {
ToSnakeCase(metric)
}
}
}

Expand Down