Skip to content

feat(extend-app-start): [2/4] Add deferred extended span and extension state#5606

Draft
buenaflor wants to merge 1 commit into
feat/app-start-extension-corefrom
feat/app-start-extension-android
Draft

feat(extend-app-start): [2/4] Add deferred extended span and extension state#5606
buenaflor wants to merge 1 commit into
feat/app-start-extension-corefrom
feat/app-start-extension-android

Conversation

@buenaflor

@buenaflor buenaflor commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

PR Stack (Extend App Start)


📜 Description

Builds the Android machinery behind the IAppStartExtender bridge:

  • ExtendedAppStartSpan — a deferred ISpan created in Application.onCreate, before the app start transaction exists. Pre-materialization, calls delegate to NoOpSpan and finish(...) buffers the status + call-time timestamp; materialize(realChild) swaps in the real child span and replays a buffered finish. Idempotent.
  • AppStartMetrics implements IAppStartExtenderextendAppStart() (guarded against already-extended / measurements-sent / activity-created / first-frame-drawn), finishAppStart(), getExtendedAppStartSpan(), plus accessors used by the next PR (isExtendedAppStartPending, getPendingExtendedAppStartSpan, markExtendedAppStartMaterialized) and a deadline-aware getExtendedAppStartEndTime() (returns null on DEADLINE_EXCEEDED so the vital is suppressed rather than inflated). clear() resets the new state.
  • Registered via AndroidOptionsInitializer.

Still inert end-to-end: nothing materializes the span yet (next PR wires ActivityLifecycleIntegration + the vital), and the public Sentry facade lands last.

💡 Motivation and Context

Second PR of the stack implementing the app start extension API (part of #5553).

💚 How did you test it?

Unit tests (TDD):

  • ExtendedAppStartSpanTest (8 cases) — buffering, materialize replay, delegation, start-date, idempotency.
  • AppStartMetricsTest (11 new cases) — extend creates a pending span; guards warn + ignore; finish idempotency; user-finish vs deadline reflected in the end-time accessor; clear() resets.

./gradlew :sentry-android-core:apiCheck, spotless, and AndroidOptionsInitializerTest (init wiring) pass.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

[3/4] — materialize the span across the three transaction paths in ActivityLifecycleIntegration and extend/suppress the app start vital in PerformanceAndroidEventProcessor.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

#skip-changelog

@github-actions

github-actions Bot commented Jun 23, 2026

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

Generated by 🚫 dangerJS against 54be119

@sentry

sentry Bot commented Jun 23, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.44.1 (1) release

⚙️ sentry-android Build Distribution Settings

…tartMetrics extension state

Adds ExtendedAppStartSpan, a deferred ISpan that buffers an early finish and
materializes into a real child span once the app start transaction exists.
AppStartMetrics now implements IAppStartExtender with window guards,
materialization state, and a deadline-aware end-time accessor for the app start
vital. Registered via AndroidOptionsInitializer.

Inert end-to-end until ALI materializes the span (PR3) and the public Sentry
facade is added (PR4).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@buenaflor buenaflor force-pushed the feat/app-start-extension-core branch from 064d3f1 to 7a7d63f Compare June 23, 2026 12:13
@buenaflor buenaflor force-pushed the feat/app-start-extension-android branch from fd450bb to 54be119 Compare June 23, 2026 12:13
@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 336.02 ms 403.42 ms 67.40 ms
Size 0 B 0 B 0 B

Baseline results on branch: feat/app-start-extension-core

Startup times

Revision Plain With Sentry Diff
3d04aae 324.42 ms 359.30 ms 34.88 ms
2821a4d 315.46 ms 366.56 ms 51.10 ms

App size

Revision Plain With Sentry Diff
3d04aae 0 B 0 B 0 B
2821a4d 0 B 0 B 0 B

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