Skip to content

Add Continuous Profiling support (v8) #3710

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 21 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f0d8942
added IContinuousProfiler and implementations
stefanosiano Sep 9, 2024
ec061f9
updated IHub to IScopes
stefanosiano Sep 17, 2024
cb3c9d3
Merge branch 'refs/heads/8.x.x' into feat/continuous-profiling-part1
stefanosiano Sep 24, 2024
4365bc3
Merge branch '8.x.x' into feat/continuous-profiling-part1
stefanosiano Nov 11, 2024
209b03d
wrapped continuous profiler close future in a try catch block
stefanosiano Nov 11, 2024
da77271
Merge branch '8.x.x' into feat/continuous-profiling-part1
stefanosiano Nov 11, 2024
a9235ae
Change payload for Continuous Profiling v8 (p2) (#3711)
stefanosiano Nov 14, 2024
6c36c4b
Merge branch '8.x.x' into feat/continuous-profiling-part1
stefanosiano Nov 22, 2024
b0e8333
Add rate limit for Continuous Profiling v8 (p6) (#3926)
stefanosiano Dec 6, 2024
e70d583
added SentryOptions.continuousProfilesSampleRate (#4013)
stefanosiano Dec 23, 2024
87bdd6d
Wrap up continuous profiling (#4069)
stefanosiano Feb 14, 2025
fcfa576
Change continuous profiling to session sample rate (#4180)
stefanosiano Feb 27, 2025
1440de9
Rename continuous profiling APIs (#4182)
stefanosiano Feb 27, 2025
27d91aa
Add continuous profiling ProfileLifecycle (#4202)
stefanosiano Mar 14, 2025
3d0fb3c
Add Continuous Profiling isStartProfilerOnAppStart option (#4226)
stefanosiano Mar 14, 2025
1206307
Merge branch 'refs/heads/main' into feat/continuous-profiling-part1
stefanosiano Mar 17, 2025
c7164d7
merged main and updated tests
stefanosiano Mar 17, 2025
1dfdeb8
Merge branch 'main' into feat/continuous-profiling-part1
stefanosiano Mar 18, 2025
d68733d
Merge branch 'main' into feat/continuous-profiling-part1
stefanosiano Mar 18, 2025
f467dbe
merged main and updated tests
stefanosiano Mar 18, 2025
9954e1c
merged main and updated tests
stefanosiano Mar 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,50 @@
### Features

- Add native stack frame address information and debug image metadata to ANR events ([#4061](https://github.com/getsentry/sentry-java/pull/4061))
- This enables symbolication for stripped native code in ANRs
- This enables symbolication for stripped native code in ANRs
- Add Continuous Profiling Support ([#3710](https://github.com/getsentry/sentry-java/pull/3710))

To enable Continuous Profiling use the `Sentry.startProfileSession` and `Sentry.stopProfileSession` experimental APIs. Sampling rate can be set through `options.profileSessionSampleRate`, which defaults to null (disabled).
Note: Both `options.profilesSampler` and `options.profilesSampleRate` must **not** be set to enable Continuous Profiling.

```java
import io.sentry.ProfileLifecycle;
import io.sentry.android.core.SentryAndroid;

SentryAndroid.init(context) { options ->

// Currently under experimental options:
options.getExperimental().setProfileSessionSampleRate(1.0);
// In manual mode, you need to start and stop the profiler manually using Sentry.startProfileSession and Sentry.stopProfileSession
// In trace mode, the profiler will start and stop automatically whenever a sampled trace starts and finishes
options.getExperimental().setProfileLifecycle(ProfileLifecycle.MANUAL);
}
// Start profiling
Sentry.startProfileSession();

// After all profiling is done, stop the profiler. Profiles can last indefinitely if not stopped.
Sentry.stopProfileSession();
```
```kotlin
import io.sentry.ProfileLifecycle
import io.sentry.android.core.SentryAndroid

SentryAndroid.init(context) { options ->

// Currently under experimental options:
options.experimental.profileSessionSampleRate = 1.0
// In manual mode, you need to start and stop the profiler manually using Sentry.startProfileSession and Sentry.stopProfileSession
// In trace mode, the profiler will start and stop automatically whenever a sampled trace starts and finishes
options.experimental.profileLifecycle = ProfileLifecycle.MANUAL
}
// Start profiling
Sentry.startProfileSession()

// After all profiling is done, stop the profiler. Profiles can last indefinitely if not stopped.
Sentry.stopProfileSession()
```

To learn more visit [Sentry's Continuous Profiling](https://docs.sentry.io/product/explore/profiling/transaction-vs-continuous-profiling/#continuous-profiling-mode) documentation page.

### Fixes

Expand Down
1 change: 1 addition & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#Mon Mar 17 13:40:54 CET 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
Expand Down
14 changes: 14 additions & 0 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ public final class io/sentry/android/core/ActivityLifecycleIntegration : android
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public class io/sentry/android/core/AndroidContinuousProfiler : io/sentry/IContinuousProfiler, io/sentry/transport/RateLimiter$IRateLimitObserver {
public fun <init> (Lio/sentry/android/core/BuildInfoProvider;Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;Lio/sentry/ILogger;Ljava/lang/String;ILio/sentry/ISentryExecutorService;)V
public fun close ()V
public fun getProfilerId ()Lio/sentry/protocol/SentryId;
public fun getRootSpanCounter ()I
public fun isRunning ()Z
public fun onRateLimitChanged (Lio/sentry/transport/RateLimiter;)V
public fun reevaluateSampling ()V
public fun startProfileSession (Lio/sentry/ProfileLifecycle;Lio/sentry/TracesSampler;)V
public fun stopProfileSession (Lio/sentry/ProfileLifecycle;)V
}

public final class io/sentry/android/core/AndroidCpuCollector : io/sentry/IPerformanceSnapshotCollector {
public fun <init> (Lio/sentry/ILogger;)V
public fun collect (Lio/sentry/PerformanceCollectionData;)V
Expand Down Expand Up @@ -460,6 +472,7 @@ public class io/sentry/android/core/performance/AppStartMetrics : io/sentry/andr
public fun clear ()V
public fun createProcessInitSpan ()Lio/sentry/android/core/performance/TimeSpan;
public fun getActivityLifecycleTimeSpans ()Ljava/util/List;
public fun getAppStartContinuousProfiler ()Lio/sentry/IContinuousProfiler;
public fun getAppStartProfiler ()Lio/sentry/ITransactionProfiler;
public fun getAppStartSamplingDecision ()Lio/sentry/TracesSamplingDecision;
public fun getAppStartTimeSpan ()Lio/sentry/android/core/performance/TimeSpan;
Expand All @@ -481,6 +494,7 @@ public class io/sentry/android/core/performance/AppStartMetrics : io/sentry/andr
public static fun onContentProviderPostCreate (Landroid/content/ContentProvider;)V
public fun registerLifecycleCallbacks (Landroid/app/Application;)V
public fun setAppLaunchedInForeground (Z)V
public fun setAppStartContinuousProfiler (Lio/sentry/IContinuousProfiler;)V
public fun setAppStartProfiler (Lio/sentry/ITransactionProfiler;)V
public fun setAppStartSamplingDecision (Lio/sentry/TracesSamplingDecision;)V
public fun setAppStartType (Lio/sentry/android/core/performance/AppStartMetrics$AppStartType;)V
Expand Down
Loading
Loading