Skip to content

Record native histogram durations as milliseconds - #283

Merged
rluong003 merged 1 commit into
masterfrom
richard.luong/tally-native-histogram-milliseconds
Sep 22, 2026
Merged

rluong003 merged 1 commit into
masterfrom
richard.luong/tally-native-histogram-milliseconds

Conversation

@rluong003

@rluong003 rluong003 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

NativeDurationHistogram recorded seconds, matching DurationBuckets.AsValues(). It should record milliseconds, so a native histogram lines up with the timer it replaces rather than sitting 1000x away from it.

Verification

go build ./..., go test ./..., go vet . and gofmt all clean. Reverting the one line to value.Seconds() fails 12 assertions across 5 tests, so the unit is genuinely pinned.

@CLAassistant

CLAassistant commented Sep 17, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

NativeDurationHistogram recorded seconds, chosen to match
DurationBuckets.AsValues(). That alignment does not survive contact with
how a native histogram is actually reported.

Every other duration path in tally hands the reporter a time.Duration and
lets it pick the unit: the statsd reporter emits milliseconds, the
prometheus reporter seconds, the m3 reporter raw nanoseconds. A native
histogram cannot work that way. record() feeds the value into the sketch
on the way in, so the reporter receives an opaque pre-bucketed payload
with no unit metadata and no opportunity to convert -- and 1000x is not a
power-of-two shift, so a base-2 exponential histogram cannot be rescaled
after the fact either.

The unit therefore has to be fixed at the API rather than deferred, and
milliseconds is the conventional choice for latency instrumentation.
A backend deriving its own histograms from tally timers in milliseconds
now agrees with these rather than sitting 1000x away from them, silently.

The divergence from DurationBuckets is deliberate, documented on both the
interface and the method, and pinned by a test so it cannot be quietly
"corrected" back into alignment.

No v7 tag has been published, so this changes no released behaviour.
@rluong003
rluong003 force-pushed the richard.luong/tally-native-histogram-milliseconds branch from d0193de to 7b2fd43 Compare September 17, 2026 18:54
@rluong003
rluong003 marked this pull request as ready for review September 17, 2026 19:45
@rluong003
rluong003 merged commit 24fbf4b into master Sep 22, 2026
6 of 7 checks passed
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.

3 participants