Skip to content

chore: Record tracing durations via a canonical Duration attribute encoding - #2544

Open
sergerad wants to merge 2 commits into
sergerad-lock-followupfrom
sergerad-duration-record
Open

chore: Record tracing durations via a canonical Duration attribute encoding#2544
sergerad wants to merge 2 commits into
sergerad-lock-followupfrom
sergerad-duration-record

Conversation

@sergerad

@sergerad sergerad commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a canonical tracing encoding for Duration values.

The tracing field registry had no RecordAttribute implementation for Duration, so every call site that records a duration hand-converted it with .as_millis() as u64 (or a saturating try_from in one place) — eight sites across five crates, with inconsistent overflow behavior between them.

This PR adds impl RecordAttribute for Duration: durations are recorded as whole milliseconds in a u64, saturating at u64::MAX. The allowed field names (retry.delay_ms, shutdown.grace_period_ms, snapshots.oldest_superseded_for_ms, timeout.ms) move from NUMBER_FIELD_NAMES onto the impl, so each registry name has exactly one canonical type. All call sites now pass the Duration directly and the manual conversions are deleted.

Note on Option<Duration>: the write-worker site records oldest_superseded_for.unwrap_or_default() rather than the Option itself, because the blanket Option<T> attribute encoding omits the field entirely on None — the field must always be present on the span.

Changelog

changelog = "none"
reason    = "Internal change only."

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