Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- 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).
To enable Continuous Profiling use the `Sentry.startProfiler` and `Sentry.stopProfiler` 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
Expand All @@ -19,15 +19,15 @@

// 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 manual mode, you need to start and stop the profiler manually using Sentry.startProfiler and Sentry.stopProfiler
// 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();
Sentry.startProfiler();

// After all profiling is done, stop the profiler. Profiles can last indefinitely if not stopped.
Sentry.stopProfileSession();
Sentry.stopProfiler();
```
```kotlin
import io.sentry.ProfileLifecycle
Expand All @@ -37,15 +37,15 @@

// 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 manual mode, you need to start and stop the profiler manually using Sentry.startProfiler and Sentry.stopProfiler
// 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()
Sentry.startProfiler()

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

To learn more visit [Sentry's Continuous Profiling](https://docs.sentry.io/product/explore/profiling/transaction-vs-continuous-profiling/#continuous-profiling-mode) documentation page.
Expand Down
4 changes: 2 additions & 2 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class io/sentry/android/core/AndroidContinuousProfiler : io/sentry/IConti
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 fun startProfiler (Lio/sentry/ProfileLifecycle;Lio/sentry/TracesSampler;)V
public fun stopProfiler (Lio/sentry/ProfileLifecycle;)V
}

public final class io/sentry/android/core/AndroidCpuCollector : io/sentry/IPerformanceSnapshotCollector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void init() {
}

