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

Prometheus exporter adds underscore suffix for metrics without unit #2317

Closed
dashpole opened this issue Sep 19, 2023 · 2 comments · Fixed by #2213
Closed

Prometheus exporter adds underscore suffix for metrics without unit #2317

dashpole opened this issue Sep 19, 2023 · 2 comments · Fixed by #2213
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@dashpole
Copy link
Contributor

Steps to reproduce

If a metric does not have a unit set, the prometheus exporter will add an extra _ suffix to the metric. I have only second-hand knowledge of the issue, and don't have reproduction steps.

What is the expected behavior?

If the unit is empty, the name should not have an underscore or unit suffix added.

What is the actual behavior?

The metric grpc.client.attempt.started without a unit turns into:

# TYPE grpc_client_attempt_started_ counter
grpc_client_attempt_started_{grpc_method="grpc.testing.TestService/UnaryCall",grpc_target="dns:///10.52.1.55:14285"} 10 1694819876572

I believe this is because of this line:

metric_family.name = sanitized + "_" + unit;

We append an underscore regardless of if the unit is empty or not.

@dashpole dashpole added the bug Something isn't working label Sep 19, 2023
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 19, 2023
@yashykt
Copy link
Contributor

yashykt commented Sep 19, 2023

This was seen on gRPC C++'s OTel plugin, but the pattern of usage is nothing out of the ordinary from what I understand. Reference - https://github.com/grpc/grpc/blob/62521a889fe134859aed7bdf4ea0730534f15d09/src/cpp/ext/otel/otel_plugin.cc#L170

A Meter with the name "grpc" was created, and a counter instrument with the name "grpc.client.attempt.started" was created out of it.

The counter was incremented like so - https://github.com/grpc/grpc/blob/62521a889fe134859aed7bdf4ea0730534f15d09/src/cpp/ext/otel/otel_client_filter.cc#L122

@marcalff marcalff added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 20, 2023
punya added a commit to punya/opentelemetry-cpp that referenced this issue Sep 22, 2023
punya added a commit to punya/opentelemetry-cpp that referenced this issue Sep 22, 2023
punya added a commit to punya/opentelemetry-cpp that referenced this issue Sep 23, 2023
Copy link

This issue was marked as stale due to lack of activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
4 participants