Migrate from sentry 7.x to 8.0.0
Learn about migrating from Sentry Android SDK 7.x to 8.0.0.
Contextsno longer extendsConcurrentHashMap, instead we offer a selected set of methods.sentry-android-okhttphas been removed in favor ofsentry-okhttp, making the module independent from Android (#3510)- Calling
Sentry.init()on Android now throws aIllegalArgumentException, please useSentryAndroid.init()instead (#3596) - The previous metrics API has been removed from the SDK (#3774)
- A new Metrics feature is now available. See the Metrics documentation for setup instructions.
enableTracingoption (a.k.aenable-tracing) has been removed from the SDK (#3776)- Please set
tracesSampleRateto a value >= 0.0 for enabling performance instead. The default value isnullwhich means performance is disabled.
- Please set
- Change OkHttp sub-spans to span attributes (#3556)
- This will reduce the number of spans created by the SDK
- Replace
synchronizedmethods and blocks withReentrantLock(AutoClosableReentrantLock) (#3715)- If you are subclassing any Sentry classes, please check if the parent class used
synchronizedbefore. Please make sure to use the same lock object as the parent class in that case.
- If you are subclassing any Sentry classes, please check if the parent class used
traceOriginsoption (io.sentry.traces.tracing-originsin manifest) has been removed, please usetracePropagationTargets(io.sentry.traces.trace-propagation-targetsin manifest`) instead (#3780)profilingEnabledoption (io.sentry.traces.profiling.enablein manifest) has been removed, please useprofilesSampleRate(io.sentry.traces.profiling.sample-ratein manifest) instead (#3780)- Please set
profileSampleRateto a value >= 0.0 for enabling profiling instead. The default value isnullwhich means profiling is disabled.
- Please set
shutdownTimeoutoption has been removed, please useshutdownTimeoutMillisinstead (#3780)profilingTracesIntervalMillisoption for Android has been removed (#3780)io.sentry.session-tracking.enablemanifest option has been removed (#3780)Sentry.traceHeaders()method has been removed, please useSentry.getTraceparent()instead (#3718)Sentry.reportFullDisplayed()method has been removed, please useSentry.reportFullyDisplayed()instead (#3717)User.otherhas been removed, please usedatainstead (#3780)SdkVersion.getIntegrations()has been removed, please usegetIntegrationSetinstead (#3780)SdkVersion.getPackages()has been removed, please usegetPackageSet()instead (#3780)Device.languagehas been removed, please uselocaleinstead (#3780)TraceContext.userandTraceContextUserclass have been removed, please useuserIdonTraceContextinstead (#3780)TransactionContext.fromSentryTrace()has been removed, please useSentry.continueTrace()instead (#3780)SentryDataFetcherExceptionHandlerhas been removed, please useSentryGenericDataFetcherExceptionHandlerin combination withSentryInstrumentationinstead (#3780)- One of the
AndroidTransactionProfilerconstructors has been removed, please use a different one (#3780) - Use String instead of UUID for SessionId (#3834)
- The
Sessionconstructor now takes aStringinstead of aUUIDfor thesessionIdparameter. Session.getSessionId()now returns aStringinstead of aUUID.
- The
- The Android minSdk level for all Android modules is now 21 (#3852) (#3851)
- All status codes below 400 are now mapped to
SpanStatus.OK(#3869) transaction.datahas moved fromextratocontexts.trace.data(#3735)- If you were filtering data in e.g.
beforeSendTransactionplease update accordingly
- If you were filtering data in e.g.
Hubhas been deprecated, we're replacing the following:IHubhas been replaced byIScopes, however you should be able to simply passIHubinstances to code expectingIScopes, allowing for an easier migration.HubAdapter.getInstance()has been replaced byScopesAdapter.getInstance()- The
.clone()method onIHub/IScopeshas been deprecated, please use.pushScope()or.pushIsolationScope()instead - Some internal methods like
.getCurrentHub()and.setCurrentHub()have also been replaced.
Sentry.popScopehas been replaced by calling.close()on the token returned bySentry.pushScope()andSentry.pushIsolationScope(). The token can also be used in atry-with-resourceblock like this:
Copied
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushScope()) {
// this block has its separate current scope
}
as well as:
Copied
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushIsolationScope()) {
// this block has its separate isolation scope
}
You may also use LifecycleHelper.close(token), e.g. in case you need to pass the token around for closing later.
- We're introducing some new
Scopetypes 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. SinceHubis 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.- Global scope is attached to all events created by the SDK. It can also be modified before
Sentry.inithas been called. It can be manipulated usingSentry.configureScope(ScopeType.GLOBAL, (scope) -> { ... }). - 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@Asyncand more. - 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.
- Global scope is attached to all events created by the SDK. It can also be modified before
Sentry.popScopehas been deprecated, please call.close()on the token returned bySentry.pushScopeinstead or use it in a way described in more detail in "Migration Guide".- We have chosen a default scope that is used for
Sentry.configureScope()as well as for APIs likeSentry.setTag()- For Android the type defaults to
CURRENTscope - For Backend and other JVM applications it defaults to
ISOLATIONscope
- For Android the type defaults to
- Event processors on
Scopecan now be ordered by overriding thegetOrdermethod on implementations ofEventProcessor. NOTE: This order only applies to event processors onScopebut notSentryOptionsat the moment. Feel free to request this if you need it. Hubis deprecated in favor ofScopes, alongside someHubrelevant APIs. More details can be found in the "Migration Guide" section.- (Android) The JNI layer for sentry-native has now been moved from sentry-java to sentry-native (#3189)
- This now includes prefab support for sentry-native, allowing you to link and access the sentry-native API within your native app code
- Checkout the
sentry-samples/sentry-samples-androidexample on how to configure CMake and consumesentry.h
- (Android) Replace thread id with kernel thread id in span data (#3706)
- (Android) Enable Performance V2 by default (#3824)
- With this change cold app start spans will include spans for ContentProviders, Application and Activity load.
- The required Sentry version in version
8.0.0of the SDK remains unchanged. Sentry's version >= v22.12.0 is required. This only applies to self-hosted Sentry. If you are using sentry.io, no action is needed.
You must use Sentry Gradle plugin 5.+ together with the Sentry Android SDK 8.+ otherwise, it might crash at runtime due to missing dependencies.
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").