Repository navigation
feat(go): let callers set Prometheus histogram buckets - #286
Merged
Merged
Conversation
PrometheusBuckets(kind, bounds) replaces the bucket boundaries of one Prometheus histogram, keyed by PrometheusCollectorSchema.Kind. NewPrometheusMetrics, NewPrometheusMetricsWithBindings and PrometheusCollectorSchemas accept the options, so reuse and bindings compare the schema the options build. Construction rejects an unknown or counter kind, a repeated kind, and bounds that are empty, not finite or not increasing. Without options every schema still matches TypeScript.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #286 +/- ##
==========================================
+ Coverage 94.77% 94.79% +0.01%
==========================================
Files 84 84
Lines 13178 13199 +21
Branches 805 805
==========================================
+ Hits 12490 12512 +22
+ Misses 622 621 -1
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lan17
marked this pull request as ready for review
November 17, 2026 08:40
lan17
added a commit
that referenced
this pull request
Nov 17, 2026
Resolve the ledger conflicts with the Prometheus bucket option (#286): take main's source-audit.json and go-parity.json, apply the expected error mapping again, and refresh both in the catalog README's order.
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.
Problem
Each Go Prometheus timer histogram exports 15 series per label set: 12 fixed boundaries,
+Inf,_sumand_count. A backend that bills each bucket series, such as Datadog, charges for all of them, and a caller cannot change the boundaries. The maintainer reported this while he onboarded a Go service that exports through its own registry. In that service a remote get takes about 2 ms, the read budget is 50 ms and the write budget is 250 ms, so thegetbuckets above 50 ms are almost always empty. Refs #285 for the TypeScript and Rust adapters.Change
Public API, Go only.
PrometheusBuckets(kind, bounds)returns aPrometheusOptionthat replaces the finite boundaries of one histogram.kindis the existingPrometheusCollectorSchema.Kind, such asget,fallback,serializationorcompressionDuration.NewPrometheusMetrics,NewPrometheusMetricsWithBindingsandPrometheusCollectorSchemastake the options as a final variadic parameter. Existing calls compile unchanged. Only code that stores one of these functions in a variable of the old function type must change.client_golangkeeps the slice it receives.TestPrometheusWireSchemaMatchesTypeScriptBindingis unchanged.docs/upgrading.mdnote, because nothing changes for existing callers.docs/observability.mdnow says that the boundaries are the defaults, and a Go note shows the option with example boundaries.go/README.mdandformal/guides/GO-PARITY.mdname the option.source-audit.jsonfor the three edited pages,feature-coverage.jsonforgo/metrics_test.goplus the newTestPrometheusBucketOptionsevidence underX01.prometheus-schema, andgo-parity.jsonforgo/metrics_prometheus.gowith the two new symbols and the mapping rationale. They were refreshed in the order offormal/catalogs/README.md.Ports
Validation
Head:
601add9make check-go(go vet, gofmt and race tests with coverage) at601add9: passed.go -C go test -race -count=1 -run Prometheus ./at601add9: passed, 5 tests including the newTestPrometheusBucketOptions.make auditat601add9: passed.corepack pnpm docs:checkandmake docsat601add9: passed.601add9: every check passed, includingtest,go,typescript,rust,python,wire,quint,differential (1)to(4),Build documentationandValidate PR title.formal-full.yamlinreplaymode, run 44025119619, at601add9: success (symbolic, generate, and TypeScript, Go, Rust and Python parity).Not run: the mutation lanes, because the mutant rule does not fire (no catalog entry names a changed file). Locally,
make integration-goandmake integration-wireneed Docker.check-ts,check-rustandcheck-pythonwere not run locally, because those ports are unchanged. CI ran all of them.Follow-ups