fix(ios): join write requests and screen loads to the traces they belong to - #561
Merged
Conversation
…ong to Two detachments, one screen. `push.sync` showed up as a single childless root: the POST it exists to measure carried no client span and no `traceparent`, because the SDK's interceptor declined every request with a body. Fixed in maple-swift 0.3.3, which this bumps to — the app's writes now reach the API's server spans in the same trace, the way its reads already did. The second is ours. `trackScreen` hands back a `ui.screen` span but nothing carries it, and the SDK is right not to make it ambient: a span that runs for the whole visit is not a scope anything can nest inside. So every `ui.screen` arrived as a childless root — 347 of 347 over three days — while the load it caused sat in a trace of its own. `Telemetry.Visit` registers the open span by screen name and `screenLoad` hangs under it, the same shape `PushOpen` already uses to parent a load to the notification tap that asked for it. A tapped notification still wins when there is one; a span the SDK closed on backgrounding is skipped rather than adopted as a parent that ended first.
🍁 Maple PR previewNote Preview resources were removed when this pull request closed. Final commit |
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.
push.syncrendered as a single childless root span — no HTTP child, nomaple-apiserver span. Two separate causes, both fixed here.Writes were never traced
The Swift SDK's
URLProtocolinterceptor declined any request with anhttpBodyStream, on the theory that it only skipped streamed uploads. Foundation hands aURLProtocolevery body as a stream —httpBody,from: Data,fromFile:and a delegate-fed stream alike — so it skipped every POST, PUT and PATCH the app makes: no client span, and notraceparent, which left the API's server span in a trace of its own.Three days of production traffic, org-scoped:
GET(Client)POST(Client)push.syncFixed in maple-swift 0.3.3 (the relay now carries the body across, preserving the app's framing); this bumps the pin.
ui.screenwas never a parenttrackScreenreturns the span but nothing carries it, and the SDK is right not to make it ambient — a span that runs for the whole visit is not a scope anything can nest inside. So all 347ui.screenspans arrived as childless roots while the load each one caused sat in its own trace.Telemetry.Visitregisters the open span by screen name andscreenLoadhangs under it — the same shapePushOpenalready uses to parent a load to the notification tap that asked for it. A tapped notification still wins when there is one, and a span the SDK closed on backgrounding is skipped rather than adopted as a parent that ended before its child began.Verification
MapleTracingTestspass, including new cases assertingtraceparentand byte-identical bodies on what actually left the process, one per URLSession body API.xcodebuild build -scheme Maplesucceeds against 0.3.3.POSTClient spans should appear withroots = 0, andpush.synctraces should contain amaple-apihttp.server POSTspan.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.