8.0.0-alpha.1
Pre-release
Pre-release
Version 8 of the Sentry Android/Java SDK brings a variety of features and fixes. The most notable changes are:
- New
Scopetypes have been introduced, see "Behavioural Changes" for more details. - Lifecycle tokens have been introduced to manage
Scopelifecycle, see "Behavioural Changes" for more details. Hubhas been replaced byScopes
Behavioural Changes
- 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 API likeSentry.setTag()- For Android the type defaults to
CURRENTscope - For Backend and other JVM applicatons 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.
Breaking Changes
Contextsno longer extendsConcurrentHashMap, instead we offer a selected set of methods.
Migration Guide / Deprecations
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 atryblock like this:
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushScope()) {
// this block has its separate current scope
}
as well as:
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.