feat(metrics): Add native histograms and Prometheus protobuf exposition - #856
Open
ethanolchik wants to merge 1 commit into
Open
feat(metrics): Add native histograms and Prometheus protobuf exposition#856ethanolchik wants to merge 1 commit into
ethanolchik wants to merge 1 commit into
Conversation
Extend Histogram with opt-in exponential native buckets, exemplars, and resolution reduction. Preserve native snapshots through registry, worker, and cluster aggregation. Add protobuf exposition for all existing metric types, binary registry return types, schema generation, documentation, and an HTTP example. Fixes prometheus#576 Assisted-by: Codex Signed-off-by: Ethan Olchik <eolchik@cloudflare.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.
Applications currently cannot expose native histogram samples from this client. This adds opt-in native collection to
Histogramand the Prometheus protobuf exposition needed to scrape it.Fixes #576.
Existing histogram configurations retain classic behavior. Native histograms can retain explicit classic buckets for migration, or use
buckets: []for native-only protobuf output. Protobuf registry methods return aBuffer, represented asUint8Arrayin the public TypeScript declarations.The implementation includes:
sum,first, andomitaggregation through registries, clusters, and workers, including reconciliation of different schemas and zero thresholds.protobufjs/lightuses the checked-inlib/metrics.jsondescriptor;lib/metrics.protoandnpm run generate-protobufmake its source and regeneration available.Validation performed locally:
checkworkflow passed throughacton Node 24.21.0: ESLint, Prettier, and TypeScript.npm run benchmarkscompleted on macOS/Node 26.4.0. A focused registry comparison against upstream, with increased sampling, found no significant regression above a 5% threshold; default-label cases measured roughly 2–4% overhead.The existing benchmark suite covers classic metrics. Dedicated native workload benchmarks and application-specific rollout validation remain follow-up work. Applications select the protobuf response format themselves; HTTP Accept negotiation is outside this change.
Developed with AI assistance (Codex), also disclosed in the commit trailer.