#61 Document histogram bucket bounds for the duration instrument - #62
Merged
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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 onNatsCacheTelemetryNames.OperationDurationInstrumentNamepointing consumers toAddViewconfiguration.
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.
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.
Closes #61.
nats.cache.operation.durationrecords 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.
ExplicitBucketHistogramConfigurationView covering ~1ms–5s, andBase2ExponentialBucketHistogramConfigurationas the no-tuning alternative (with the caveat that it needs a pipeline carrying exponential histograms end to end, so thele-based queries below it assume explicit bounds).NatsCacheTelemetryNames.OperationDurationInstrumentName, which is the name a consumer passes toAddView.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