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

feat: Populate metric unit of cpu metrics #274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

obs-gh-enricogiorio
Copy link
Collaborator

Set the unit to "CPU" when the metric name contains cpu and the unit is not already set.

Set the unit to "CPU" when the metric name contains *cpu* and the unit
is not already set.
metric_statements:
- context: metric
statements:
- set(unit, "test")
Copy link
Collaborator Author

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.

Copy link
Contributor

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

Copy link
Contributor

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")

Copy link
Collaborator Author

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!

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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

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.

2 participants