Skip to content

Commit fffd957

Browse files
committed
init the scopes at profile finish, too, so that it sends the chunk the first time
1 parent e0d5c10 commit fffd957

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

sentry-android-core/src/main/java/io/sentry/android/core/AndroidContinuousProfiler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void startProfiler(
151151
}
152152
}
153153

154-
private void start() {
154+
private void initScopes() {
155155
if ((scopes == null || scopes == NoOpScopes.getInstance())
156156
&& Sentry.getCurrentScopes() != NoOpScopes.getInstance()) {
157157
this.scopes = Sentry.getCurrentScopes();
@@ -162,6 +162,10 @@ private void start() {
162162
rateLimiter.addRateLimitObserver(this);
163163
}
164164
}
165+
}
166+
167+
private void start() {
168+
initScopes();
165169

166170
// Debug.startMethodTracingSampling() is only available since Lollipop, but Android Profiler
167171
// causes crashes on api 21 -> https://github.com/getsentry/sentry-java/issues/3392
@@ -252,6 +256,7 @@ public void stopProfiler(final @NotNull ProfileLifecycle profileLifecycle) {
252256
}
253257

254258
private void stop(final boolean restartProfiler) {
259+
initScopes();
255260
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
256261
if (stopFuture != null) {
257262
stopFuture.cancel(true);

0 commit comments

Comments
 (0)