Skip to content

fix(ios): pin the SDK build that reports where a request's time went - #549

Merged
Makisuo merged 1 commit into
mainfrom
fix/ios-http-connection-phase-telemetry
Aug 20, 2026
Merged

fix(ios): pin the SDK build that reports where a request's time went#549
Makisuo merged 1 commit into
mainfrom
fix/ios-http-connection-phase-telemetry

Conversation

@Makisuo

@Makisuo Makisuo commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Bumps maple-swift to 0.2.1, which records URLSession's connection phases on client spans.

Why

The mobile screens load slowly and maple-api is not the reason. Joining 241 iOS client spans to their own maple-api server span in the same trace:

Phase p50 p95
Before the server 404 ms 1,148 ms
Server work 233 ms 857 ms
After the server responded 97 ms 759 ms

Two thirds of every request happens outside the API. Home's five requests do fan out in parallel — that part is fine — but in trace 85db338c… the app held two completed responses for 12.6 s, both ending at the same instant, long after the API had answered them in ~220 ms.

Contention is implicated: a request with no concurrent peers has an 89 ms post-server tail; with peers it is 496 ms p50 / 5,820 ms p95, and the request's own payload size does not explain the difference (~18 KB in every bucket).

Why the traces could not say more

The SDK's relay delegate implemented didReceive / didCompleteWithError but not didFinishCollecting, so URLSessionTaskMetrics — which URLSession had been measuring all along — was built and discarded. That is why 404 ms of pre-server time had no attribution.

0.2.1 keeps them. The gap now resolves into maple.http.{queued,dns,connect,tls,request,ttfb,response}_ms, plus maple.http.connection.reused and semconv's http.request.resend_count and network.protocol.{name,version}.

maple.http.queued_ms vs response_ms is what separates "connection setup" from "body transfer stuck behind something", which is the open question.

Scope

Instrument only — no app-side behaviour changes. The fix follows the numbers this produces rather than the current best guess at them.

Two things found along the way, left for separate changes:

  • ui.screen spans measure time-on-screen (max observed: 11 hours) and sit in the same latency rollup as real operations, which is why list_services reports maple-ios P95 = 12.62 s. That number is currently meaningless.
  • Home fetches /alerts/rules?limit=100 (42 KB) and /error_issues?limit=100 (39 KB), where the issues response is used only to compute two integers. Trimming it needs a count endpoint on the API side.

Verification

  • xcodegen generate + xcodebuild -scheme Maple against 0.2.1: BUILD SUCCEEDED
  • maple-swift: MapleTracingTests 60 passed (5 new), MapleReplayTests 80 passed

project.yml is the only durable pin — the generated .pbxproj and its Package.resolved are gitignored.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

maple-swift 0.2.1 records URLSession's connection phases on client spans.

The mobile screens are slow and maple-api is not the reason: joining 241 iOS
client spans to their own server span in the same trace puts 404ms p50 /
1148ms p95 *before* the server and 97ms / 759ms *after* it, against 233ms /
857ms of actual server work. In the worst trace the app held two completed
responses for twelve seconds — both ending at the same instant, long after
the API had answered in ~220ms.

Nothing in the trace could say what that time was, because the SDK's relay
delegate built URLSessionTaskMetrics and dropped them. 0.2.1 keeps them, so
the gap resolves into DNS, TLS, queueing, TTFB and body transfer instead of
a guess.

No app-side behaviour changes here — this is the instrument, and the fix
follows the numbers it produces.
@Makisuo
Makisuo merged commit d9b7207 into main Aug 20, 2026
26 checks passed
@Makisuo
Makisuo deleted the fix/ios-http-connection-phase-telemetry branch August 20, 2026 10:38
@Makisuo
Makisuo deployed to pr-preview August 20, 2026 10:38 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown

🍁 Maple PR preview

Note

Preview resources were removed when this pull request closed.

Final commit db2e5bb · View workflow run

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.

1 participant