Skip to content
Draft
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
30 changes: 20 additions & 10 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class io/sentry/android/core/ActivityFramesTracker {
public fun takeMetrics (Lio/sentry/protocol/SentryId;)Ljava/util/Map;
}

public final class io/sentry/android/core/ActivityLifecycleIntegration : android/app/Application$ActivityLifecycleCallbacks, io/sentry/Integration, java/io/Closeable {
public final class io/sentry/android/core/ActivityLifecycleIntegration : android/app/Application$ActivityLifecycleCallbacks, io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/app/Application;Lio/sentry/android/core/BuildInfoProvider;Lio/sentry/android/core/ActivityFramesTracker;)V
public fun close ()V
public fun onActivityCreated (Landroid/app/Activity;Landroid/os/Bundle;)V
Expand All @@ -38,6 +38,7 @@ public final class io/sentry/android/core/ActivityLifecycleIntegration : android
public fun onActivityStarted (Landroid/app/Activity;)V
public fun onActivityStopped (Landroid/app/Activity;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/AndroidContinuousProfiler : io/sentry/IContinuousProfiler, io/sentry/transport/RateLimiter$IRateLimitObserver {
Expand Down Expand Up @@ -147,21 +148,23 @@ public final class io/sentry/android/core/AndroidSocketTagger : io/sentry/ISocke
public fun untagSockets ()V
}

public final class io/sentry/android/core/AnrIntegration : io/sentry/Integration, java/io/Closeable {
public final class io/sentry/android/core/AnrIntegration : io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/AnrIntegrationFactory {
public fun <init> ()V
public static fun create (Landroid/content/Context;Lio/sentry/android/core/BuildInfoProvider;)Lio/sentry/Integration;
}

public final class io/sentry/android/core/AnrV2Integration : io/sentry/Integration, java/io/Closeable {
public final class io/sentry/android/core/AnrV2Integration : io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/AnrV2Integration$AnrV2Hint : io/sentry/hints/BlockingFlushHint, io/sentry/hints/AbnormalExit, io/sentry/hints/Backfillable {
Expand All @@ -174,13 +177,14 @@ public final class io/sentry/android/core/AnrV2Integration$AnrV2Hint : io/sentry
public fun timestamp ()Ljava/lang/Long;
}

public final class io/sentry/android/core/AppComponentsBreadcrumbsIntegration : android/content/ComponentCallbacks2, io/sentry/Integration, java/io/Closeable {
public final class io/sentry/android/core/AppComponentsBreadcrumbsIntegration : android/content/ComponentCallbacks2, io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun onConfigurationChanged (Landroid/content/res/Configuration;)V
public fun onLowMemory ()V
public fun onTrimMemory (I)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/AppLifecycleIntegration : io/sentry/Integration, java/io/Closeable {
Expand Down Expand Up @@ -294,15 +298,16 @@ public final class io/sentry/android/core/DeviceInfoUtil {
public static fun isCharging (Landroid/content/Intent;Lio/sentry/SentryOptions;)Ljava/lang/Boolean;
}

public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : io/sentry/Integration, java/io/Closeable {
public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : io/sentry/internal/InternalIntegration, java/io/Closeable {
protected final field startLock Lio/sentry/util/AutoClosableReentrantLock;
public fun <init> ()V
public fun close ()V
public static fun getOutboxFileObserver ()Lio/sentry/android/core/EnvelopeFileObserverIntegration;
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/FeedbackShakeIntegration : android/app/Application$ActivityLifecycleCallbacks, io/sentry/Integration, io/sentry/SentryFeedbackOptions$IShakeController, java/io/Closeable {
public final class io/sentry/android/core/FeedbackShakeIntegration : android/app/Application$ActivityLifecycleCallbacks, io/sentry/SentryFeedbackOptions$IShakeController, io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/app/Application;)V
public fun close ()V
public fun disableOnShake ()V
Expand All @@ -316,6 +321,7 @@ public final class io/sentry/android/core/FeedbackShakeIntegration : android/app
public fun onActivityStarted (Landroid/app/Activity;)V
public fun onActivityStopped (Landroid/app/Activity;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public abstract interface class io/sentry/android/core/IDebugImagesLoader {
Expand Down Expand Up @@ -348,10 +354,11 @@ public final class io/sentry/android/core/LoadClass : io/sentry/util/LoadClass {
public fun loadClass (Ljava/lang/String;Lio/sentry/ILogger;)Ljava/lang/Class;
}

public final class io/sentry/android/core/MemoryLimiterIntegration : io/sentry/Integration, java/io/Closeable {
public final class io/sentry/android/core/MemoryLimiterIntegration : io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/BuildInfoProvider;)V
public fun close ()V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/MemoryLimiterIntegration$MemoryLimiterHint : io/sentry/hints/BlockingFlushHint, io/sentry/hints/AbnormalExit, io/sentry/hints/Backfillable {
Expand Down Expand Up @@ -665,7 +672,7 @@ public final class io/sentry/android/core/SpanFrameMetricsCollector : io/sentry/
public fun onSpanStarted (Lio/sentry/ISpan;)V
}

public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : io/sentry/Integration, io/sentry/android/core/AppState$AppStateListener, java/io/Closeable {
public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : io/sentry/android/core/AppState$AppStateListener, io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun <init> (Landroid/content/Context;Landroid/os/Handler;)V
public fun <init> (Landroid/content/Context;Ljava/util/List;)V
Expand All @@ -674,12 +681,14 @@ public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : i
public fun onBackground ()V
public fun onForeground ()V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/TombstoneIntegration : io/sentry/Integration, java/io/Closeable {
public final class io/sentry/android/core/TombstoneIntegration : io/sentry/internal/InternalIntegration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
}

public final class io/sentry/android/core/TombstoneIntegration$TombstoneHint : io/sentry/hints/BlockingFlushHint, io/sentry/hints/Backfillable, io/sentry/hints/NativeCrashExit {
Expand Down Expand Up @@ -768,14 +777,15 @@ public final class io/sentry/android/core/anr/AnrProfileRotationHelper {
public static fun rotate ()V
}

public final class io/sentry/android/core/anr/AnrProfilingIntegration : io/sentry/Integration, io/sentry/android/core/AppState$AppStateListener, java/io/Closeable, java/lang/Runnable {
public final class io/sentry/android/core/anr/AnrProfilingIntegration : io/sentry/android/core/AppState$AppStateListener, io/sentry/internal/InternalIntegration, java/io/Closeable, java/lang/Runnable {
public static final field POLLING_INTERVAL_MS J
public static final field THRESHOLD_ANR_MS J
public fun <init> ()V
public fun close ()V
public fun onBackground ()V
public fun onForeground ()V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;Lio/sentry/internal/SentryRuntime;)V
public fun run ()V
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
import io.sentry.FullyDisplayedReporter;
import io.sentry.IScope;
import io.sentry.IScopes;
import io.sentry.ISentryExecutorService;
import io.sentry.ISentryLifecycleToken;
import io.sentry.ISpan;
import io.sentry.ITransaction;
import io.sentry.Instrumenter;
import io.sentry.Integration;
import io.sentry.NoOpSentryExecutorService;
import io.sentry.NoOpTransaction;
import io.sentry.PropagationContext;
import io.sentry.SentryDate;
Expand All @@ -35,6 +36,9 @@
import io.sentry.android.core.performance.ActivityLifecycleSpanHelper;
import io.sentry.android.core.performance.AppStartMetrics;
import io.sentry.android.core.performance.TimeSpan;
import io.sentry.internal.InternalIntegration;
import io.sentry.internal.LegacyOptionsBridge;
import io.sentry.internal.SentryRuntime;
import io.sentry.protocol.MeasurementValue;
import io.sentry.protocol.SentryId;
import io.sentry.protocol.TransactionNameSource;
Expand All @@ -56,7 +60,10 @@
import org.jetbrains.annotations.VisibleForTesting;

public final class ActivityLifecycleIntegration
implements Integration, Closeable, Application.ActivityLifecycleCallbacks {
implements InternalIntegration, Closeable, Application.ActivityLifecycleCallbacks {

private volatile @NotNull ISentryExecutorService executorService =
NoOpSentryExecutorService.getInstance();

static final String UI_LOAD_OP = "ui.load";
static final String STANDALONE_APP_START_OP = "app.start";
Expand Down Expand Up @@ -128,6 +135,15 @@ public ActivityLifecycleIntegration(

@Override
public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
register(scopes, options, LegacyOptionsBridge.runtimeOf(options));
}

@Override
public void register(
final @NotNull IScopes scopes,
final @NotNull SentryOptions options,
final @NotNull SentryRuntime runtime) {
this.executorService = runtime.getExecutorService();
this.options =
Objects.requireNonNull(
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
Expand Down Expand Up @@ -390,10 +406,8 @@ private void startTracing(final @NotNull Activity activity) {
try {
ttfdSpanMap.put(activity, ttfdSpan);
ttfdAutoCloseFuture =
options
.getExecutorService()
.schedule(
() -> finishExceededTtfdSpan(ttfdSpan, ttidSpan), TTFD_TIMEOUT_MILLIS);
executorService.schedule(
() -> finishExceededTtfdSpan(ttfdSpan, ttidSpan), TTFD_TIMEOUT_MILLIS);
} catch (RejectedExecutionException e) {
options
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
import android.content.Context;
import io.sentry.Hint;
import io.sentry.IScopes;
import io.sentry.ISentryExecutorService;
import io.sentry.ISentryLifecycleToken;
import io.sentry.Integration;
import io.sentry.NoOpSentryExecutorService;
import io.sentry.SentryEvent;
import io.sentry.SentryLevel;
import io.sentry.SentryOptions;
import io.sentry.exception.ExceptionMechanismException;
import io.sentry.hints.AbnormalExit;
import io.sentry.hints.TransactionEnd;
import io.sentry.internal.InternalIntegration;
import io.sentry.internal.LegacyOptionsBridge;
import io.sentry.internal.SentryRuntime;
import io.sentry.protocol.Mechanism;
import io.sentry.util.AutoClosableReentrantLock;
import io.sentry.util.HintUtils;
Expand All @@ -28,7 +32,10 @@
* When the UI thread of an Android app is blocked for too long, an "Application Not Responding"
* (ANR) error is triggered. Sends an event if an ANR happens
*/
public final class AnrIntegration implements Integration, Closeable {
public final class AnrIntegration implements InternalIntegration, Closeable {

private volatile @NotNull ISentryExecutorService executorService =
NoOpSentryExecutorService.getInstance();

private final @NotNull Context context;
private boolean isClosed = false;
Expand All @@ -51,6 +58,15 @@ public AnrIntegration(final @NotNull Context context) {

@Override
public final void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
register(scopes, options, LegacyOptionsBridge.runtimeOf(options));
}

@Override
public final void register(
final @NotNull IScopes scopes,
final @NotNull SentryOptions options,
final @NotNull SentryRuntime runtime) {
this.executorService = runtime.getExecutorService();
this.options = Objects.requireNonNull(options, "SentryOptions is required");
register(scopes, (SentryAndroidOptions) options);
}
Expand All @@ -65,15 +81,13 @@ private void register(
if (options.isAnrEnabled()) {
addIntegrationToSdkVersion("Anr");
try {
options
.getExecutorService()
.submit(() -> {
try (final @NotNull ISentryLifecycleToken ignored = startLock.acquire()) {
if (!isClosed) {
startAnrWatchdog(scopes, options);
}
}
});
executorService.submit(() -> {
try (final @NotNull ISentryLifecycleToken ignored = startLock.acquire()) {
if (!isClosed) {
startAnrWatchdog(scopes, options);
}
}
});
} catch (Throwable e) {
options
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.sentry.Hint;
import io.sentry.ILogger;
import io.sentry.IScopes;
import io.sentry.Integration;
import io.sentry.SentryEvent;
import io.sentry.SentryLevel;
import io.sentry.SentryOptions;
Expand All @@ -22,6 +21,9 @@
import io.sentry.hints.AbnormalExit;
import io.sentry.hints.Backfillable;
import io.sentry.hints.BlockingFlushHint;
import io.sentry.internal.InternalIntegration;
import io.sentry.internal.LegacyOptionsBridge;
import io.sentry.internal.SentryRuntime;
import io.sentry.protocol.ArtContext;
import io.sentry.protocol.DebugImage;
import io.sentry.protocol.DebugMeta;
Expand All @@ -42,7 +44,7 @@
import org.jetbrains.annotations.Nullable;

@SuppressLint("NewApi") // we check this in AnrIntegrationFactory
public final class AnrV2Integration implements Integration, Closeable {
public final class AnrV2Integration implements InternalIntegration, Closeable {

private final @NotNull Context context;
private @Nullable SentryAndroidOptions options;
Expand All @@ -51,10 +53,18 @@ public AnrV2Integration(final @NotNull Context context) {
this.context = ContextUtils.getApplicationContext(context);
}

@SuppressLint("NewApi") // we do the check in the AnrIntegrationFactory
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void register(@NotNull IScopes scopes, @NotNull SentryOptions options) {
register(scopes, options, LegacyOptionsBridge.runtimeOf(options));
}

@Override
@SuppressLint("NewApi") // we do the check in the AnrIntegrationFactory
@SuppressWarnings("FutureReturnValueIgnored")
public void register(
final @NotNull IScopes scopes,
final @NotNull SentryOptions options,
final @NotNull SentryRuntime runtime) {
this.options =
Objects.requireNonNull(
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
Expand All @@ -73,11 +83,15 @@ public void register(@NotNull IScopes scopes, @NotNull SentryOptions options) {

if (this.options.isAnrEnabled()) {
try {
options
runtime
.getExecutorService()
.submit(
new ApplicationExitInfoHistoryDispatcher(
context, scopes, this.options, new AnrV2Policy(this.options)));
context,
scopes,
this.options,
runtime.getEnvelopeDiskCache(),
new AnrV2Policy(this.options)));
} catch (Throwable e) {
options.getLogger().log(SentryLevel.DEBUG, "Failed to start ANR processor.", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
import io.sentry.Breadcrumb;
import io.sentry.Hint;
import io.sentry.IScopes;
import io.sentry.Integration;
import io.sentry.ISentryExecutorService;
import io.sentry.NoOpSentryExecutorService;
import io.sentry.SentryLevel;
import io.sentry.SentryOptions;
import io.sentry.android.core.internal.util.Debouncer;
import io.sentry.android.core.internal.util.DeviceOrientations;
import io.sentry.internal.InternalIntegration;
import io.sentry.internal.LegacyOptionsBridge;
import io.sentry.internal.SentryRuntime;
import io.sentry.protocol.Device;
import io.sentry.util.Objects;
import java.io.Closeable;
Expand All @@ -23,7 +27,10 @@
import org.jetbrains.annotations.Nullable;

public final class AppComponentsBreadcrumbsIntegration
implements Integration, Closeable, ComponentCallbacks2 {
implements InternalIntegration, Closeable, ComponentCallbacks2 {

private volatile @NotNull ISentryExecutorService executorService =
NoOpSentryExecutorService.getInstance();

private static final long DEBOUNCE_WAIT_TIME_MS = 60 * 1000;
// pre-allocate hint to avoid creating it every time for the low memory case
Expand All @@ -42,6 +49,15 @@ public AppComponentsBreadcrumbsIntegration(final @NotNull Context context) {

@Override
public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
register(scopes, options, LegacyOptionsBridge.runtimeOf(options));
}

@Override
public void register(
final @NotNull IScopes scopes,
final @NotNull SentryOptions options,
final @NotNull SentryRuntime runtime) {
this.executorService = runtime.getExecutorService();
this.scopes = Objects.requireNonNull(scopes, "Scopes are required");
this.options =
Objects.requireNonNull(
Expand Down Expand Up @@ -172,7 +188,7 @@ private void captureConfigurationChangedBreadcrumb(
private void executeInBackground(final @NotNull Runnable runnable) {
if (options != null) {
try {
options.getExecutorService().submit(runnable);
executorService.submit(runnable);
} catch (Throwable t) {
options
.getLogger()
Expand Down
Loading
Loading