Skip to content

Commit 66af8c8

Browse files
adinauerlblodermarkushi
authored
Add migration guide for Android SDK 7 to 8 upgrade (#11853)
* Add migration guide for Java SDK 7 to 8 upgrade * update wording on spring boot otel agent combo * Apply suggestions from code review Co-authored-by: Lukas Bloder <[email protected]> * CR changes * Add migration guide for Android SDK 7 to 8 upgrade * Apply suggestions from code review Co-authored-by: Markus Hintersteiner <[email protected]> --------- Co-authored-by: Lukas Bloder <[email protected]> Co-authored-by: Markus Hintersteiner <[email protected]>
1 parent 865cf9e commit 66af8c8

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

docs/platforms/android/migration/index.mdx

+88
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,94 @@ sidebar_order: 8000
44
description: "Migrating between versions of Sentry's SDK for Android."
55
---
66

7+
## Migrating from `io.sentry:sentry` `7.x` to `io.sentry:sentry` `8.0.0`
8+
9+
### Breaking Changes
10+
11+
- `Contexts` no longer extends `ConcurrentHashMap`, instead we offer a selected set of methods.
12+
- `sentry-android-okhttp` has been removed in favor of `sentry-okhttp`, making the module independent from Android ([#3510](https://github.com/getsentry/sentry-java/pull/3510))
13+
- Calling `Sentry.init()` on Android now throws a `IllegalArgumentException`, please use `SentryAndroid.init()` instead ([#3596](https://github.com/getsentry/sentry-java/pull/3596))
14+
- Metrics have been removed from the SDK ([#3774](https://github.com/getsentry/sentry-java/pull/3774))
15+
- Metrics will return but we don't know in what exact form yet
16+
- `enableTracing` option (a.k.a `enable-tracing`) has been removed from the SDK ([#3776](https://github.com/getsentry/sentry-java/pull/3776))
17+
- Please set `tracesSampleRate` to a value >= 0.0 for enabling performance instead. The default value is `null` which means performance is disabled.
18+
- Change OkHttp sub-spans to span attributes ([#3556](https://github.com/getsentry/sentry-java/pull/3556))
19+
- This will reduce the number of spans created by the SDK
20+
- Replace `synchronized` methods and blocks with `ReentrantLock` (`AutoClosableReentrantLock`) ([#3715](https://github.com/getsentry/sentry-java/pull/3715))
21+
- If you are subclassing any Sentry classes, please check if the parent class used `synchronized` before. Please make sure to use the same lock object as the parent class in that case.
22+
- `traceOrigins` option (`io.sentry.traces.tracing-origins` in manifest) has been removed, please use `tracePropagationTargets` (`io.sentry.traces.trace-propagation-targets` in manifest`) instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
23+
- `profilingEnabled` option (`io.sentry.traces.profiling.enable` in manifest) has been removed, please use `profilesSampleRate` (`io.sentry.traces.profiling.sample-rate` in manifest) instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
24+
- Please set `profileSampleRate` to a value >= 0.0 for enabling profiling instead. The default value is `null` which means profiling is disabled.
25+
- `shutdownTimeout` option has been removed, please use `shutdownTimeoutMillis` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
26+
- `profilingTracesIntervalMillis` option for Android has been removed ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
27+
- `io.sentry.session-tracking.enable` manifest option has been removed ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
28+
- `Sentry.traceHeaders()` method has been removed, please use `Sentry.getTraceparent()` instead ([#3718](https://github.com/getsentry/sentry-java/pull/3718))
29+
- `Sentry.reportFullDisplayed()` method has been removed, please use `Sentry.reportFullyDisplayed()` instead ([#3717](https://github.com/getsentry/sentry-java/pull/3717))
30+
- `User.other` has been removed, please use `data` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
31+
- `SdkVersion.getIntegrations()` has been removed, please use `getIntegrationSet` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
32+
- `SdkVersion.getPackages()` has been removed, please use `getPackageSet()` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
33+
- `Device.language` has been removed, please use `locale` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
34+
- `TraceContext.user` and `TraceContextUser` class have been removed, please use `userId` on `TraceContext` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
35+
- `TransactionContext.fromSentryTrace()` has been removed, please use `Sentry.continueTrace()` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
36+
- `SentryDataFetcherExceptionHandler` has been removed, please use `SentryGenericDataFetcherExceptionHandler` in combination with `SentryInstrumentation` instead ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
37+
- One of the `AndroidTransactionProfiler` constructors has been removed, please use a different one ([#3780](https://github.com/getsentry/sentry-java/pull/3780))
38+
- Use String instead of UUID for SessionId ([#3834](https://github.com/getsentry/sentry-java/pull/3834))
39+
- The `Session` constructor now takes a `String` instead of a `UUID` for the `sessionId` parameter.
40+
- `Session.getSessionId()` now returns a `String` instead of a `UUID`.
41+
- The Android minSdk level for all Android modules is now 21 ([#3852](https://github.com/getsentry/sentry-java/pull/3852)) ([#3851](https://github.com/getsentry/sentry-java/pull/3851))
42+
- All status codes below 400 are now mapped to `SpanStatus.OK` ([#3869](https://github.com/getsentry/sentry-java/pull/3869))
43+
- `transaction.data` has moved from `extra` to `contexts.trace.data` (#3735)
44+
- If you were filtering data in e.g. `beforeSendTransaction` please update accordingly
45+
46+
### Deprecations
47+
48+
- `Hub` has been deprecated, we're replacing the following:
49+
- `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.
50+
- `HubAdapter.getInstance()` has been replaced by `ScopesAdapter.getInstance()`
51+
- The `.clone()` method on `IHub`/`IScopes` has been deprecated, please use `.pushScope()` or `.pushIsolationScope()` instead
52+
- Some internal methods like `.getCurrentHub()` and `.setCurrentHub()` have also been replaced.
53+
- `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-with-resource` block like this:
54+
55+
```
56+
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushScope()) {
57+
// this block has its separate current scope
58+
}
59+
```
60+
61+
as well as:
62+
63+
64+
```
65+
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushIsolationScope()) {
66+
// this block has its separate isolation scope
67+
}
68+
```
69+
70+
You may also use `LifecycleHelper.close(token)`, e.g. in case you need to pass the token around for closing later.
71+
72+
### Behavioral Changes
73+
74+
- 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.
75+
- 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) -> { ... })`.
76+
- 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.
77+
- 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.
78+
- `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".
79+
- We have chosen a default scope that is used for `Sentry.configureScope()` as well as for APIs like `Sentry.setTag()`
80+
- For Android the type defaults to `CURRENT` scope
81+
- For Backend and other JVM applicatons it defaults to `ISOLATION` scope
82+
- 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.
83+
- `Hub` is deprecated in favor of `Scopes`, alongside some `Hub` relevant APIs. More details can be found in the "Migration Guide" section.
84+
- (Android) The JNI layer for sentry-native has now been moved from sentry-java to sentry-native ([#3189](https://github.com/getsentry/sentry-java/pull/3189))
85+
- This now includes prefab support for sentry-native, allowing you to link and access the sentry-native API within your native app code
86+
- Checkout the `sentry-samples/sentry-samples-android` example on how to configure CMake and consume `sentry.h`
87+
- (Android) Replace thread id with kernel thread id in span data ([#3706](https://github.com/getsentry/sentry-java/pull/3706))
88+
- (Android) Enable Performance V2 by default ([#3824](https://github.com/getsentry/sentry-java/pull/3824))
89+
- With this change cold app start spans will include spans for ContentProviders, Application and Activity load.
90+
91+
### Sentry Self-hosted Compatibility
92+
93+
- The required Sentry version in version `8.0.0` of the SDK remains unchanged. [Sentry's version >= v22.12.0](https://github.com/getsentry/self-hosted/releases) is required. This only applies to self-hosted Sentry. If you are using [sentry.io](https://sentry.io), no action is needed.
94+
795
## Migration from `io.sentry:sentry-android-gradle-plugin:3.x.x` to `io.sentry:sentry-android-gradle-plugin:4.0.0`
896

997
### Breaking Changes

0 commit comments

Comments
 (0)