Skip to content

fix: Use compact duration format consistently across UI#3846

Merged
yurishkuro merged 1 commit into
jaegertracing:mainfrom
yurishkuro:label-precision
May 10, 2026
Merged

fix: Use compact duration format consistently across UI#3846
yurishkuro merged 1 commit into
jaegertracing:mainfrom
yurishkuro:label-precision

Conversation

@yurishkuro
Copy link
Copy Markdown
Member

Summary

Follow-up to #3844 which switched ResultItemTitle from formatDuration to formatDurationCompact. That PR's commit message claimed "the trace timeline already uses formatDurationCompact for tick labels" — but that was incorrect. This PR finishes the job.

  • Replace formatDuration with formatDurationCompact for all standalone latency displays: span bar labels, minimap tick labels, scatter plot Y-axis, trace page header duration, trace diff header and cohort table, and the span detail "Duration" field
  • Retain formatDuration only for relative offset comparisons (event timestamps, log entry relative times, span "Start Time") where seeing differences between consecutive values is meaningful
  • Add usage guidance to both formatDuration and formatDurationCompact docstrings to prevent future misuse

Rule of thumb

Use formatDurationCompact for any standalone latency number.
Use formatDuration only when the value is shown alongside other timestamps for relative comparison.

Test plan

  • npm run lint — 0 errors
  • npm test — 2821/2821 pass
  • npm run build — clean build

🤖 Generated with Claude Code

Replace formatDuration with formatDurationCompact for all standalone
latency displays: span bar labels, tick labels, scatter plot Y-axis,
trace header, trace diff header/table, and span detail duration.

Reserve formatDuration for relative offset comparisons (event timestamps,
relative start times) where sub-millisecond differences are meaningful.

Adds usage guidance to both function docstrings.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Copilot AI review requested due to automatic review settings May 10, 2026 22:33
@yurishkuro yurishkuro requested a review from a team as a code owner May 10, 2026 22:33
@yurishkuro yurishkuro added the changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements label May 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes duration/latency formatting across Jaeger UI by using formatDurationCompact for standalone duration displays (improving readability and consistency), while retaining formatDuration for relative/offset comparisons where precision differences are meaningful. It also updates docstrings to guide correct usage going forward.

Changes:

  • Switch multiple UI duration displays from formatDuration to formatDurationCompact (timeline span labels, minimap ticks, trace headers, trace diff views, scatter plot axis, span detail duration).
  • Re-export formatDurationCompact from TraceTimelineViewer utils to simplify imports.
  • Update unit tests/mocks that depended on formatDuration to align with the new formatter.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/jaeger-ui/src/utils/date.ts Adds usage guidance to duration formatting docstrings.
packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/utils.ts Re-exports formatDurationCompact for TraceTimelineViewer components.
packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/SpanDetail/index.tsx Uses compact formatting for the span “Duration” field; keeps precise formatting for “Start Time”.
packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/SpanBarRow.tsx Uses compact formatting for span bar labels.
packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/SpanBarRow.test.jsx Updates mocked formatter to formatDurationCompact.
packages/jaeger-ui/src/components/TracePage/TracePageHeader/TracePageHeader.tsx Uses compact formatting for the trace header duration display.
packages/jaeger-ui/src/components/TracePage/TracePageHeader/SpanGraph/TickLabels.tsx Uses compact formatting for minimap tick labels.
packages/jaeger-ui/src/components/TracePage/TracePageHeader/SpanGraph/TickLabels.test.jsx Updates mock and assertions to formatDurationCompact.
packages/jaeger-ui/src/components/TraceDiff/TraceDiffHeader/TraceHeader.tsx Uses compact formatting for trace diff header duration.
packages/jaeger-ui/src/components/TraceDiff/TraceDiffHeader/CohortTable.tsx Uses compact formatting for cohort table duration column.
packages/jaeger-ui/src/components/TraceDiff/TraceDiffHeader/CohortTable.test.jsx Updates spy to formatDurationCompact.
packages/jaeger-ui/src/components/SearchTracePage/SearchResults/ScatterPlot.tsx Uses compact formatting for scatter plot Y-axis tick labels.

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

Comment on lines 228 to +232
/**
* Formats a duration in microseconds to a compact string with 3 significant digits.
* Useful for displaying durations in tables where space is limited and excessive precision
* reduces readability.
* Use this for all standalone latency displays: span durations, trace durations, axis
* labels, table cells. Prefer this over `formatDuration` unless you specifically need
* the higher precision for relative offset comparisons.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.59%. Comparing base (4249bc2) to head (d159b3f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3846   +/-   ##
=======================================
  Coverage   90.59%   90.59%           
=======================================
  Files         333      333           
  Lines       10498    10498           
  Branches     2744     2742    -2     
=======================================
  Hits         9511     9511           
  Misses        860      860           
  Partials      127      127           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yurishkuro yurishkuro merged commit 8025a9d into jaegertracing:main May 10, 2026
18 of 19 checks passed
@yurishkuro yurishkuro deleted the label-precision branch May 10, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants