From 6ec60ff52ce4233c8934060ee14c61e30dbba3f9 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Thu, 11 Jun 2026 18:34:19 +0100 Subject: [PATCH] ci: Add __name__ to OTel naming check Rule D builtins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rule D (dashboard PromQL labels must exist in L1) flagged `__name__` once the phase-7 system-*.json dashboards started using `sum by (le, __name__)`. `__name__` is the Prometheus reserved label for the metric name itself — a builtin, not a span attribute. Add it to the builtin allowlist and cover it with a test. (Earlier dashboards only used `__name__` inside `{__name__=~...}` matchers, which the label regex did not extract, so this surfaced only now.) Co-Authored-By: Claude Opus 4.8 --- .github/scripts/otel-naming/check_otel_naming.py | 1 + .github/scripts/otel-naming/test_check_otel_naming.py | 8 ++++++++ 2 files changed, 9 insertions(+) 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"}), [])