diff --git a/docs/platforms/android/integrations/okhttp/index.mdx b/docs/platforms/android/integrations/okhttp/index.mdx index 003a1c2187e9da..c7335b38012c23 100644 --- a/docs/platforms/android/integrations/okhttp/index.mdx +++ b/docs/platforms/android/integrations/okhttp/index.mdx @@ -302,7 +302,7 @@ private final List failedRequestTargets = Collections.singletonList(".*" private final OkHttpClient client = new OkHttpClient.Builder() .eventListener(new SentryOkHttpEventListener()) .addInterceptor(new SentryOkHttpInterceptor( - Sentry.getCurrentHub(), + Sentry.getCurrentScopes(), null, true, codeRanges, @@ -340,7 +340,7 @@ private final List failedRequestTargets = Collections.singletonList(".*" private final OkHttpClient client = new OkHttpClient.Builder() .eventListener(new SentryOkHttpEventListener()) .addInterceptor(new SentryOkHttpInterceptor( - Sentry.getCurrentHub(), + Sentry.getCurrentScopes(), null, true, codeRanges, @@ -378,7 +378,7 @@ private final List failedRequestTargets = Collections.singletonList("mya private final OkHttpClient client = new OkHttpClient.Builder() .eventListener(new SentryOkHttpEventListener()) .addInterceptor(new SentryOkHttpInterceptor( - Sentry.getCurrentHub(), + Sentry.getCurrentScopes(), null, true, codeRanges, diff --git a/docs/platforms/android/migration/v8-to-v9.mdx b/docs/platforms/android/migration/v8-to-v9.mdx index e1432a2345878e..623ada90f4c857 100644 --- a/docs/platforms/android/migration/v8-to-v9.mdx +++ b/docs/platforms/android/migration/v8-to-v9.mdx @@ -4,7 +4,32 @@ description: "Learn how to migrate from Sentry Android SDK 8.x to 9.0.0." sidebar_order: 8890 --- -Version 9 removes the global Logs and Metrics enable options. Manual telemetry APIs now work whenever the SDK is enabled, while automatic Timber and Logcat capture require their own explicit opt-in. +Version 9 removes the deprecated Hub compatibility APIs and the global Logs and Metrics enable options. Migrate remaining Hub references to Scopes, then update your telemetry configuration. + +## Removed Hub APIs + +Version 8 deprecated Hub and introduced Scopes. Version 9 removes the Hub compatibility layer: + +- `IHub` has been removed. Use `IScopes` instead. +- `HubAdapter.getInstance()` has been removed. Use `ScopesAdapter.getInstance()` instead. +- `HubScopesWrapper` has been removed. Use the wrapped `IScopes` instance directly. +- `NoOpHub.getInstance()` has been removed. Use `NoOpScopes.getInstance()` instead. +- `Sentry.getCurrentHub()` and `Sentry.setCurrentHub(...)` have been removed. Use `Sentry.getCurrentScopes()` and `Sentry.setCurrentScopes(...)` instead. +- `IHub.clone()` and `IScopes.clone()` have been removed. Use `forkedScopes(...)` or `forkedCurrentScope(...)` when you need an independent Scopes instance. For temporary scope changes, use `withScope()` or `withIsolationScope()`. + +### Remove `popScope()` Calls + +`Sentry.popScope()` and `IScopes.popScope()` have been removed. Use `Sentry.withScope()` or `Sentry.withIsolationScope()` for temporary scope changes instead. Both methods restore the previous scopes after the callback finishes. + +### Scopes Model + +The Scopes model introduced in version 8 is the supported context model in version 9: + +- The global scope is attached to all events created by the SDK. To modify it before `SentryAndroid.init()`, call methods directly on `Sentry.getGlobalScope()`, such as `Sentry.getGlobalScope().setTag(...)`. +- The isolation scope attaches data to events within an isolated lifecycle. +- The current scope contains data for the active operation. Child scopes inherit its data, but parent scopes don't receive changes made in a child scope. + +On Android, APIs such as `Sentry.configureScope()` and `Sentry.setTag()` use the current scope by default. ## Manual Logs and Metrics diff --git a/docs/platforms/java/common/migration/8.x-to-9.0.mdx b/docs/platforms/java/common/migration/8.x-to-9.0.mdx index 436907aec025be..220525e0129c33 100644 --- a/docs/platforms/java/common/migration/8.x-to-9.0.mdx +++ b/docs/platforms/java/common/migration/8.x-to-9.0.mdx @@ -4,7 +4,50 @@ description: "Learn how to migrate from version 8.x to 9.0 of the Sentry Java SD sidebar_order: 994 --- -Version 9 removes the global Logs and Metrics enable options. Manual telemetry APIs now work whenever the SDK is enabled, while automatic logging integrations require their own explicit opt-in. +Version 9 removes the deprecated Hub compatibility APIs and the global Logs and Metrics enable options. Migrate remaining Hub references to Scopes, then update your telemetry configuration. + +## Removed Hub APIs + +Version 8 deprecated Hub and introduced Scopes. Version 9 removes the Hub compatibility layer: + +- `IHub` has been removed. Use `IScopes` instead. +- `HubAdapter.getInstance()` has been removed. Use `ScopesAdapter.getInstance()` instead. +- `HubScopesWrapper` has been removed. Use the wrapped `IScopes` instance directly. +- `NoOpHub.getInstance()` has been removed. Use `NoOpScopes.getInstance()` instead. +- `Sentry.getCurrentHub()` and `Sentry.setCurrentHub(...)` have been removed. Use `Sentry.getCurrentScopes()` and `Sentry.setCurrentScopes(...)` instead. +- `IHub.clone()` and `IScopes.clone()` have been removed. Use `forkedScopes(...)` or `forkedCurrentScope(...)` when you need an independent Scopes instance. For temporary scope changes, use `pushScope()`, `pushIsolationScope()`, `withScope()`, or `withIsolationScope()`. +- Spring WebFlux's `SENTRY_HUB_KEY` has been removed. Use `SENTRY_SCOPES_KEY` instead. +- GraphQL's `ExceptionDetails.getHub()` has been removed. Use `ExceptionDetails.getScopes()` instead. + +### Remove `popScope()` Calls + +`Sentry.popScope()` and `IScopes.popScope()` have been removed. Close the lifecycle token returned by `pushScope()` or `pushIsolationScope()` to restore the previous scopes: + +```java +try (ISentryLifecycleToken ignored = Sentry.pushScope()) { + // This block has its own current scope. +} +``` + +Use the same pattern for an isolation scope: + +```java +try (ISentryLifecycleToken ignored = Sentry.pushIsolationScope()) { + // This block has its own isolation scope. +} +``` + +If you can't use try-with-resources, close the token in a `finally` block. + +### Scopes Model + +The Scopes model introduced in version 8 is the supported context model in version 9: + +- The global scope is attached to all events created by the SDK. To modify it before `Sentry.init()`, call methods directly on `Sentry.getGlobalScope()`, such as `Sentry.getGlobalScope().setTag(...)`. +- The isolation scope attaches data to events within an isolated lifecycle, such as an incoming request. The SDK automatically forks this scope for incoming requests, CRON jobs, Spring `@Async`, and other integrations. +- The current scope contains data for the active operation. Child scopes inherit its data, but parent scopes don't receive changes made in a child scope. + +For backend and other JVM applications, APIs such as `Sentry.configureScope()` and `Sentry.setTag()` use the isolation scope by default. ## Manual Logs and Metrics diff --git a/docs/platforms/java/guides/spring/advanced-usage.mdx b/docs/platforms/java/guides/spring/advanced-usage.mdx index 9b0117afbae0f8..15b6d5a068a43b 100644 --- a/docs/platforms/java/guides/spring/advanced-usage.mdx +++ b/docs/platforms/java/guides/spring/advanced-usage.mdx @@ -22,7 +22,7 @@ Configuring this field activates the