Skip to content

Feat/metrics doc generator v3 - #1

Open
ivankatliarchuk wants to merge 2 commits into
masterfrom
feat/metrics-doc-generator-v3
Open

Feat/metrics doc generator v3#1
ivankatliarchuk wants to merge 2 commits into
masterfrom
feat/metrics-doc-generator-v3

Conversation

@ivankatliarchuk

@ivankatliarchuk ivankatliarchuk commented Apr 1, 2026

Copy link
Copy Markdown
Member

Why: The v1 generator required manually seeding GaugeVec label values before Gather() to make them visible, and relied on a static MetricRegistry for shared/conditional
metrics. This approach breaks silently when label names change — the docs drift without any signal.

What:

Change all prober function signatures from *prometheus.Registry → prometheus.Registerer (non-breaking, callers unchanged)
Add internal/gen/docs/metrics_v3/ with a capturingRegistry that intercepts every MustRegister call and invokes Describe() on the collector — extracting label names
without needing observed values
GaugeVec labels (e.g. probe_grpc_healthcheck_response.serving_status, probe_websocket_duration_seconds.phase) now come directly from code, not manual declarations
Conditional metrics that only register on live code paths (TLS, CEL, SOA, ICMP reply) still fall back to prober.MetricRegistry
Golden-file test in main_test.go fails when any metric name, type, labels, or help text changes — making docs drift visible in CI

Branch: feat/metrics-doc-generator-v3

Title: feat: add capturingRegistry metrics doc generator with golden-file test

Why: The v1 generator required manually seeding GaugeVec label values before Gather() to make them visible, and relied on a static MetricRegistry for shared/conditional
metrics. This approach breaks silently when label names change — the docs drift without any signal.

What:

  • Change all prober function signatures from *prometheus.Registry → prometheus.Registerer (non-breaking, callers unchanged)
  • Add internal/gen/docs/metrics_v3/ with a capturingRegistry that intercepts every MustRegister call and invokes Describe() on the collector — extracting label names
    without needing observed values
  • GaugeVec labels (e.g. probe_grpc_healthcheck_response.serving_status, probe_websocket_duration_seconds.phase) now come directly from code, not manual declarations
  • Conditional metrics that only register on live code paths (TLS, CEL, SOA, ICMP reply) still fall back to prober.MetricRegistry
  • Golden-file test in main_test.go fails when any metric name, type, labels, or help text changes — making docs drift visible in CI

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant