[processor/metricstransformprocessor] Add operation for conversion of camel case metric names to snake case #15379
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.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.