Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/platforms/android/integrations/okhttp/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private final List<String> failedRequestTargets = Collections.singletonList(".*"
private final OkHttpClient client = new OkHttpClient.Builder()
.eventListener(new SentryOkHttpEventListener())
.addInterceptor(new SentryOkHttpInterceptor(
Sentry.getCurrentHub(),
Sentry.getCurrentScopes(),
null,
true,
codeRanges,
Expand Down Expand Up @@ -340,7 +340,7 @@ private final List<String> failedRequestTargets = Collections.singletonList(".*"
private final OkHttpClient client = new OkHttpClient.Builder()
.eventListener(new SentryOkHttpEventListener())
.addInterceptor(new SentryOkHttpInterceptor(
Sentry.getCurrentHub(),
Sentry.getCurrentScopes(),
null,
true,
codeRanges,
Expand Down Expand Up @@ -378,7 +378,7 @@ private final List<String> failedRequestTargets = Collections.singletonList("mya
private final OkHttpClient client = new OkHttpClient.Builder()
.eventListener(new SentryOkHttpEventListener())
.addInterceptor(new SentryOkHttpInterceptor(
Sentry.getCurrentHub(),
Sentry.getCurrentScopes(),
null,
true,
codeRanges,
Expand Down
27 changes: 26 additions & 1 deletion docs/platforms/android/migration/v8-to-v9.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 44 additions & 1 deletion docs/platforms/java/common/migration/8.x-to-9.0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 15 additions & 15 deletions docs/platforms/java/guides/spring/advanced-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Configuring this field activates the <PlatformLink to="/configuration/options/#d
2. Register the servlet filter bean `SentryUserFilter`:

```java {tabTitle:Java (Spring 5)} {mdExpandTabs}
import io.sentry.IHub;
import io.sentry.IScopes;
import io.sentry.spring.SentryUserFilter;
import io.sentry.spring.SentryUserProvider;
import java.util.List;
Expand All @@ -34,14 +34,14 @@ public class SentryFilterConfig {

@Bean
public SentryUserFilter sentryUserFilter(
final IHub hub, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(hub, sentryUserProviders);
final IScopes scopes, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(scopes, sentryUserProviders);
}
}
```

```java {tabTitle:Java (Spring 6)}
import io.sentry.IHub;
import io.sentry.IScopes;
import io.sentry.spring.jakarta.SentryUserFilter;
import io.sentry.spring.jakarta.SentryUserProvider;
import java.util.List;
Expand All @@ -53,14 +53,14 @@ public class SentryFilterConfig {

@Bean
public SentryUserFilter sentryUserFilter(
final IHub hub, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(hub, sentryUserProviders);
final IScopes scopes, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(scopes, sentryUserProviders);
}
}
```

```java {tabTitle:Java (Spring 7)}
import io.sentry.IHub;
import io.sentry.IScopes;
import io.sentry.spring7.SentryUserFilter;
import io.sentry.spring7.SentryUserProvider;
import java.util.List;
Expand All @@ -72,14 +72,14 @@ public class SentryFilterConfig {

@Bean
public SentryUserFilter sentryUserFilter(
final IHub hub, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(hub, sentryUserProviders);
final IScopes scopes, final List<SentryUserProvider> sentryUserProviders) {
return new SentryUserFilter(scopes, sentryUserProviders);
}
}
```

```kotlin {tabTitle:Kotlin (Spring 5)}
import io.sentry.IHub
import io.sentry.IScopes
import io.sentry.spring.SentryUserProvider
import io.sentry.spring.SentryUserFilter
import org.springframework.context.annotation.Bean
Expand All @@ -88,12 +88,12 @@ import org.springframework.context.annotation.Configuration
@Configuration
class SentryFilterConfig {
@Bean
fun sentryUserFilter(hub: IHub, sentryUserProviders: List<SentryUserProvider>) = SentryUserFilter(hub, sentryUserProviders)
fun sentryUserFilter(scopes: IScopes, sentryUserProviders: List<SentryUserProvider>) = SentryUserFilter(scopes, sentryUserProviders)
}
```

```kotlin {tabTitle:Kotlin (Spring 6)}
import io.sentry.IHub
import io.sentry.IScopes
import io.sentry.spring.jakarta.SentryUserProvider
import io.sentry.spring.jakarta.SentryUserFilter
import org.springframework.context.annotation.Bean
Expand All @@ -102,12 +102,12 @@ import org.springframework.context.annotation.Configuration
@Configuration
class SentryFilterConfig {
@Bean
fun sentryUserFilter(hub: IHub, sentryUserProviders: List<SentryUserProvider>) = SentryUserFilter(hub, sentryUserProviders)
fun sentryUserFilter(scopes: IScopes, sentryUserProviders: List<SentryUserProvider>) = SentryUserFilter(scopes, sentryUserProviders)
}
```

```kotlin {tabTitle:Kotlin (Spring 7)}
import io.sentry.IHub
import io.sentry.IScopes
import io.sentry.spring7.SentryUserProvider
import io.sentry.spring7.SentryUserFilter
import org.springframework.context.annotation.Bean
Expand All @@ -116,7 +116,7 @@ import org.springframework.context.annotation.Configuration
@Configuration
class SentryFilterConfig {
@Bean
fun sentryUserFilter(hub: IHub, sentryUserProviders: List<SentryUserProvider>) = SentryUserFilter(hub, sentryUserProviders)
fun sentryUserFilter(scopes: IScopes, sentryUserProviders: List<SentryUserProvider>) = SentryUserFilter(scopes, sentryUserProviders)
}
```

Expand Down
Loading