Skip to content
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

Hubs Scopes Merge 29 - Mark TODOs related to Hubs/Scopes Merge with [HSM] #3356

Merged
merged 35 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
305baf5
replace hub with scopes
adinauer Mar 27, 2024
95f5e1b
Add Scopes
adinauer Apr 2, 2024
27f2398
Introduce `IScopes` interface.
adinauer Apr 2, 2024
ce3c14f
Replace `IHub` with `IScopes` in core
adinauer Apr 2, 2024
ce615f4
Replace `IHub` with `IScopes` in android core
adinauer Apr 2, 2024
22ddc00
Replace `IHub` with `IScopes` in android integrations
adinauer Apr 2, 2024
305c217
Replace `IHub` with `IScopes` in apollo integrations
adinauer Apr 2, 2024
da927bc
Replace `IHub` with `IScopes` in okhttp integration
adinauer Apr 2, 2024
8279276
Replace `IHub` with `IScopes` in graphql integration
adinauer Apr 2, 2024
9bfc086
Replace `IHub` with `IScopes` in logging integrations
adinauer Apr 2, 2024
b998e50
Replace `IHub` with `IScopes` in more integrations
adinauer Apr 2, 2024
739827a
Replace `IHub` with `IScopes` in OTel integration
adinauer Apr 2, 2024
69f2d63
Replace `IHub` with `IScopes` in Spring 5 / Spring Boot 2 integrations
adinauer Apr 2, 2024
792d482
Replace `IHub` with `IScopes` in Spring 6 / Spring Boot 3 integrations
adinauer Apr 2, 2024
9bcbce6
Replace `IHub` with `IScopes` in samples
adinauer Apr 2, 2024
3f25a4b
Merge branch 'feat/hsm-13-replacements-in-samples' into feat/hubs-sco…
adinauer Apr 2, 2024
d6fb40a
gitscopes -> github
adinauer Apr 2, 2024
7752bcc
Replace ThreadLocal with ScopesStorage
adinauer Apr 4, 2024
1e329c5
Move client and throwable to span map to scope
adinauer Apr 4, 2024
b0d89ae
Add global scope
adinauer Apr 4, 2024
cdd414a
use global scope in Scopes
adinauer Apr 4, 2024
98da9ff
Implement pushScope popScope and withScope for Scopes
adinauer Apr 4, 2024
2d26033
Add pushIsolationScope; add fork methods to ISCope
adinauer Apr 12, 2024
bbb6700
Use separate scopes for current, isolation and global scope; rename m…
adinauer Apr 12, 2024
c714b21
Allow controlling which scope configureScope uses
adinauer Apr 12, 2024
a474402
Combine scopes
adinauer Apr 12, 2024
ae93e33
Use new API for CRONS integrations
adinauer Apr 12, 2024
b01298b
Add lifecycle helper
adinauer Apr 12, 2024
b64e688
Change spring integrations to use new API
adinauer Apr 12, 2024
d06fc50
Use new API in servlet integrations
adinauer Apr 12, 2024
f0af5c3
Use new API for kotlin coroutines and wrapers for Supplier/Callable
adinauer Apr 12, 2024
2f02001
Discussion TODOs
adinauer Apr 12, 2024
bf4a7bf
Fix breadcrumb ordering
adinauer Apr 15, 2024
62cb91a
Mark TODOS with [HSM]
adinauer Apr 15, 2024
5b8902f
Merge branch '8.x.x' into feat/hsm-29-todos
adinauer Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ allprojects {
dependsOn("cleanTest")
}
withType<JavaCompile> {
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing"))
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing", "-Xlint:-try"))
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public final class io/sentry/android/core/ActivityBreadcrumbsIntegration : andro
public fun onActivitySaveInstanceState (Landroid/app/Activity;Landroid/os/Bundle;)V
public fun onActivityStarted (Landroid/app/Activity;)V
public fun onActivityStopped (Landroid/app/Activity;)V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/ActivityFramesTracker {
Expand All @@ -33,7 +33,7 @@ public final class io/sentry/android/core/ActivityLifecycleIntegration : android
public fun onActivitySaveInstanceState (Landroid/app/Activity;Landroid/os/Bundle;)V
public fun onActivityStarted (Landroid/app/Activity;)V
public fun onActivityStopped (Landroid/app/Activity;)V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/AndroidCpuCollector : io/sentry/IPerformanceSnapshotCollector {
Expand Down Expand Up @@ -87,7 +87,7 @@ public class io/sentry/android/core/AndroidProfiler$ProfileStartData {
public final class io/sentry/android/core/AnrIntegration : io/sentry/Integration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public final fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/AnrIntegrationFactory {
Expand All @@ -104,7 +104,7 @@ public final class io/sentry/android/core/AnrV2EventProcessor : io/sentry/Backfi
public class io/sentry/android/core/AnrV2Integration : io/sentry/Integration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/AnrV2Integration$AnrV2Hint : io/sentry/hints/BlockingFlushHint, io/sentry/hints/AbnormalExit, io/sentry/hints/Backfillable {
Expand All @@ -123,13 +123,13 @@ public final class io/sentry/android/core/AppComponentsBreadcrumbsIntegration :
public fun onConfigurationChanged (Landroid/content/res/Configuration;)V
public fun onLowMemory ()V
public fun onTrimMemory (I)V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/AppLifecycleIntegration : io/sentry/Integration, java/io/Closeable {
public fun <init> ()V
public fun close ()V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/AppState {
Expand Down Expand Up @@ -177,7 +177,7 @@ public final class io/sentry/android/core/CurrentActivityIntegration : android/a
public fun onActivitySaveInstanceState (Landroid/app/Activity;Landroid/os/Bundle;)V
public fun onActivityStarted (Landroid/app/Activity;)V
public fun onActivityStopped (Landroid/app/Activity;)V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/DeviceInfoUtil {
Expand All @@ -193,7 +193,7 @@ public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : i
public fun <init> ()V
public fun close ()V
public static fun getOutboxFileObserver ()Lio/sentry/android/core/EnvelopeFileObserverIntegration;
public final fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public abstract interface class io/sentry/android/core/IDebugImagesLoader {
Expand All @@ -219,19 +219,19 @@ public final class io/sentry/android/core/NdkIntegration : io/sentry/Integration
public static final field SENTRY_NDK_CLASS_NAME Ljava/lang/String;
public fun <init> (Ljava/lang/Class;)V
public fun close ()V
public final fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

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

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

public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor {
Expand Down Expand Up @@ -360,15 +360,15 @@ public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : i
public fun <init> (Landroid/content/Context;)V
public fun <init> (Landroid/content/Context;Ljava/util/List;)V
public fun close ()V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/TempSensorBreadcrumbsIntegration : android/hardware/SensorEventListener, io/sentry/Integration, java/io/Closeable {
public fun <init> (Landroid/content/Context;)V
public fun close ()V
public fun onAccuracyChanged (Landroid/hardware/Sensor;I)V
public fun onSensorChanged (Landroid/hardware/SensorEvent;)V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/UserInteractionIntegration : android/app/Application$ActivityLifecycleCallbacks, io/sentry/Integration, java/io/Closeable {
Expand All @@ -381,7 +381,7 @@ public final class io/sentry/android/core/UserInteractionIntegration : android/a
public fun onActivitySaveInstanceState (Landroid/app/Activity;Landroid/os/Bundle;)V
public fun onActivityStarted (Landroid/app/Activity;)V
public fun onActivityStopped (Landroid/app/Activity;)V
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/ViewHierarchyEventProcessor : io/sentry/EventProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import android.os.Bundle;
import io.sentry.Breadcrumb;
import io.sentry.Hint;
import io.sentry.IHub;
import io.sentry.IScopes;
import io.sentry.Integration;
import io.sentry.SentryLevel;
import io.sentry.SentryOptions;
Expand All @@ -23,21 +23,21 @@ public final class ActivityBreadcrumbsIntegration
implements Integration, Closeable, Application.ActivityLifecycleCallbacks {

private final @NotNull Application application;
private @Nullable IHub hub;
private @Nullable IScopes scopes;
private boolean enabled;

public ActivityBreadcrumbsIntegration(final @NotNull Application application) {
this.application = Objects.requireNonNull(application, "Application is required");
}

@Override
public void register(final @NotNull IHub hub, final @NotNull SentryOptions options) {
public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
final SentryAndroidOptions androidOptions =
Objects.requireNonNull(
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
"SentryAndroidOptions is required");

this.hub = Objects.requireNonNull(hub, "Hub is required");
this.scopes = Objects.requireNonNull(scopes, "Scopes are required");
this.enabled = androidOptions.isEnableActivityLifecycleBreadcrumbs();
options
.getLogger()
Expand All @@ -54,8 +54,9 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
public void close() throws IOException {
if (enabled) {
application.unregisterActivityLifecycleCallbacks(this);
if (hub != null) {
hub.getOptions()
if (scopes != null) {
scopes
.getOptions()
.getLogger()
.log(SentryLevel.DEBUG, "ActivityBreadcrumbsIntegration removed.");
}
Expand Down Expand Up @@ -100,7 +101,7 @@ public synchronized void onActivityDestroyed(final @NotNull Activity activity) {
}

private void addBreadcrumb(final @NotNull Activity activity, final @NotNull String state) {
if (hub == null) {
if (scopes == null) {
return;
}

Expand All @@ -114,7 +115,7 @@ private void addBreadcrumb(final @NotNull Activity activity, final @NotNull Stri
final Hint hint = new Hint();
hint.set(ANDROID_ACTIVITY, activity);

hub.addBreadcrumb(breadcrumb, hint);
scopes.addBreadcrumb(breadcrumb, hint);
}

private @NotNull String getActivityName(final @NotNull Activity activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import android.view.View;
import androidx.annotation.NonNull;
import io.sentry.FullyDisplayedReporter;
import io.sentry.IHub;
import io.sentry.IScope;
import io.sentry.IScopes;
import io.sentry.ISpan;
import io.sentry.ITransaction;
import io.sentry.Instrumenter;
Expand Down Expand Up @@ -60,7 +60,7 @@ public final class ActivityLifecycleIntegration

private final @NotNull Application application;
private final @NotNull BuildInfoProvider buildInfoProvider;
private @Nullable IHub hub;
private @Nullable IScopes scopes;
private @Nullable SentryAndroidOptions options;

private boolean performanceEnabled = false;
Expand Down Expand Up @@ -102,13 +102,13 @@ public ActivityLifecycleIntegration(
}

@Override
public void register(final @NotNull IHub hub, final @NotNull SentryOptions options) {
public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
this.options =
Objects.requireNonNull(
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
"SentryAndroidOptions is required");

this.hub = Objects.requireNonNull(hub, "Hub is required");
this.scopes = Objects.requireNonNull(scopes, "Scopes are required");

performanceEnabled = isPerformanceEnabled(this.options);
fullyDisplayedReporter = this.options.getFullyDisplayedReporter();
Expand Down Expand Up @@ -150,10 +150,10 @@ private void stopPreviousTransactions() {

private void startTracing(final @NotNull Activity activity) {
WeakReference<Activity> weakActivity = new WeakReference<>(activity);
if (hub != null && !isRunningTransactionOrTrace(activity)) {
if (scopes != null && !isRunningTransactionOrTrace(activity)) {
if (!performanceEnabled) {
activitiesWithOngoingTransactions.put(activity, NoOpTransaction.getInstance());
TracingUtils.startNewTrace(hub);
TracingUtils.startNewTrace(scopes);
} else {
// as we allow a single transaction running on the bound Scope, we finish the previous ones
stopPreviousTransactions();
Expand Down Expand Up @@ -225,7 +225,7 @@ private void startTracing(final @NotNull Activity activity) {

// we can only bind to the scope if there's no running transaction
ITransaction transaction =
hub.startTransaction(
scopes.startTransaction(
new TransactionContext(
activityName,
TransactionNameSource.COMPONENT,
Expand Down Expand Up @@ -278,7 +278,7 @@ private void startTracing(final @NotNull Activity activity) {
}

// lets bind to the scope so other integrations can pick it up
hub.configureScope(
scopes.configureScope(
scope -> {
applyScope(scope, transaction);
});
Expand Down Expand Up @@ -356,10 +356,10 @@ private void finishTransaction(
status = SpanStatus.OK;
}
transaction.finish(status);
if (hub != null) {
if (scopes != null) {
// make sure to remove the transaction from scope, as it may contain running children,
// therefore `finish` method will not remove it from scope
hub.configureScope(
scopes.configureScope(
scope -> {
clearScope(scope, transaction);
});
Expand All @@ -371,9 +371,9 @@ private void finishTransaction(
public synchronized void onActivityCreated(
final @NotNull Activity activity, final @Nullable Bundle savedInstanceState) {
setColdStart(savedInstanceState);
if (hub != null) {
if (scopes != null) {
final @Nullable String activityClassName = ClassUtil.getClassName(activity);
hub.configureScope(scope -> scope.setScreen(activityClassName));
scopes.configureScope(scope -> scope.setScreen(activityClassName));
}
startTracing(activity);
final @Nullable ISpan ttfdSpan = ttfdSpanMap.get(activity);
Expand Down Expand Up @@ -429,10 +429,10 @@ public void onActivityPrePaused(@NonNull Activity activity) {
// well
// this ensures any newly launched activity will not use the app start timestamp as txn start
firstActivityCreated = true;
if (hub == null) {
if (scopes == null) {
lastPausedTime = AndroidDateUtils.getCurrentSentryDateTime();
} else {
lastPausedTime = hub.getOptions().getDateProvider().now();
lastPausedTime = scopes.getOptions().getDateProvider().now();
}
}
}
Expand All @@ -445,10 +445,10 @@ public synchronized void onActivityPaused(final @NotNull Activity activity) {
// well
// this ensures any newly launched activity will not use the app start timestamp as txn start
firstActivityCreated = true;
if (hub == null) {
if (scopes == null) {
lastPausedTime = AndroidDateUtils.getCurrentSentryDateTime();
} else {
lastPausedTime = hub.getOptions().getDateProvider().now();
lastPausedTime = scopes.getOptions().getDateProvider().now();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.sentry.ILogger;
import io.sentry.ITransactionProfiler;
import io.sentry.NoOpConnectionStatusProvider;
import io.sentry.ScopeType;
import io.sentry.SendFireAndForgetEnvelopeSender;
import io.sentry.SendFireAndForgetOutboxSender;
import io.sentry.SentryLevel;
Expand Down Expand Up @@ -98,6 +99,8 @@ static void loadDefaultAndMetadataOptions(
// Firstly set the logger, if `debug=true` configured, logging can start asap.
options.setLogger(logger);

options.setDefaultScopeType(ScopeType.CURRENT);

options.setDateProvider(new SentryAndroidDateProvider());

// set a lower flush timeout on Android to avoid ANRs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import android.os.Build;
import android.os.Process;
import android.os.SystemClock;
import io.sentry.HubAdapter;
import io.sentry.IHub;
import io.sentry.ILogger;
import io.sentry.IScopes;
import io.sentry.ISentryExecutorService;
import io.sentry.ITransaction;
import io.sentry.ITransactionProfiler;
import io.sentry.PerformanceCollectionData;
import io.sentry.ProfilingTraceData;
import io.sentry.ProfilingTransactionData;
import io.sentry.ScopesAdapter;
import io.sentry.SentryLevel;
import io.sentry.SentryOptions;
import io.sentry.android.core.internal.util.CpuInfoUtils;
Expand Down Expand Up @@ -46,16 +46,16 @@ final class AndroidTransactionProfiler implements ITransactionProfiler {
private long profileStartCpuMillis;

/**
* @deprecated please use a constructor that doesn't takes a {@link IHub} instead, as it would be
* ignored anyway.
* @deprecated please use a constructor that doesn't takes a {@link IScopes} instead, as it would
* be ignored anyway.
*/
@Deprecated
public AndroidTransactionProfiler(
final @NotNull Context context,
final @NotNull SentryAndroidOptions sentryAndroidOptions,
final @NotNull BuildInfoProvider buildInfoProvider,
final @NotNull SentryFrameMetricsCollector frameMetricsCollector,
final @NotNull IHub hub) {
final @NotNull IScopes scopes) {
this(context, sentryAndroidOptions, buildInfoProvider, frameMetricsCollector);
}

Expand Down Expand Up @@ -311,7 +311,7 @@ public void close() {
currentProfilingTransactionData.getTraceId(),
true,
null,
HubAdapter.getInstance().getOptions());
ScopesAdapter.getInstance().getOptions());
} else if (transactionsCounter != 0) {
// in case the app start profiling is running, and it's not bound to a transaction, we still
// stop profiling, but we also have to manually update the counter.
Expand Down
Loading
Loading