From 0a9cc5b513d365cd11f8382383db04f4c2733938 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Wed, 16 Aug 2023 19:03:37 +0000 Subject: [PATCH] prometheus exporter: remove non-ucum units from conversion --- .../prometheus/PrometheusUnitsHelper.java | 12 ------------ .../prometheus/PrometheusUnitsHelperTest.java | 17 +++++------------ 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelper.java b/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelper.java index b4ba94d4709..a0ca81669d9 100644 --- a/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelper.java +++ b/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelper.java @@ -154,16 +154,6 @@ private static String getPrometheusUnit(String unitAbbreviation) { return "gigabytes"; case "TBy": return "terabytes"; - case "B": - return "bytes"; - case "KB": - return "kilobytes"; - case "MB": - return "megabytes"; - case "GB": - return "gigabytes"; - case "TB": - return "terabytes"; // SI case "m": return "meters"; @@ -186,8 +176,6 @@ private static String getPrometheusUnit(String unitAbbreviation) { return ""; case "%": return "percent"; - case "$": - return "dollars"; default: return unitAbbreviation; } diff --git a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelperTest.java b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelperTest.java index a510e726215..2a8d01f0ce3 100644 --- a/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelperTest.java +++ b/exporters/prometheus/src/test/java/io/opentelemetry/exporter/prometheus/PrometheusUnitsHelperTest.java @@ -24,18 +24,13 @@ private static Stream providePrometheusOTelUnitEquivalentPairs() { return Stream.of( // Simple expansion - storage Bytes Arguments.of("By", "bytes"), - Arguments.of("B", "bytes"), - // Simple expansion - storage KB - Arguments.of("KB", "kilobytes"), + // Simple expansion - storage KBy Arguments.of("KBy", "kilobytes"), - // Simple expansion - storage MB - Arguments.of("MB", "megabytes"), + // Simple expansion - storage MBy Arguments.of("MBy", "megabytes"), - // Simple expansion - storage GB - Arguments.of("GB", "gigabytes"), + // Simple expansion - storage GBy Arguments.of("GBy", "gigabytes"), - // Simple expansion - storage TB - Arguments.of("TB", "terabytes"), + // Simple expansion - storage TBy Arguments.of("TBy", "terabytes"), // Simple expansion - storage KiBy Arguments.of("KiBy", "kibibytes"), @@ -61,8 +56,6 @@ private static Stream providePrometheusOTelUnitEquivalentPairs() { Arguments.of("min", "minutes"), // Simple expansion - special symbol - % Arguments.of("%", "percent"), - // Simple expansion - special symbols - $ - Arguments.of("$", "dollars"), // Simple expansion - frequency Arguments.of("Hz", "hertz"), // Simple expansion - temperature @@ -90,7 +83,7 @@ private static Stream providePrometheusOTelUnitEquivalentPairs() { // Units expressing rate - per month Arguments.of("J/mo", "joules_per_month"), // Units expressing rate - per year - Arguments.of("TB/y", "terabytes_per_year"), + Arguments.of("TBy/y", "terabytes_per_year"), // Units expressing rate - 'per' units, both units unknown Arguments.of("v/v", "v_per_v"), // Units expressing rate - 'per' units, first unit unknown