Repository navigation
docs(tutorial): fix stale registry prose in instrumenting HTTP server - #3126
Open
santhiprakash wants to merge 1 commit into
Open
santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2815
Problem
Three statements in
docs/tutorials/instrumenting_http_server_in_go.mdstill 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
prometheus.MustRegisterfunction registers the pingCounter with the default registry." →promauto.With(reg).NewCounter()creates the counter and registers it withreg.promhttp.Handler()… exposes the metrics registered in the default registry." →promhttp.HandlerFor(reg, promhttp.HandlerOpts{})exposes the metrics registered inreg.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
client_golangv1.24.1: after three/pingrequests,GET /metricsreturns onlyping_request_count 3— nogo_*,promhttp_*, orprocess_*series, confirmingprometheus.NewRegistry()starts empty.make check(mdox fmt + link validation) passes.ping_metric.pngand theHelpstring it renders are left unchanged so the text and image stay in sync.Notes / Risks
go_*/promhttp_*series visible inping_metric.pngpredate 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.