From 3afa5ab1e1ff72930328750c5b7feb10b42cc8da Mon Sep 17 00:00:00 2001 From: Matt Layher Date: Thu, 28 May 2020 11:05:16 -0400 Subject: [PATCH] testutil/promlint: allow Kelvin as a base unit for color temperature Signed-off-by: Matt Layher --- prometheus/testutil/promlint/promlint.go | 6 ++--- prometheus/testutil/promlint/promlint_test.go | 22 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/prometheus/testutil/promlint/promlint.go b/prometheus/testutil/promlint/promlint.go index e48e4d453..ec8061706 100644 --- a/prometheus/testutil/promlint/promlint.go +++ b/prometheus/testutil/promlint/promlint.go @@ -313,9 +313,10 @@ var ( // Base units. "amperes": "amperes", "bytes": "bytes", - "celsius": "celsius", // Celsius is more common in practice than Kelvin. + "celsius": "celsius", // Also allow Celsius because it is common in typical Prometheus use cases. "grams": "grams", "joules": "joules", + "kelvin": "kelvin", // SI base unit, used in special cases (e.g. color temperature, scientific measurements). "meters": "meters", // Both American and international spelling permitted. "metres": "metres", "seconds": "seconds", @@ -328,8 +329,7 @@ var ( "days": "seconds", "weeks": "seconds", // Temperature. - "kelvin": "celsius", - "kelvins": "celsius", + "kelvins": "kelvin", "fahrenheit": "celsius", "rankine": "celsius", // Length. diff --git a/prometheus/testutil/promlint/promlint_test.go b/prometheus/testutil/promlint/promlint_test.go index c2d9980c4..f545322c6 100644 --- a/prometheus/testutil/promlint/promlint_test.go +++ b/prometheus/testutil/promlint/promlint_test.go @@ -164,6 +164,14 @@ x_seconds 10 # HELP x_joules Test metric. # TYPE x_joules untyped x_joules 10 +`, + }, + { + name: "kelvin", + in: ` +# HELP x_kelvin Test metric. +# TYPE x_kelvin untyped +x_kelvin 10 `, }, // bad cases. @@ -287,18 +295,6 @@ x_days 10 Text: `use base unit "seconds" instead of "days"`, }}, }, - { - name: "kelvin", - in: ` -# HELP x_kelvin Test metric. -# TYPE x_kelvin untyped -x_kelvin 10 -`, - problems: []promlint.Problem{{ - Metric: "x_kelvin", - Text: `use base unit "celsius" instead of "kelvin"`, - }}, - }, { name: "kelvins", in: ` @@ -308,7 +304,7 @@ x_kelvins 10 `, problems: []promlint.Problem{{ Metric: "x_kelvins", - Text: `use base unit "celsius" instead of "kelvins"`, + Text: `use base unit "kelvin" instead of "kelvins"`, }}, }, {