Skip to content

Add unit suffixes to prometheus metric names#3352

Merged
Aneurysm9 merged 3 commits into
open-telemetry:mainfrom
dashpole:unit_in_name
Oct 19, 2022
Merged

Add unit suffixes to prometheus metric names#3352
Aneurysm9 merged 3 commits into
open-telemetry:mainfrom
dashpole:unit_in_name

Conversation

@dashpole
Copy link
Copy Markdown
Collaborator

@dashpole dashpole commented Oct 18, 2022

Fixes #3288

This adds a new option, WithoutUnits() that disables this behavior for all metrics, and maintains the status quo.

I've opted to only rename units we explicitly support in our units package, rather than a more complete set like the collector does. I've also opted not to try and convert milliseconds to seconds, as the conversion (dividing by 1000) won't be straightforward with exponential histograms.

Open Question: Is 1 only applicable to ratios and fractions, or does it apply to any unitless metric? I was told that it only applies to ratios and fractions in the collector version of this. The spec says:

Instruments for utilization metrics (that measure the fraction out of a total) are dimensionless and SHOULD use the default unit 1 (the unity).
Instruments that measure an integer count of something SHOULD only use annotations with curly braces to give additional meaning without the leading default unit (1). For example, use {packets}, {errors}, {faults}, etc.

But I can't tell if there are metrics which don't fall into either category and can use 1 without being a ratio.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 18, 2022

Codecov Report

Merging #3352 (a7c8fee) into main (1d9d4b2) will decrease coverage by 0.0%.
The diff coverage is 80.7%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #3352     +/-   ##
=======================================
- Coverage   77.9%   77.9%   -0.1%     
=======================================
  Files        164     164             
  Lines      11348   11363     +15     
=======================================
+ Hits        8850    8861     +11     
- Misses      2301    2305      +4     
  Partials     197     197             
Impacted Files Coverage Δ
exporters/prometheus/exporter.go 84.0% <76.1%> (+0.7%) ⬆️
exporters/prometheus/config.go 100.0% <100.0%> (ø)
sdk/trace/batch_span_processor.go 81.1% <0.0%> (-0.9%) ⬇️
exporters/jaeger/jaeger.go 90.3% <0.0%> (-0.9%) ⬇️

Comment thread CHANGELOG.md Outdated
Comment thread exporters/prometheus/exporter.go Outdated
Comment thread exporters/prometheus/config.go
@dashpole dashpole force-pushed the unit_in_name branch 2 times, most recently from ba437f1 to 68a17ab Compare October 19, 2022 18:24
dashpole and others added 3 commits October 19, 2022 18:29
Comment thread CHANGELOG.md
@MrAlias MrAlias added this to the Metric v0.33.0 milestone Oct 19, 2022
@Aneurysm9 Aneurysm9 merged commit 510910e into open-telemetry:main Oct 19, 2022
@dashpole dashpole deleted the unit_in_name branch October 19, 2022 19:28
@MrAlias MrAlias mentioned this pull request Oct 19, 2022
@ttys3
Copy link
Copy Markdown

ttys3 commented May 24, 2023

using _ratio is really bad if you use an promethus exporter

requests_total will become: requests_ratio_total Omz

@MrAlias MrAlias added the area:metrics Part of OpenTelemetry Metrics label Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:metrics Part of OpenTelemetry Metrics pkg:exporter:prometheus Related to the Prometheus exporter package

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Prometheus exporter metric names should include unit suffixes.

5 participants