testutil/promlint: allow Kelvin as a base unit for color temperature

Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
Matt Layher 2020-05-28 11:05:16 -04:00
parent 3bb96180b6
commit 3afa5ab1e1
No known key found for this signature in database
GPG Key ID: 77BFE531397EDE94
2 changed files with 12 additions and 16 deletions

View File

@ -313,9 +313,10 @@ var (
// Base units. // Base units.
"amperes": "amperes", "amperes": "amperes",
"bytes": "bytes", "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", "grams": "grams",
"joules": "joules", "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. "meters": "meters", // Both American and international spelling permitted.
"metres": "metres", "metres": "metres",
"seconds": "seconds", "seconds": "seconds",
@ -328,8 +329,7 @@ var (
"days": "seconds", "days": "seconds",
"weeks": "seconds", "weeks": "seconds",
// Temperature. // Temperature.
"kelvin": "celsius", "kelvins": "kelvin",
"kelvins": "celsius",
"fahrenheit": "celsius", "fahrenheit": "celsius",
"rankine": "celsius", "rankine": "celsius",
// Length. // Length.

View File

@ -164,6 +164,14 @@ x_seconds 10
# HELP x_joules Test metric. # HELP x_joules Test metric.
# TYPE x_joules untyped # TYPE x_joules untyped
x_joules 10 x_joules 10
`,
},
{
name: "kelvin",
in: `
# HELP x_kelvin Test metric.
# TYPE x_kelvin untyped
x_kelvin 10
`, `,
}, },
// bad cases. // bad cases.
@ -287,18 +295,6 @@ x_days 10
Text: `use base unit "seconds" instead of "days"`, 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", name: "kelvins",
in: ` in: `
@ -308,7 +304,7 @@ x_kelvins 10
`, `,
problems: []promlint.Problem{{ problems: []promlint.Problem{{
Metric: "x_kelvins", Metric: "x_kelvins",
Text: `use base unit "celsius" instead of "kelvins"`, Text: `use base unit "kelvin" instead of "kelvins"`,
}}, }},
}, },
{ {