Skip to content

Commit 3afa5ab

Browse files
committed
testutil/promlint: allow Kelvin as a base unit for color temperature
Signed-off-by: Matt Layher <[email protected]>
1 parent 3bb9618 commit 3afa5ab

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

prometheus/testutil/promlint/promlint.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,10 @@ var (
313313
// Base units.
314314
"amperes": "amperes",
315315
"bytes": "bytes",
316-
"celsius": "celsius", // Celsius is more common in practice than Kelvin.
316+
"celsius": "celsius", // Also allow Celsius because it is common in typical Prometheus use cases.
317317
"grams": "grams",
318318
"joules": "joules",
319+
"kelvin": "kelvin", // SI base unit, used in special cases (e.g. color temperature, scientific measurements).
319320
"meters": "meters", // Both American and international spelling permitted.
320321
"metres": "metres",
321322
"seconds": "seconds",
@@ -328,8 +329,7 @@ var (
328329
"days": "seconds",
329330
"weeks": "seconds",
330331
// Temperature.
331-
"kelvin": "celsius",
332-
"kelvins": "celsius",
332+
"kelvins": "kelvin",
333333
"fahrenheit": "celsius",
334334
"rankine": "celsius",
335335
// Length.

prometheus/testutil/promlint/promlint_test.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ x_seconds 10
164164
# HELP x_joules Test metric.
165165
# TYPE x_joules untyped
166166
x_joules 10
167+
`,
168+
},
169+
{
170+
name: "kelvin",
171+
in: `
172+
# HELP x_kelvin Test metric.
173+
# TYPE x_kelvin untyped
174+
x_kelvin 10
167175
`,
168176
},
169177
// bad cases.
@@ -287,18 +295,6 @@ x_days 10
287295
Text: `use base unit "seconds" instead of "days"`,
288296
}},
289297
},
290-
{
291-
name: "kelvin",
292-
in: `
293-
# HELP x_kelvin Test metric.
294-
# TYPE x_kelvin untyped
295-
x_kelvin 10
296-
`,
297-
problems: []promlint.Problem{{
298-
Metric: "x_kelvin",
299-
Text: `use base unit "celsius" instead of "kelvin"`,
300-
}},
301-
},
302298
{
303299
name: "kelvins",
304300
in: `
@@ -308,7 +304,7 @@ x_kelvins 10
308304
`,
309305
problems: []promlint.Problem{{
310306
Metric: "x_kelvins",
311-
Text: `use base unit "celsius" instead of "kelvins"`,
307+
Text: `use base unit "kelvin" instead of "kelvins"`,
312308
}},
313309
},
314310
{

0 commit comments

Comments
 (0)