@Override
public synchronized void startProfileSession(
public synchronized void startProfiler(
final @NotNull ProfileLifecycle profileLifecycle,
final @NotNull TracesSampler tracesSampler) {
if (shouldSample) {
Expand Down Expand Up @@ -217,7 +217,7 @@ private synchronized void start() {
}

@Override
public synchronized void stopProfileSession(final @NotNull ProfileLifecycle profileLifecycle) {
public synchronized void stopProfiler(final @NotNull ProfileLifecycle profileLifecycle) {
switch (profileLifecycle) {
case TRACE:
rootSpanCounter--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private void createAndStartContinuousProfiler(
sentryOptions
.getExperimental()
.setProfileSessionSampleRate(profilingOptions.isContinuousProfileSampled() ? 1.0 : 0.0);
appStartContinuousProfiler.startProfileSession(
appStartContinuousProfiler.startProfiler(
profilingOptions.getProfileLifecycle(), new TracesSampler(sentryOptions));
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class MyApplication extends Application {

@Override
public void onCreate() {
Sentry.startProfileSession();
Sentry.startProfiler();
strictMode();
super.onCreate();

Expand Down
40 changes: 20 additions & 20 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,10 @@ public final class io/sentry/HubAdapter : io/sentry/IHub {
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startProfileSession ()V
public fun startProfiler ()V
public fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun stopProfileSession ()V
public fun stopProfiler ()V
public fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down Expand Up @@ -719,10 +719,10 @@ public final class io/sentry/HubScopesWrapper : io/sentry/IHub {
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startProfileSession ()V
public fun startProfiler ()V
public fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun stopProfileSession ()V
public fun stopProfiler ()V
public fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down Expand Up @@ -752,8 +752,8 @@ public abstract interface class io/sentry/IContinuousProfiler {
public abstract fun getProfilerId ()Lio/sentry/protocol/SentryId;
public abstract fun isRunning ()Z
public abstract fun reevaluateSampling ()V
public abstract fun startProfileSession (Lio/sentry/ProfileLifecycle;Lio/sentry/TracesSampler;)V
public abstract fun stopProfileSession (Lio/sentry/ProfileLifecycle;)V
public abstract fun startProfiler (Lio/sentry/ProfileLifecycle;Lio/sentry/TracesSampler;)V
public abstract fun stopProfiler (Lio/sentry/ProfileLifecycle;)V
}

public abstract interface class io/sentry/IEnvelopeReader {
Expand Down Expand Up @@ -958,13 +958,13 @@ public abstract interface class io/sentry/IScopes {
public abstract fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public abstract fun setTransaction (Ljava/lang/String;)V
public abstract fun setUser (Lio/sentry/protocol/User;)V
public abstract fun startProfileSession ()V
public abstract fun startProfiler ()V
public abstract fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;)Lio/sentry/ITransaction;
public abstract fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun startTransaction (Ljava/lang/String;Ljava/lang/String;)Lio/sentry/ITransaction;
public fun startTransaction (Ljava/lang/String;Ljava/lang/String;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public abstract fun stopProfileSession ()V
public abstract fun stopProfiler ()V
public abstract fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public abstract fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down Expand Up @@ -1436,8 +1436,8 @@ public final class io/sentry/NoOpContinuousProfiler : io/sentry/IContinuousProfi
public fun getProfilerId ()Lio/sentry/protocol/SentryId;
public fun isRunning ()Z
public fun reevaluateSampling ()V
public fun startProfileSession (Lio/sentry/ProfileLifecycle;Lio/sentry/TracesSampler;)V
public fun stopProfileSession (Lio/sentry/ProfileLifecycle;)V
public fun startProfiler (Lio/sentry/ProfileLifecycle;Lio/sentry/TracesSampler;)V
public fun stopProfiler (Lio/sentry/ProfileLifecycle;)V
}

public final class io/sentry/NoOpEnvelopeReader : io/sentry/IEnvelopeReader {
Expand Down Expand Up @@ -1505,10 +1505,10 @@ public final class io/sentry/NoOpHub : io/sentry/IHub {
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startProfileSession ()V
public fun startProfiler ()V
public fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun stopProfileSession ()V
public fun stopProfiler ()V
public fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down Expand Up @@ -1667,10 +1667,10 @@ public final class io/sentry/NoOpScopes : io/sentry/IScopes {
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startProfileSession ()V
public fun startProfiler ()V
public fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun stopProfileSession ()V
public fun stopProfiler ()V
public fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down Expand Up @@ -2344,10 +2344,10 @@ public final class io/sentry/Scopes : io/sentry/IScopes {
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startProfileSession ()V
public fun startProfiler ()V
public fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun stopProfileSession ()V
public fun stopProfiler ()V
public fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down Expand Up @@ -2411,10 +2411,10 @@ public final class io/sentry/ScopesAdapter : io/sentry/IScopes {
public fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public fun setTransaction (Ljava/lang/String;)V
public fun setUser (Lio/sentry/protocol/User;)V
public fun startProfileSession ()V
public fun startProfiler ()V
public fun startSession ()V
public fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public fun stopProfileSession ()V
public fun stopProfiler ()V
public fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down Expand Up @@ -2517,14 +2517,14 @@ public final class io/sentry/Sentry {
public static fun setTag (Ljava/lang/String;Ljava/lang/String;)V
public static fun setTransaction (Ljava/lang/String;)V
public static fun setUser (Lio/sentry/protocol/User;)V
public static fun startProfileSession ()V
public static fun startProfiler ()V
public static fun startSession ()V
public static fun startTransaction (Lio/sentry/TransactionContext;)Lio/sentry/ITransaction;
public static fun startTransaction (Lio/sentry/TransactionContext;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public static fun startTransaction (Ljava/lang/String;Ljava/lang/String;)Lio/sentry/ITransaction;
public static fun startTransaction (Ljava/lang/String;Ljava/lang/String;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public static fun startTransaction (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/sentry/TransactionOptions;)Lio/sentry/ITransaction;
public static fun stopProfileSession ()V
public static fun stopProfiler ()V
public static fun withIsolationScope (Lio/sentry/ScopeCallback;)V
public static fun withScope (Lio/sentry/ScopeCallback;)V
}
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/ExperimentalOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public final class ExperimentalOptions {
/**
* Whether profiling can automatically be started as early as possible during the app lifecycle,
* to capture more of app startup. If {@link ExperimentalOptions#profileLifecycle} is {@link
* ProfileLifecycle#MANUAL} Profiling is started automatically on startup and stopProfileSession
* must be called manually whenever the app startup is completed If {@link
* ProfileLifecycle#MANUAL} Profiling is started automatically on startup and stopProfiler must be
* called manually whenever the app startup is completed If {@link
* ExperimentalOptions#profileLifecycle} is {@link ProfileLifecycle#TRACE} Profiling is started
* automatically on startup, and will automatically be stopped when the root span that is
* associated with app startup ends
Expand Down
8 changes: 4 additions & 4 deletions sentry/src/main/java/io/sentry/HubAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ public boolean isAncestorOf(final @Nullable IScopes otherScopes) {
}

@Override
public void startProfileSession() {
Sentry.startProfileSession();
public void startProfiler() {
Sentry.startProfiler();
}

@Override
public void stopProfileSession() {
Sentry.stopProfileSession();
public void stopProfiler() {
Sentry.stopProfiler();
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions sentry/src/main/java/io/sentry/HubScopesWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ public boolean isAncestorOf(final @Nullable IScopes otherScopes) {
}

@Override
public void startProfileSession() {
scopes.startProfileSession();
public void startProfiler() {
scopes.startProfiler();
}

@Override
public void stopProfileSession() {
scopes.stopProfileSession();
public void stopProfiler() {
scopes.stopProfiler();
}

@ApiStatus.Internal
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/IContinuousProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
public interface IContinuousProfiler {
boolean isRunning();

void startProfileSession(
void startProfiler(
final @NotNull ProfileLifecycle profileLifecycle, final @NotNull TracesSampler tracesSampler);

void stopProfileSession(final @NotNull ProfileLifecycle profileLifecycle);
void stopProfiler(final @NotNull ProfileLifecycle profileLifecycle);

/** Cancel the profiler and stops it. Used on SDK close. */
void close();
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/IScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ ITransaction startTransaction(
final @NotNull TransactionContext transactionContext,
final @NotNull TransactionOptions transactionOptions);

void startProfileSession();
void startProfiler();

void stopProfileSession();
void stopProfiler();

/**
* Associates {@link ISpan} and the transaction name with the {@link Throwable}. Used to determine
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/NoOpContinuousProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public static NoOpContinuousProfiler getInstance() {
}

@Override
public void stopProfileSession(final @NotNull ProfileLifecycle profileLifecycle) {}
public void stopProfiler(final @NotNull ProfileLifecycle profileLifecycle) {}

@Override
public boolean isRunning() {
return false;
}

@Override
public void startProfileSession(
public void startProfiler(
final @NotNull ProfileLifecycle profileLifecycle,
final @NotNull TracesSampler tracesSampler) {}

Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/NoOpHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ public boolean isAncestorOf(@Nullable IScopes otherScopes) {
}

@Override
public void startProfileSession() {}
public void startProfiler() {}

@Override
public void stopProfileSession() {}
public void stopProfiler() {}

@Override
public void setSpanContext(
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/NoOpScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ public boolean isAncestorOf(@Nullable IScopes otherScopes) {
}

@Override
public void startProfileSession() {}
public void startProfiler() {}

@Override
public void stopProfileSession() {}
public void stopProfiler() {}

@Override
public void setSpanContext(
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/ProfileLifecycle.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
public enum ProfileLifecycle {
/**
* Profiling is controlled manually. You must use the {@link Sentry#startProfileSession()} and
* {@link Sentry#stopProfileSession()} APIs to control the lifecycle of the profiler.
* Profiling is controlled manually. You must use the {@link Sentry#startProfiler()} and {@link
* Sentry#stopProfiler()} APIs to control the lifecycle of the profiler.
*/
MANUAL,
/**
Expand Down
10 changes: 5 additions & 5 deletions sentry/src/main/java/io/sentry/Scopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ public void flush(long timeoutMillis) {
&& getOptions().getProfileLifecycle() == ProfileLifecycle.TRACE) {
getOptions()
.getContinuousProfiler()
.startProfileSession(ProfileLifecycle.TRACE, getOptions().getInternalTracesSampler());
.startProfiler(ProfileLifecycle.TRACE, getOptions().getInternalTracesSampler());
}
}
}
Expand All @@ -951,7 +951,7 @@ && getOptions().getProfileLifecycle() == ProfileLifecycle.TRACE) {
}

@Override
public void startProfileSession() {
public void startProfiler() {
if (getOptions().isContinuousProfilingEnabled()) {
if (getOptions().getProfileLifecycle() != ProfileLifecycle.MANUAL) {
getOptions()
Expand All @@ -964,7 +964,7 @@ public void startProfileSession() {
}
getOptions()
.getContinuousProfiler()
.startProfileSession(ProfileLifecycle.MANUAL, getOptions().getInternalTracesSampler());
.startProfiler(ProfileLifecycle.MANUAL, getOptions().getInternalTracesSampler());
} else if (getOptions().isProfilingEnabled()) {
getOptions()
.getLogger()
Expand All @@ -975,7 +975,7 @@ public void startProfileSession() {
}

@Override
public void stopProfileSession() {
public void stopProfiler() {
if (getOptions().isContinuousProfilingEnabled()) {
if (getOptions().getProfileLifecycle() != ProfileLifecycle.MANUAL) {
getOptions()
Expand All @@ -987,7 +987,7 @@ public void stopProfileSession() {
return;
}
getOptions().getLogger().log(SentryLevel.DEBUG, "Stopped continuous Profiling.");
getOptions().getContinuousProfiler().stopProfileSession(ProfileLifecycle.MANUAL);
getOptions().getContinuousProfiler().stopProfiler(ProfileLifecycle.MANUAL);
} else {
getOptions()
.getLogger()
Expand Down
Loading
Loading