Preserve OTLP nanosecond timestamp precision#3751
Conversation
|
|
Hi @RitwijParmar, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis pull request consolidates nanosecond timestamp conversion logic across the event repository module. Two helper functions in Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
convertDateToNanoseconds()anywhere the webapp converts epoch milliseconds into OTLP nanosecond timestampsBigIntconversionWhy
Fixes #3292. Multiplying epoch milliseconds by
1_000_000before converting toBigIntcrossesNumber.MAX_SAFE_INTEGERand can introduce small nanosecond-level errors. Converting toBigIntfirst preserves exact span timestamps and duration calculations.Verification
pnpm install --frozen-lockfilepnpm exec prettier --check apps/webapp/app/v3/eventRepository/common.server.ts apps/webapp/app/v3/eventRepository/index.server.ts apps/webapp/app/v3/runEngineHandlers.server.ts apps/webapp/test/eventRepositoryNanoseconds.test.tsgit diff --checknoderepro check confirmsBigInt(ms * 1_000_000)differs fromBigInt(ms) * 1_000_000nfor1_700_000_000_001Local test note
I tried
pnpm --filter webapp exec vitest run test/eventRepositoryNanoseconds.test.ts, but local collection is blocked before tests run because@trigger.dev/core/v3/isomorphicis not available until workspace packages are generated/built. Attemptingpnpm --filter @trigger.dev/core buildis currently blocked by existing generated database artifacts (../generated/prisma) plus an unrelatedsharedRuntimeManager.tsexhaustiveness error.