Skip to content

Commit 34db09f

Browse files
authored
Merge c2f2cc7 into 619c9b9
2 parents 619c9b9 + c2f2cc7 commit 34db09f

File tree

356 files changed

+10836
-4790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+10836
-4790
lines changed

CHANGELOG.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,71 @@
11
# Changelog
22

3-
43
## Unreleased
54

65
### Features
76

87
- Publish Gradle module metadata ([#3422](https://github.com/getsentry/sentry-java/pull/3422))
8+
- Add data fetching environment hint to breadcrumb for GraphQL (#3413) ([#3431](https://github.com/getsentry/sentry-java/pull/3431))
99

1010
### Fixes
1111

1212
- Fix faulty `span.frame_delay` calculation for early app start spans ([#3427](https://github.com/getsentry/sentry-java/pull/3427))
1313

14+
## 8.0.0-alpha.1
15+
16+
Version 8 of the Sentry Android/Java SDK brings a variety of features and fixes. The most notable changes are:
17+
18+
- New `Scope` types have been introduced, see "Behavioural Changes" for more details.
19+
- Lifecycle tokens have been introduced to manage `Scope` lifecycle, see "Behavioural Changes" for more details.
20+
- `Hub` has been replaced by `Scopes`
21+
22+
### Behavioural Changes
23+
24+
- We're introducing some new `Scope` types in the SDK, allowing for better control over what data is attached where. Previously there was a stack of scopes that was pushed and popped. Instead we now fork scopes for a given lifecycle and then restore the previous scopes. Since `Hub` is gone, it is also never cloned anymore. Separation of data now happens through the different scope types while making it easier to manipulate exactly what you need without having to attach data at the right time to have it apply where wanted.
25+
- Global scope is attached to all events created by the SDK. It can also be modified before `Sentry.init` has been called. It can be manipulated using `Sentry.configureScope(ScopeType.GLOBAL, (scope) -> { ... })`.
26+
- Isolation scope can be used e.g. to attach data to all events that come up while handling an incoming request. It can also be used for other isolation purposes. It can be manipulated using `Sentry.configureScope(ScopeType.ISOLATION, (scope) -> { ... })`. The SDK automatically forks isolation scope in certain cases like incoming requests, CRON jobs, Spring `@Async` and more.
27+
- Current scope is forked often and data added to it is only added to events that are created while this scope is active. Data is also passed on to newly forked child scopes but not to parents.
28+
- `Sentry.popScope` has been deprecated, please call `.close()` on the token returned by `Sentry.pushScope` instead or use it in a way described in more detail in "Migration Guide".
29+
- We have chosen a default scope that is used for `Sentry.configureScope()` as well as API like `Sentry.setTag()`
30+
- For Android the type defaults to `CURRENT` scope
31+
- For Backend and other JVM applicatons it defaults to `ISOLATION` scope
32+
- Event processors on `Scope` can now be ordered by overriding the `getOrder` method on implementations of `EventProcessor`. NOTE: This order only applies to event processors on `Scope` but not `SentryOptions` at the moment. Feel free to request this if you need it.
33+
- `Hub` is deprecated in favor of `Scopes`, alongside some `Hub` relevant APIs. More details can be found in the "Migration Guide" section.
34+
35+
### Breaking Changes
36+
37+
- `Contexts` no longer extends `ConcurrentHashMap`, instead we offer a selected set of methods.
38+
39+
### Migration Guide / Deprecations
40+
41+
- `Hub` has been deprecated, we're replacing the following:
42+
- `IHub` has been replaced by `IScopes`, however you should be able to simply pass `IHub` instances to code expecting `IScopes`, allowing for an easier migration.
43+
- `HubAdapter.getInstance()` has been replaced by `ScopesAdapter.getInstance()`
44+
- The `.clone()` method on `IHub`/`IScopes` has been deprecated, please use `.pushScope()` or `.pushIsolationScope()` instead
45+
- Some internal methods like `.getCurrentHub()` and `.setCurrentHub()` have also been replaced.
46+
- `Sentry.popScope` has been replaced by calling `.close()` on the token returned by `Sentry.pushScope()` and `Sentry.pushIsolationScope()`. The token can also be used in a `try` block like this:
47+
48+
```
49+
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushScope()) {
50+
// this block has its separate current scope
51+
}
52+
```
53+
54+
as well as:
55+
56+
57+
```
58+
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushIsolationScope()) {
59+
// this block has its separate isolation scope
60+
}
61+
```
62+
63+
You may also use `LifecycleHelper.close(token)`, e.g. in case you need to pass the token around for closing later.
64+
65+
### Features
66+
67+
- Report exceptions returned by Throwable.getSuppressed() to Sentry as exception groups ([#3396] https://github.com/getsentry/sentry-java/pull/3396)
68+
1469
## 7.9.0
1570

1671
### Features

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ allprojects {
9999
dependsOn("cleanTest")
100100
}
101101
withType<JavaCompile> {
102-
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing"))
102+
options.compilerArgs.addAll(arrayOf("-Xlint:all", "-Werror", "-Xlint:-classfile", "-Xlint:-processing", "-Xlint:-try"))
103103
}
104104
}
105105
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android.useAndroidX=true
1010
android.defaults.buildfeatures.buildconfig=true
1111

1212
# Release information
13-
versionName=7.9.0
13+
versionName=8.0.0-alpha.1
1414

1515
# Override the SDK name on native crashes on Android
1616
sentryAndroidSdkName=sentry.native.android

sentry-android-core/api/sentry-android-core.api

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public final class io/sentry/android/core/ActivityBreadcrumbsIntegration : andro
88
public fun onActivitySaveInstanceState (Landroid/app/Activity;Landroid/os/Bundle;)V
99
public fun onActivityStarted (Landroid/app/Activity;)V
1010
public fun onActivityStopped (Landroid/app/Activity;)V
11-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
11+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
1212
}
1313

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

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

9393
public final class io/sentry/android/core/AnrIntegrationFactory {
@@ -97,14 +97,15 @@ public final class io/sentry/android/core/AnrIntegrationFactory {
9797

9898
public final class io/sentry/android/core/AnrV2EventProcessor : io/sentry/BackfillingEventProcessor {
9999
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
100+
public fun getOrder ()Ljava/lang/Long;
100101
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
101102
public fun process (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryTransaction;
102103
}
103104

104105
public class io/sentry/android/core/AnrV2Integration : io/sentry/Integration, java/io/Closeable {
105106
public fun <init> (Landroid/content/Context;)V
106107
public fun close ()V
107-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
108+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
108109
}
109110

110111
public final class io/sentry/android/core/AnrV2Integration$AnrV2Hint : io/sentry/hints/BlockingFlushHint, io/sentry/hints/AbnormalExit, io/sentry/hints/Backfillable {
@@ -123,13 +124,13 @@ public final class io/sentry/android/core/AppComponentsBreadcrumbsIntegration :
123124
public fun onConfigurationChanged (Landroid/content/res/Configuration;)V
124125
public fun onLowMemory ()V
125126
public fun onTrimMemory (I)V
126-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
127+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
127128
}
128129

129130
public final class io/sentry/android/core/AppLifecycleIntegration : io/sentry/Integration, java/io/Closeable {
130131
public fun <init> ()V
131132
public fun close ()V
132-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
133+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
133134
}
134135

135136
public final class io/sentry/android/core/AppState {
@@ -177,7 +178,7 @@ public final class io/sentry/android/core/CurrentActivityIntegration : android/a
177178
public fun onActivitySaveInstanceState (Landroid/app/Activity;Landroid/os/Bundle;)V
178179
public fun onActivityStarted (Landroid/app/Activity;)V
179180
public fun onActivityStopped (Landroid/app/Activity;)V
180-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
181+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
181182
}
182183

183184
public final class io/sentry/android/core/DeviceInfoUtil {
@@ -193,7 +194,7 @@ public abstract class io/sentry/android/core/EnvelopeFileObserverIntegration : i
193194
public fun <init> ()V
194195
public fun close ()V
195196
public static fun getOutboxFileObserver ()Lio/sentry/android/core/EnvelopeFileObserverIntegration;
196-
public final fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
197+
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
197198
}
198199

199200
public abstract interface class io/sentry/android/core/IDebugImagesLoader {
@@ -219,23 +220,24 @@ public final class io/sentry/android/core/NdkIntegration : io/sentry/Integration
219220
public static final field SENTRY_NDK_CLASS_NAME Ljava/lang/String;
220221
public fun <init> (Ljava/lang/Class;)V
221222
public fun close ()V
222-
public final fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
223+
public final fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
223224
}
224225

225226
public final class io/sentry/android/core/NetworkBreadcrumbsIntegration : io/sentry/Integration, java/io/Closeable {
226227
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/BuildInfoProvider;Lio/sentry/ILogger;)V
227228
public fun close ()V
228-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
229+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
229230
}
230231

231232
public final class io/sentry/android/core/PhoneStateBreadcrumbsIntegration : io/sentry/Integration, java/io/Closeable {
232233
public fun <init> (Landroid/content/Context;)V
233234
public fun close ()V
234-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
235+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
235236
}
236237

237238
public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor {
238239
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
240+
public fun getOrder ()Ljava/lang/Long;
239241
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
240242
public fun process (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryTransaction;
241243
}
@@ -360,15 +362,15 @@ public final class io/sentry/android/core/SystemEventsBreadcrumbsIntegration : i
360362
public fun <init> (Landroid/content/Context;)V
361363
public fun <init> (Landroid/content/Context;Ljava/util/List;)V
362364
public fun close ()V
363-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
365+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
364366
}
365367

366368
public final class io/sentry/android/core/TempSensorBreadcrumbsIntegration : android/hardware/SensorEventListener, io/sentry/Integration, java/io/Closeable {
367369
public fun <init> (Landroid/content/Context;)V
368370
public fun close ()V
369371
public fun onAccuracyChanged (Landroid/hardware/Sensor;I)V
370372
public fun onSensorChanged (Landroid/hardware/SensorEvent;)V
371-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
373+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
372374
}
373375

374376
public final class io/sentry/android/core/UserInteractionIntegration : android/app/Application$ActivityLifecycleCallbacks, io/sentry/Integration, java/io/Closeable {
@@ -381,11 +383,12 @@ public final class io/sentry/android/core/UserInteractionIntegration : android/a
381383
public fun onActivitySaveInstanceState (Landroid/app/Activity;Landroid/os/Bundle;)V
382384
public fun onActivityStarted (Landroid/app/Activity;)V
383385
public fun onActivityStopped (Landroid/app/Activity;)V
384-
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
386+
public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V
385387
}
386388

387389
public final class io/sentry/android/core/ViewHierarchyEventProcessor : io/sentry/EventProcessor {
388390
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;)V
391+
public fun getOrder ()Ljava/lang/Long;
389392
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
390393
public fun process (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryTransaction;
391394
public static fun snapshotViewHierarchy (Landroid/app/Activity;Lio/sentry/ILogger;)Lio/sentry/protocol/ViewHierarchy;

sentry-android-core/src/main/java/io/sentry/android/core/ActivityBreadcrumbsIntegration.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import android.os.Bundle;
99
import io.sentry.Breadcrumb;
1010
import io.sentry.Hint;
11-
import io.sentry.IHub;
11+
import io.sentry.IScopes;
1212
import io.sentry.Integration;
1313
import io.sentry.SentryLevel;
1414
import io.sentry.SentryOptions;
@@ -23,21 +23,21 @@ public final class ActivityBreadcrumbsIntegration
2323
implements Integration, Closeable, Application.ActivityLifecycleCallbacks {
2424

2525
private final @NotNull Application application;
26-
private @Nullable IHub hub;
26+
private @Nullable IScopes scopes;
2727
private boolean enabled;
2828

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

3333
@Override
34-
public void register(final @NotNull IHub hub, final @NotNull SentryOptions options) {
34+
public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
3535
final SentryAndroidOptions androidOptions =
3636
Objects.requireNonNull(
3737
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
3838
"SentryAndroidOptions is required");
3939

40-
this.hub = Objects.requireNonNull(hub, "Hub is required");
40+
this.scopes = Objects.requireNonNull(scopes, "Scopes are required");
4141
this.enabled = androidOptions.isEnableActivityLifecycleBreadcrumbs();
4242
options
4343
.getLogger()
@@ -54,8 +54,9 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
5454
public void close() throws IOException {
5555
if (enabled) {
5656
application.unregisterActivityLifecycleCallbacks(this);
57-
if (hub != null) {
58-
hub.getOptions()
57+
if (scopes != null) {
58+
scopes
59+
.getOptions()
5960
.getLogger()
6061
.log(SentryLevel.DEBUG, "ActivityBreadcrumbsIntegration removed.");
6162
}
@@ -100,7 +101,7 @@ public synchronized void onActivityDestroyed(final @NotNull Activity activity) {
100101
}
101102

102103
private void addBreadcrumb(final @NotNull Activity activity, final @NotNull String state) {
103-
if (hub == null) {
104+
if (scopes == null) {
104105
return;
105106
}
106107

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

117-
hub.addBreadcrumb(breadcrumb, hint);
118+
scopes.addBreadcrumb(breadcrumb, hint);
118119
}
119120

120121
private @NotNull String getActivityName(final @NotNull Activity activity) {

0 commit comments

Comments
 (0)