Skip to content

feat(metrics): Add explicitly sharded histograms - #311

Open
nox wants to merge 1 commit into
cloudflare:mainfrom
nox:split-histogram
Open

nox wants to merge 1 commit into
cloudflare:mainfrom
nox:split-histogram

Conversation

@nox

@nox nox commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

SplitHistogram collects explicitly registered SplitHistogramShard handles into one standard classic histogram. Each shard records through relaxed atomics without taking a parent-wide observation lock, while the parent retains ownership for collection.

The implementation reuses HistogramSnapshot and the existing histogram encoding path, preserving text and protobuf rendering. Shard placement remains caller-controlled, including the documented option of caller-managed thread-local storage.

Both types are exported from foundations-metrics and the backend-gated foundations facade.

Exemplar support remains deferred because sharing exemplar storage across explicit shards requires additional ownership and conflict semantics.

`SplitHistogram` collects explicitly registered `SplitHistogramShard`
handles into a standard classic histogram while observations use
per-shard relaxed atomics. The parent retains shard ownership, and cloned
shard handles share their underlying counters.

The implementation reuses `HistogramSnapshot` and the existing histogram
encoder, preserving standard text and protobuf rendering. Caller-managed
thread-local storage is documented without adding TLS policy to the
metrics backend.

Both types are available from `foundations-metrics` and its backend-gated
`foundations` facade.

Exemplar support remains deferred because sharing exemplar storage across
explicit shards requires additional ownership and conflict semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant