Skip to content

feat: Support sub-second (millisecond) precision in the time picker#2353

Draft
MikeShi42 wants to merge 5 commits into
mainfrom
cursor/time-picker-ms-support-1b75
Draft

feat: Support sub-second (millisecond) precision in the time picker#2353
MikeShi42 wants to merge 5 commits into
mainfrom
cursor/time-picker-ms-support-1b75

Conversation

@MikeShi42
Copy link
Copy Markdown
Contributor

@MikeShi42 MikeShi42 commented May 28, 2026

Summary

The time picker for logs did not support sub-second date times while the logs are displayed at millisecond resolution. This PR adds millisecond (.SSS) support to the time picker, conditional on the timestamp column type — ms is only shown when the column actually supports sub-second precision (DateTime64).

Changes:

Time picker UI (packages/app)

  • Added showMs prop to TimePicker — controls placeholder (YYYY-MM-DD HH:mm:ss vs YYYY-MM-DD HH:mm:ss.SSS), value format, and handleSearch display strings
  • Added showMs param to dateRangeToString and useNewTimeQuery — conditionally formats with 'withMs' or 'normal'
  • In DBSearchPage, derives showMs by looking up the timestamp column type from useColumns metadata: DateTime64 → ms shown, DateTime → seconds only
  • Added showMs to useNewTimeQuery's useEffect dependency array so the displayed time string reformats when column metadata loads
  • Updated E2E page object locators to use regex (/^YYYY-MM-DD HH:mm:ss/) for resilience against both formats
  • Added unit tests verifying millisecond parsing in dateParser and parseTimeRangeInput

How it works

The DBSearchPage looks up the searched source's timestamp column type at runtime:

const tsCol = getFirstTimestampValueExpression(source.timestampValueExpression);
const colMeta = columns.find(c => c.name === tsCol);
const showMs = colMeta?.type?.startsWith('DateTime64') ?? true;

This flag flows into both the time picker (display/input format) and the time query hook (range string formatting). The default is true (ms shown) — the standard OTel tables use DateTime64(9).

No changes to the query layer (renderChartConfig) — ClickHouse handles implicit type promotion correctly, and the from/to URL params already carry epoch milliseconds via Date.getTime().

Screenshots or video

Time picker with millisecond placeholder
Time picker showing applied range with milliseconds
Full second range showing all 8 test results
Filtered to .509ms showing only 4 results
ms_filtering_verification.mp4

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Click on the time picker input at the top of the Search page
  2. Verify the Start time and End time inputs show placeholder "YYYY-MM-DD HH:mm:ss.SSS" (default OTel source uses DateTime64)
  3. Type "2024-06-15 10:30:45.123" in the Start time input and press Enter
  4. Type "2024-06-15 11:30:45.456" in the End time input and press Enter
  5. Click the "Apply" button
  6. Verify the time picker input displays "Jun 15 10:30:45.123 - Jun 15 11:30:45.456" with milliseconds preserved

References

  • Linear Issue: HDX-2133
  • Related PRs: None

To show artifacts inline, enable in settings.

Linear Issue: HDX-2133

Open in Web Open in Cursor 

- Update DateInput format to YYYY-MM-DD HH:mm:ss.SSS
- Include .SSS in handleSearch format strings for both 12h/24h modes
- Switch dateRangeToString to use 'withMs' format for sub-second precision
- Update E2E page object placeholder to match new format
- Add unit tests for millisecond parsing in dateParser and parseTimeRangeInput

Resolves HDX-2133

Co-authored-by: Mike Shi <mike@hyperdx.io>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

⚠️ No Changeset found

Latest commit: 8e27937

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment May 30, 2026 1:59am
hyperdx-storybook Error Error May 30, 2026 1:59am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

E2E Test Results

All tests passed • 188 passed • 3 skipped • 1266s

Status Count
✅ Passed 188
❌ Failed 0
⚠️ Flaky 7
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

The DateInput now displays values with .SSS suffix (e.g., '14:37:42.000')
due to the updated valueFormat. Update E2E assertions to expect the
millisecond-formatted output.

Co-authored-by: Mike Shi <mike@hyperdx.io>
For DateTime (second-precision) columns, wrap time filter boundaries with
toDateTime() to truncate sub-second values. This matches the existing
toDate() pattern for Date columns and ensures the filter precision
matches the column's storage precision.

- DateTime64 columns: ms-level filtering via fromUnixTimestamp64Milli()
- DateTime columns: second-level filtering via toDateTime(fromUnixTimestamp64Milli())
- Date columns: day-level filtering via toDate(fromUnixTimestamp64Milli())

Updated test mocks to use DateTime64(9) for timestamp columns (matching
real OTel table schemas) and added explicit test cases for DateTime
column behavior.

Co-authored-by: Mike Shi <mike@hyperdx.io>
Only show millisecond precision in the time picker when the timestamp
column is DateTime64 (sub-second capable). For DateTime columns (second
precision), fall back to second-level display.

- Add showMs prop to TimePicker (controls placeholder, format, and
  display strings)
- Add showMs param to dateRangeToString and useNewTimeQuery
- In DBSearchPage, derive showMs by looking up the timestamp column
  type from useColumns metadata
- Remove forced inclusive operators for DateTime columns — the
  toDateTime() wrapper handles precision, operator choice stays with
  the caller
- Update E2E locators to use regex matching for resilience against
  both formats

Co-authored-by: Mike Shi <mike@hyperdx.io>
- Revert DateTime detection and toDateTime() wrapper in
  renderChartConfig — ClickHouse handles implicit type promotion
  correctly, no query-layer changes needed
- Add showMs to useNewTimeQuery's useEffect dependency array so the
  displayed time string reformats when column metadata loads
- Restore original test mocks and remove DateTime-specific test cases

Co-authored-by: Mike Shi <mike@hyperdx.io>
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.

2 participants