|
21 | 21 | * keeps the new "extend app start" concern out of that already-large class. |
22 | 22 | * |
23 | 23 | * <p>Both the eager standalone App Start {@link ITransaction} and its extended child {@link ISpan} |
24 | | - * are created by the integration (which has access to scopes) and handed back here via {@link |
25 | | - * #onExtended(ITransaction, ISpan)}. This component owns them from then on: it never stores them in |
26 | | - * the integration's shared transaction field, so the per-activity cleanup can never cancel an |
27 | | - * eagerly-created extension. |
| 24 | + * are created by the integration (which has access to scopes) and returned to this component from |
| 25 | + * {@link ExtendAppStartListener#onExtendAppStartRequested()}. This component owns them from then |
| 26 | + * on: it never stores them in the integration's shared transaction field, so the per-activity |
| 27 | + * cleanup can never cancel an eagerly-created extension. |
28 | 28 | */ |
29 | 29 | @ApiStatus.Internal |
30 | 30 | public final class AppStartExtension implements IAppStartExtender { |
31 | 31 |
|
| 32 | + /** |
| 33 | + * The standalone App Start transaction and its extended child span, created by the integration. |
| 34 | + */ |
| 35 | + public static final class ExtendedAppStart { |
| 36 | + public final @NotNull ITransaction transaction; |
| 37 | + public final @NotNull ISpan span; |
| 38 | + |
| 39 | + public ExtendedAppStart(final @NotNull ITransaction transaction, final @NotNull ISpan span) { |
| 40 | + this.transaction = transaction; |
| 41 | + this.span = span; |
| 42 | + } |
| 43 | + } |
| 44 | + |
32 | 45 | /** |
33 | 46 | * Notifies the integration that an extension was requested. The integration creates the |
34 | | - * standalone App Start transaction + extended child span (it has scopes) and hands them back via |
35 | | - * {@link #onExtended(ITransaction, ISpan)}. When no listener is registered (e.g. standalone |
36 | | - * tracing is disabled), {@link #extendAppStart()} is inert and the whole API stays a no-op. |
| 47 | + * standalone App Start transaction + extended child span (it has scopes) and returns them, or |
| 48 | + * returns {@code null} to decline (e.g. standalone tracing is disabled). When no listener is |
| 49 | + * registered, {@link #extendAppStart()} is inert and the whole API stays a no-op. |
37 | 50 | */ |
38 | 51 | public interface ExtendAppStartListener { |
39 | | - void onExtendAppStartRequested(); |
| 52 | + @Nullable |
| 53 | + ExtendedAppStart onExtendAppStartRequested(); |
40 | 54 | } |
41 | 55 |
|
42 | 56 | private final @NotNull AppStartMetrics metrics; |
@@ -81,24 +95,15 @@ public void extendAppStart() { |
81 | 95 | } |
82 | 96 | final @Nullable ExtendAppStartListener listener = extendAppStartListener; |
83 | 97 | if (listener != null) { |
84 | | - listener.onExtendAppStartRequested(); |
| 98 | + final @Nullable ExtendedAppStart extended = listener.onExtendAppStartRequested(); |
| 99 | + if (extended != null) { |
| 100 | + this.extendedTransaction = extended.transaction; |
| 101 | + this.extendedSpan = extended.span; |
| 102 | + } |
85 | 103 | } |
86 | 104 | } |
87 | 105 | } |
88 | 106 |
|
89 | | - /** |
90 | | - * Hands the eagerly-created standalone App Start transaction and its extended child span over to |
91 | | - * this component, which owns them from now on. Called synchronously by the integration while |
92 | | - * handling {@link ExtendAppStartListener#onExtendAppStartRequested()}. |
93 | | - */ |
94 | | - public void onExtended( |
95 | | - final @NotNull ITransaction transaction, final @NotNull ISpan extendedSpan) { |
96 | | - try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) { |
97 | | - this.extendedTransaction = transaction; |
98 | | - this.extendedSpan = extendedSpan; |
99 | | - } |
100 | | - } |
101 | | - |
102 | 107 | @Override |
103 | 108 | public void finishAppStart() { |
104 | 109 | try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) { |
|
0 commit comments