Skip to content

docs(tutorial): fix stale registry prose in instrumenting HTTP server - #3126

Open
santhiprakash wants to merge 1 commit into
prometheus:mainfrom
santhiprakash:fix-2815-tutorial-instrumenting-server
Open

santhiprakash wants to merge 1 commit into
prometheus:mainfrom
santhiprakash:fix-2815-tutorial-instrumenting-server

Conversation

@santhiprakash

Copy link
Copy Markdown
Contributor

Fixes #2815

Problem

Three statements in docs/tutorials/instrumenting_http_server_in_go.md still describe the pre-292bc326 version of the sample, which used the default registry. The sample code in the same file now builds a custom registry (prometheus.NewRegistry() + promauto.With(reg) + promhttp.HandlerFor(reg, …)), so the prose contradicts the code it explains.

Fix

  • "The prometheus.MustRegister function registers the pingCounter with the default registry." → promauto.With(reg).NewCounter() creates the counter and registers it with reg.
  • "promhttp.Handler() … exposes the metrics registered in the default registry." → promhttp.HandlerFor(reg, promhttp.HandlerOpts{}) exposes the metrics registered in reg.
  • "The default registry comes with a collector for Go runtime metrics…" → the custom registry does not include Go runtime metrics by default; to collect them, register collectors.NewGoCollector() with the registry (the non-deprecated API, per @jan--f's review on docs: fix stale explanation in instrumenting HTTP server tutorial #3074).

Verification

  • Ran the tutorial's exact sample code against client_golang v1.24.1: after three /ping requests, GET /metrics returns only ping_request_count 3 — no go_*, promhttp_*, or process_* series, confirming prometheus.NewRegistry() starts empty.
  • make check (mdox fmt + link validation) passes.
  • The diff is limited to the three sentences; ping_metric.png and the Help string it renders are left unchanged so the text and image stay in sync.

Notes / Risks

  • Docs-only change.
  • The go_*/promhttp_* series visible in ping_metric.png predate the custom-registry switch; happy to regenerate the screenshot in a follow-up if you'd like it to match the current sample.

Assistance

AI-assisted. I wrote and verified this change.

Problem: three sentences in the instrumenting HTTP server tutorial still
describe the pre-292bc326 sample that used the default registry, while the
code now builds a custom registry (prometheus.NewRegistry() +
promauto.With(reg) + promhttp.HandlerFor).

Fix: rewrite the three sentences to match the shipped sample code, and use
collectors.NewGoCollector() (non-deprecated) for the Go-collector hint, per
jan--f's review on prometheus#3074.

Verification: ran the tutorial's sample code with client_golang v1.24.1;
/metrics emits only ping_request_count (no go_*/promhttp_* series). make
check passes.

Fixes prometheus#2815

Signed-off-by: Santhi Prakash <b.santhiprakash@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.

Fix errors in tutorial/instrumenting HTTP server

1 participant