fix(metrics): register prometheus histograms - #506
Open
ffelipelimao wants to merge 1 commit into
Open
ffelipelimao wants to merge 1 commit into
ffelipelimao wants to merge 1 commit into
Conversation
Histogram vectors were created and stored in histogramReportersMap but never appended to the collectors passed to prometheus.MustRegister, so ReportHistogram observed into unregistered collectors and neither the custom histograms nor the built-in channel_capacity ever showed up on /metrics. Register the histogram map alongside counters, gauges and summaries. The unused response_time_ns histogram is removed: nothing calls ReportHistogram(ResponseTime), and once registered it would collide with the summary of the same fully-qualified name and panic on startup. Closes #504 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Coverage Report for CI Build 34607495191Coverage increased (+2.8%) to 61.268%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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
PrometheusReporterbuilds everyHistogramVec(custommetrics.custom.histogramsand the built-inchannel_capacity) and stores it inhistogramReportersMap, but the finalregisterMetricsloop only hands counters, gauges and summaries toprometheus.MustRegister.ReportHistogramtherefore returnsnilwhile observing into collectors no registry knows about, and the series never appear on/metrics. Reported in #504.This registers the histogram map along with the other collectors and adds the first test for the Prometheus reporter.
Key Changes
pkg/metrics/prometheus_reporter.go: appendhistogramReportersMapto the collectors passed toprometheus.MustRegister.response_time_nshistogram. Nothing callsReportHistogram(ResponseTime)(report.goandagent.gouse the summary /ChannelCapacity), and once registered it would collide with theresponse_time_nssummary: same fully-qualified name and const labels, whichRegistry.Registerrejects, soMustRegisterwould panic on startup for everyone withmetrics.prometheus.enabled. A histogram variant of response time is still possible later under a distinct name.pkg/metrics/prometheus_reporter_test.go: builds the reporter with a custom histogram spec, reports one sample to it and tochannel_capacity, and asserts both families are gathered asHISTOGRAMwith sample count 1. Fails onmainwithpitaya_custom_custom_histogram is not registered.go.mod:prometheus/client_modelmoves from indirect to direct (imported by the test fordto.MetricType).How to Test
go test ./pkg/metrics/ -run TestPrometheusReporterRegistersHistogramsManual check: enable
metrics.prometheus, declare a histogram undermetrics.custom.histograms, callReportHistogram, and curl/metrics. Before this change only summaries/counters/gauges show up; after it the_bucket,_sumand_countseries for the custom histogram and forpitaya_channel_channel_capacityare present.Closes #504
🤖 Generated with Claude Code