diff --git a/.github/scripts/otel-naming/check_otel_naming.py b/.github/scripts/otel-naming/check_otel_naming.py index aeaa7e003c..43746d5692 100644 --- a/.github/scripts/otel-naming/check_otel_naming.py +++ b/.github/scripts/otel-naming/check_otel_naming.py @@ -699,6 +699,7 @@ def run_rule_d_dashboards(root: Path, l1_keys: Set[str], report: Report) -> None report.skip("D", "no L1 key set to validate against") return builtins = { + "__name__", # Prometheus reserved label for the metric name itself "le", "exported_instance", "span_name", diff --git a/.github/scripts/otel-naming/test_check_otel_naming.py b/.github/scripts/otel-naming/test_check_otel_naming.py index e2e9e1fe88..8254993e7e 100644 --- a/.github/scripts/otel-naming/test_check_otel_naming.py +++ b/.github/scripts/otel-naming/test_check_otel_naming.py @@ -502,6 +502,14 @@ class RuleDDashboards(unittest.TestCase): [], ) + def test_prometheus_name_label_not_flagged(self): + # `__name__` is the Prometheus reserved metric-name label; the renamed + # system-*.json dashboards use `sum by (le, __name__)`. + self.assertEqual( + self._run('"expr": "sum by (le, __name__) (rate(x[5m]))"', set()), + [], + ) + def test_l1_label_passes(self): self.assertEqual(self._run('"q": "{command=\\"x\\"}"', {"command"}), [])