Fix(SDK): Auto root span start timestamps precision#1985
Conversation
|
Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1985 +/- ##
============================================
+ Coverage 67.87% 67.92% +0.04%
Complexity 3046 3046
============================================
Files 459 459
Lines 8891 8891
============================================
+ Hits 6035 6039 +4
+ Misses 2856 2852 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
ChrisLightfootWild
left a comment
There was a problem hiding this comment.
Thanks for the PR @zigzagdev 💪
Summary
Content
Fixed a precision loss bug in
AutoRootSpan::create()where the start timestamp was calculated incorrectly whenREQUEST_TIME_FLOATis not available.Root Cause
The original code cast
microtime(true)tointbefore multiplying viaNANOS_PER_SECOND:This caused up to 999,999,999ns (~1 second) of error because the sub-second precision was discarded before nanosecond conversioning.
GET /?foo=barwithmicrotime(true)=1718123456.789→ cast to1718123456→ multiplied by1e9→ last 9 digits always000000000What I have done
Multiply first, then cast to
intto preserve sub-second precision like:Test Results