Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions prometheus/testutil/promlint/promlint.go
Expand Up @@ -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",
Expand All @@ -328,8 +329,7 @@ var (
"days": "seconds",
"weeks": "seconds",
// Temperature.
"kelvin": "celsius",
"kelvins": "celsius",
"kelvins": "kelvin",
"fahrenheit": "celsius",
"rankine": "celsius",
csmarchbanks marked this conversation as resolved.
Show resolved Hide resolved
// Length.
Expand Down
22 changes: 9 additions & 13 deletions prometheus/testutil/promlint/promlint_test.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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: `
Expand All @@ -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"`,
}},
},
{
Expand Down