Skip to content

feat: Return extended app launch span from extendAppLaunch()#7985

Merged
itaybre merged 11 commits into
mainfrom
itay/standalone_span
Jun 2, 2026
Merged

feat: Return extended app launch span from extendAppLaunch()#7985
itaybre merged 11 commits into
mainfrom
itay/standalone_span

Conversation

@itaybre
Copy link
Copy Markdown
Contributor

@itaybre itaybre commented Jun 2, 2026

Summary

  • SentrySDK.extendAppLaunch() now returns the extended app launch Span?, allowing users to add child spans for granular breakdown of the app start period
  • The return value is @discardableResult so this is not a breaking change
  • finishExtendedAppLaunch() is preserved for backward compatibility
  • Tracer creation is extracted into StandaloneTransactionStrategy.createTracer() to avoid duplication
  • Fixed a race condition: the tracer now waits for both the app start measurement (from report()) and the user finishing the span before completing the transaction

Example usage

let appStartSpan = SentrySDK.extendAppLaunch()

let configSpan = appStartSpan?.startChild(operation: "app.init", description: "fetch remote config")
fetchRemoteConfig()
configSpan?.finish()

appStartSpan?.finish()

Test plan

  • Existing extended app launch tests pass (updated for new API)
  • New tests for returned span, child span creation, and child span inclusion in transaction
  • Race condition tests: span finished before measurement arrives (both via span.finish() and finishExtendedAppLaunch())
  • AppStartReportingStrategy tests pass
  • Sample app updated with child span example
  • sdk_api.json regenerated

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 96507be

@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Jun 2, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Jun 2, 2026

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.16.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

Comment thread Sources/Swift/Integrations/AppStartTracking/SentryExtendedAppLaunchManager.swift Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@2446b3d). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...StartTracking/SentryExtendedAppLaunchManager.swift 93.333% 4 Missing ⚠️
Sources/Swift/Helper/SentrySDK.swift 0.000% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main     #7985   +/-   ##
========================================
  Coverage        ?   86.570%           
========================================
  Files           ?       550           
  Lines           ?     31692           
  Branches        ?     13029           
========================================
  Hits            ?     27436           
  Misses          ?      4207           
  Partials        ?        49           
Files with missing lines Coverage Δ
Sources/Sentry/SentryAppStartMeasurementProvider.m 100.000% <ø> (ø)
...s/AppStartTracking/AppStartReportingStrategy.swift 100.000% <100.000%> (ø)
...tions/AppStartTracking/SentryAppStartTracker.swift 94.382% <ø> (ø)
Sources/Swift/Helper/SentrySDK.swift 93.650% <0.000%> (ø)
...StartTracking/SentryExtendedAppLaunchManager.swift 95.238% <93.333%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2446b3d...96507be. Read the comment docs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1223.71 ms 1257.80 ms 34.09 ms
Size 24.14 KiB 1.17 MiB 1.15 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ba824fc 1212.75 ms 1244.29 ms 31.54 ms
48fa69f 1221.60 ms 1251.52 ms 29.92 ms
e3070ad 1201.60 ms 1235.70 ms 34.10 ms
9da166b 1222.40 ms 1250.24 ms 27.84 ms
6b08499 1231.61 ms 1241.90 ms 10.29 ms
1770336 1225.09 ms 1251.32 ms 26.23 ms
9c19a06 1217.77 ms 1248.98 ms 31.21 ms
bc68ff6 1227.02 ms 1254.89 ms 27.87 ms
a7c42d9 1217.25 ms 1253.98 ms 36.73 ms
8180609 1214.67 ms 1243.36 ms 28.69 ms

App size

Revision Plain With Sentry Diff
ba824fc 24.14 KiB 1.17 MiB 1.15 MiB
48fa69f 24.14 KiB 1.15 MiB 1.13 MiB
e3070ad 24.14 KiB 1.16 MiB 1.14 MiB
9da166b 24.14 KiB 1.16 MiB 1.14 MiB
6b08499 24.14 KiB 1.15 MiB 1.13 MiB
1770336 24.14 KiB 1.15 MiB 1.13 MiB
9c19a06 24.14 KiB 1.16 MiB 1.13 MiB
bc68ff6 24.14 KiB 1.16 MiB 1.14 MiB
a7c42d9 24.14 KiB 1.15 MiB 1.13 MiB
8180609 24.14 KiB 1.16 MiB 1.13 MiB

Previous results on branch: itay/standalone_span

Startup times

Revision Plain With Sentry Diff
c4d5fa5 1223.50 ms 1265.39 ms 41.89 ms
c7ce3b0 1236.80 ms 1269.20 ms 32.40 ms

App size

Revision Plain With Sentry Diff
c4d5fa5 24.14 KiB 1.17 MiB 1.15 MiB
c7ce3b0 24.14 KiB 1.17 MiB 1.15 MiB

Copy link
Copy Markdown
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved but please consider implementing the feedback

Comment thread Sources/Swift/Integrations/AppStartTracking/AppStartReportingStrategy.swift Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a0f6fc8. Configure here.

itaybre added 10 commits June 2, 2026 12:43
Allow users to add child spans to the extended app launch span,
enabling granular breakdown of the app start period. The return
value is @discardableResult for backward compatibility.

The tracer is now created eagerly in extend() and waits for both
the app start measurement (from report()) and the user finishing
the span before completing the transaction, preventing a race
condition.
Store tracerConfiguration under the initial lock in extend() so
report() can safely set the measurement even if the tracer object
hasn't been stored yet. If report() wins the race and sets the
measurement first, extend() detects this and calls tracer.finish()
after storing it.
Read the pre-generated appStartTraceId from
SentryAppStartMeasurementProvider so the extended app launch
transaction shares the same trace as the first UIVC transaction,
preserving distributed trace correlation.
Return existing span on duplicate extend() calls instead of
creating an orphaned tracer. Consolidated into a single lock
block. Added debug logging to setAppStartMeasurement and
shouldFinishTracer paths.
@itaybre itaybre force-pushed the itay/standalone_span branch from a0f6fc8 to c09bdc6 Compare June 2, 2026 15:44
@itaybre itaybre merged commit 4d144d7 into main Jun 2, 2026
224 of 226 checks passed
@itaybre itaybre deleted the itay/standalone_span branch June 2, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants