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

Conversation

clarkjohnd
Copy link
Contributor

Description:

Have added an operation to the metrics transform processor which allows metric names to be converted from camel case to snake case (e.g. CurrentCPUUtilization -> current_cpu_utilization) in line with common naming conventions of metrics.

# convert all camel case metric names to snake case: e.g. MyMetric -> my_metric
include: (.*)
match_type: regexp
action: update
operations:
  - action: case_convert

Other parameters in operations elements have no effect on the operation.

AWS CloudWatch Metric Streams output metrics (into OpenTelemetry Collector) with camel case names, so this feature helps to normalize the names, particularly into the same standard as Prometheus metric names. There will also be other use cases and metrics providers this may help with, but admittedly this is somewhat of a rare problem being solved.

The feature has no effect on metrics already named appropriately (current.cpu.utilization, current_cpu_utilization etc.) so using a ".*" regex include with this operation should be safe, but not sure of performance implications if any, so may be wise if using with a catch-all to use with a specific collector pipeline expecting mostly camel case metrics etc., rather than a part of a pipeline where every single metric flows through and gets analysed.

No effect on any other existing feature or implications on collectors being upgraded.

Testing:

A development docker image with this feature was built from the branch and deployed into my test environment (replacing the production OpenTelemetry Colllector currently in place) currently receiving said AWS CloudWatch metrics with include set to ".*" and once the configuration was updated as above, it immediately started converting them as expected to snake case, with no effect on other metrics that are already named appropriately.

Various test cases added to the code, including handling wildcard regex, strict include, already-snake-case, multiple uppercase characters etc. metric names.

Documentation:

README has been updated with a description of the feature and an example.

@clarkjohnd
Copy link
Contributor Author

Bumping this @dmitryax @Aneurysm9 , any feedback etc.? Thanks.

@Aneurysm9
Copy link
Member

@TylerHelmuth should this functionality be directed at the transform processor instead? I think we've anticipated that metricstransform will be replaced by transform at some point. Is it ready to start putting all new features there?

@TylerHelmuth
Copy link
Member

@Aneurysm9 yes this would be a great use case for the transform processor because it is focus on changing the metric name itself and not more complicated data transformations. The function to switch case could be implemented now and could be used within the transform processor to change metric names.

@clarkjohnd
Copy link
Contributor Author

I can look to migrate this over to transform processor instead then if we're happy with that route @TylerHelmuth @Aneurysm9

@TylerHelmuth
Copy link
Member

@clarkjohnd yes please!

@clarkjohnd
Copy link
Contributor Author

Superseded by #16070 - migrated to transform processor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants