Reproduce RUMS-5093: span timing bug with NTP clock drift#3356
Closed
Reproduce RUMS-5093: span timing bug with NTP clock drift#3356
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: 2615767 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CoreTracerSpanToSpanEventMapperTest: two tests prove that when device clock is ahead of server (negativeserverTimeOffsetNs),map()shifts the serialized spanstartto before the actual request started (5s earlier), making theandroid.requestspan appear to have negligible duration vs. backend child spansKronosTimeProviderTest: one test proves thatgetServerOffsetMillis()returns a large negative value (-5000ms) when device clock is ahead of server, with no guard against this offset being blindly applied at serialization timeDatadogHttpCodecTest: one passing test confirms thatx-datadog-parent-idis correctly set to the span's own spanId — the visual broken ordering in the Datadog UI is caused by incorrect timestamps, NOT by wrong context propagation headersRoot Cause
CoreTracerSpanToSpanEventMapper.map()fetchesserverTimeOffsetNsat serialization time (not at span creation time). When the device clock is ahead of NTP server time, this offset is negative, shifting the serialized span start timestamp to before the actual HTTP request was initiated.Test plan
:features:dd-sdk-android-trace:testDebugUnitTest— 2 REPRO tests fail, all others pass:dd-sdk-android-core:testDebugUnitTest— 1 REPRO test fails, all others pass:features:dd-sdk-android-trace-internal:testDebugUnitTest— 1 REPRO test passes (confirms propagation correctness), all others pass🤖 Generated with Claude Code