Skip to content

#61 Document histogram bucket bounds for the duration instrument - #62

Merged
matthewdevenny merged 1 commit into
mainfrom
matt/61-histogram-buckets
Jul 31, 2026
Merged

matthewdevenny merged 1 commit into
mainfrom
matt/61-histogram-buckets

Conversation

@matthewdevenny

Copy link
Copy Markdown
Contributor

Closes #61.

nats.cache.operation.duration records seconds — the right OTel convention — but OpenTelemetry's default explicit bucket bounds (0, 5, 10, 25, … 10000) are millisecond-shaped. Left at the default, every realistic cache operation falls into the single (0, 5] bucket, and the README's own p99 example returns ~4.95s by interpolating inside it, three orders of magnitude off a real ~4ms latency.

Documentation-only; the package still takes no OpenTelemetry dependency and the View belongs in the consumer's registration.

  • New Histogram buckets section ahead of the example queries: what goes wrong, an ExplicitBucketHistogramConfiguration View covering ~1ms–5s, and Base2ExponentialBucketHistogramConfiguration as the no-tuning alternative (with the caveat that it needs a pipeline carrying exponential histograms end to end, so the le-based queries below it assume explicit bounds).
  • The p99 query now states the precondition inline, since that snippet gets copied on its own.
  • Matching remark on NatsCacheTelemetryNames.OperationDurationInstrumentName, which is the name a consumer passes to AddView.

Also noted that sum/count-derived figures — hit ratio, operation rate, mean latency — are unaffected, so the existing hit-ratio query needs no bucket configuration.

🤖 Generated with Claude Code

The duration histogram records seconds, but OpenTelemetry's default explicit
bucket bounds are millisecond-shaped, so every cache operation lands in the
single (0, 5] bucket and the README's p99 example returns ~4.95s regardless of
actual latency. Add a "Histogram buckets" section covering both the explicit
bounds View and base-2 exponential aggregation, flag the precondition on the
p99 query itself, and note it on the instrument-name constant.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Matthew DeVenny <matt@codecargo.com>
Copilot AI review requested due to automatic review settings July 31, 2026 21:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the project documentation to prevent misleading latency quantiles for the nats.cache.operation.duration seconds-unit histogram by explaining why OpenTelemetry’s default explicit bucket bounds are inappropriate and showing consumer-side View configurations.

Changes:

  • Adds a new README “Histogram buckets” section explaining the default-bounds pitfall and providing explicit-bounds and base-2 exponential View examples.
  • Updates the README p99 PromQL snippet to state the explicit-bounds precondition inline.
  • Adds an XML-doc <remarks> note on NatsCacheTelemetryNames.OperationDurationInstrumentName pointing consumers to AddView configuration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/NatsDistributedCache/NatsCacheTelemetryNames.cs Documents the histogram bucket-bound requirement directly on the instrument name constant for consumers configuring Views.
README.md Adds a histogram bucket-configuration section and clarifies the p99 query’s prerequisite to avoid misleading quantile results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@matthewdevenny
matthewdevenny merged commit 77bf29e into main Jul 31, 2026
3 checks passed
@matthewdevenny
matthewdevenny deleted the matt/61-histogram-buckets branch July 31, 2026 21:53
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.

README p99 example is misleading: a seconds-unit histogram needs explicit bucket bounds

2 participants