Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Continuous Profiling - stop when app goes in background #4311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 7, 2025

Conversation

stefanosiano
Copy link
Member

📜 Description

app going in the background now stops the continuous profiler

💡 Motivation and Context

Going to the background (after the session timer) should stop the profiler, as decided in the doc. Note that it shouldn't restart when it goes to the foreground again

💚 How did you test it?

Unit tests

📝 Checklist

  • 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

Added platform "android" in ProfileChunk envelope items
…dContinuousProfiler

Added "delayed" stop of profiler, which stops the profiler after the current chunk is finished
Added default span data (profiler id, thread name and thread id) to transaction root span
Copy link
Contributor

github-actions bot commented Apr 1, 2025

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

Generated by 🚫 dangerJS against 1f78424

@stefanosiano stefanosiano marked this pull request as ready for review April 1, 2025 15:43
@stefanosiano stefanosiano changed the base branch from main to feat/continuous-profiling-delayed-stop April 1, 2025 15:44
Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

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

Looking good, I left two comments I'd like to clarified before merging.

@@ -122,6 +122,7 @@ public void run() {
scopes.endSession();
}
scopes.getOptions().getReplayController().stop();
scopes.getOptions().getContinuousProfiler().stopAllProfiles();
Copy link
Member

Choose a reason for hiding this comment

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

This means the profiler will continue to run for 30s in the background before stopping, is this what we want?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, and actually stops after 30s and the last chunk is finished

Copy link
Member

Choose a reason for hiding this comment

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

Alright, to be honest I still wouldn't do this. Once the app is in background, any executed code can easily produce a background ANR.

Copy link
Member Author

Choose a reason for hiding this comment

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

true, but if we don't, the profiler could continue to run indefinitely, right?

Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

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

LGTM, I left a few comments, but nothing major which should stop us from shipping this.

Base automatically changed from feat/continuous-profiling-delayed-stop to main April 7, 2025 09:18
…-background

# Conflicts:
#	CHANGELOG.md
#	sentry-android-core/src/main/java/io/sentry/android/core/AndroidContinuousProfiler.java
#	sentry-android-core/src/test/java/io/sentry/android/core/AndroidContinuousProfilerTest.kt
added AndroidContinuousProfiler.close param isTerminating
@stefanosiano stefanosiano enabled auto-merge (squash) April 7, 2025 15:38
Copy link
Contributor

github-actions bot commented Apr 7, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 409.47 ms 470.42 ms 60.95 ms
Size 1.58 MiB 2.08 MiB 505.39 KiB

@stefanosiano stefanosiano merged commit c4eeb3c into main Apr 7, 2025
34 checks passed
@stefanosiano stefanosiano deleted the feat/continuous-profiling-stop-on-background branch April 7, 2025 15:50
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.

2 participants