-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: Populate metric unit of cpu metrics #274
base: main
Are you sure you want to change the base?
Conversation
Set the unit to "CPU" when the metric name contains *cpu* and the unit is not already set.
7d0fc6d
to
8da4754
Compare
metric_statements: | ||
- context: metric | ||
statements: | ||
- set(unit, "test") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are my various attempts at making the change show up in o2. All of them have failed so far.
The docs say that I can access the "unit" field from the "metric" context, but apparently it's not the case, unless I am missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason even the metrics transform processor doesn't mention being able to modify a metric's unit. i wonder if its prohibited for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found this example
https://opentelemetry.io/blog/2023/any-metric-receiver/#fine-tuning-with-the-transform-processor
processors:
transform:
metric_statements:
- context: datapoint
statements:
- set(metric.unit, attributes["unit"])
- delete_key(attributes, "unit")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so this uses a lower level context. This will be more expensive for sure, I'll try it out. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will open an issue regarding the metric
context btw, because it explicitly says that you can access the unit, but it clearly doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait but your example also doesn't work, right? Have you tried it? I don't see any metrics showing up with the "unit" label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tried it, just found it in the opentelemetry docs
Set the unit to "CPU" when the metric name contains cpu and the unit is not already set.