Skip to content

Commit

Permalink
Remove units from the prometheus conversion that aren't UCUM (#24647)
Browse files Browse the repository at this point in the history
**Description:**

Discovered during
open-telemetry/opentelemetry-go#4374 (review).

`B` means `bel` in UCUM, so MB is `megabel`, for example. `$` is also
not UCUM.

https://ucum.org/ucum#section-Alphabetic-Index-By-Symbol
  • Loading branch information
dashpole committed Aug 1, 2023
1 parent 74387c3 commit 6cf4dec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
20 changes: 20 additions & 0 deletions .chloggen/prometheus_translation_ucum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'breaking'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: prometheusexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove invalid unit translations from the prometheus exporters

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [24647]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
6 changes: 0 additions & 6 deletions pkg/translator/prometheus/normalize_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ var unitMap = map[string]string{
"MBy": "megabytes",
"GBy": "gigabytes",
"TBy": "terabytes",
"B": "bytes",
"KB": "kilobytes",
"MB": "megabytes",
"GB": "gigabytes",
"TB": "terabytes",

// SI
"m": "meters",
Expand All @@ -56,7 +51,6 @@ var unitMap = map[string]string{
"Hz": "hertz",
"1": "",
"%": "percent",
"$": "dollars",
}

// The map that translates the "per" unit
Expand Down
7 changes: 0 additions & 7 deletions pkg/translator/prometheus/normalize_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ func TestPercent(t *testing.T) {

}

func TestDollar(t *testing.T) {

require.Equal(t, "crypto_bitcoin_value_dollars", normalizeName(createGauge("crypto.bitcoin.value", "$"), ""))
require.Equal(t, "crypto_bitcoin_value_dollars", normalizeName(createGauge("crypto.bitcoin.value.dollars", "$"), ""))

}

func TestEmpty(t *testing.T) {

require.Equal(t, "test_metric_no_unit", normalizeName(createGauge("test.metric.no_unit", ""), ""))
Expand Down

0 comments on commit 6cf4dec

Please sign in to comment.