Switch /metrics to promhttp.Handler() for full Prometheus output#1
Merged
Conversation
Replaces the hand-rolled text formatter with client_golang's promhttp.Handler(), adding Go runtime metrics (goroutines, GC, memstats) and proper # TYPE lines for free. Custom tracker metrics are now registered via promauto package vars.
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.
Summary
promhttp.Handler()fromgithub.com/prometheus/client_golangtracker_announces_total,tracker_scrapes_total,tracker_registered_torrents,tracker_active_peers,tracker_swarms_total) now registered as typedprometheus.Counter/prometheus.Gauge/prometheus.GaugeFuncvars viapromautogo_goroutines,go_gc_*,go_memstats_*,process_cpu_seconds_total, etc.# HELPand# TYPElines (previously missing)sync/atomicfrom tracker package — counters handled by prometheus internalsTest plan
go test ./...passescurl http://localhost:8080/metricsreturns full Prometheus output with bothtracker_*andgo_*metricsTestMetricsHandlerverifies all 5 custom metrics +go_goroutinesare present🤖 Generated with Claude Code