---
title: "Reactor Integration"
description: "Learn how to capture errors, breadcrumbs and traces for your reactive applications."
url: https://docs.sentry.io/platforms/java/guides/logback/integrations/reactor/
---

# Reactor Integration | Sentry for Logback

Sentry's [Reactor](https://projectreactor.io/) integration provides a set of utilities to use Sentry with Reactor.

Using the utilities ensures that your errors and traces are always enriched with the correct context and breadcrumbs. Due to how Reactor works under the hood, if you don't use this integration, you might run into issues such as unrelated breadcrumbs appearing in the events that are sent to Sentry within the context of Reactive Streams.

If you're using Spring Boot WebFlux, you just need to install our [Spring Boot SDK](https://docs.sentry.io/platforms/java/guides/spring-boot.md) and the Reactor integration will be automatically configured and enabled under the hood.

Otherwise, read on to learn how to install and use the Sentry Reactor integration.

## [Installation](https://docs.sentry.io/platforms/java/guides/logback/integrations/reactor.md#installation)

To install use:

```groovy
implementation 'io.sentry:sentry-reactor:8.37.1'
```

For other dependency managers, check out the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-reactor).

Make sure your dependencies include `io.micrometer:context-propagation` version `1.0.2` or later, and `io.projectreactor:reactor-core` version `3.5.3` or later, as those are required for the integration to work.

## [Set Up](https://docs.sentry.io/platforms/java/guides/logback/integrations/reactor.md#set-up)

Enable automatic context propagation:

```java
import reactor.core.publisher.Hooks;
// ...
Hooks.enableAutomaticContextPropagation();
```

## [Usage](https://docs.sentry.io/platforms/java/guides/logback/integrations/reactor.md#usage)

Wrap your `Mono` and `Flux` objects using the `SentryReactorUtils.withSentry` function to enable correct capturing of errors, breadcrumbs and traces in the context of your Reactive Streams. This will execute your publisher in the context of *forked current scopes*, which should be the default for most use cases.

For example:

```java
import reactor.core.publisher.Mono;
import io.sentry.Sentry;
import io.sentry.ISpan;
import io.sentry.ITransaction;
import io.sentry.TransactionOptions;

TransactionOptions txOptions = new TransactionOptions();
txOptions.setBindToScope(true);
ITransaction tx = Sentry.startTransaction("Transaction", "op", txOptions);
ISpan child = tx.startChild("Outside Mono", "op")
Sentry.captureMessage("Message outside Mono")
child.finish()
String result = SentryReactorUtils.withSentry(
  Mono.just("hello")
    .map({ (it) ->
      ISpan span = Sentry.getCurrentScopes().transaction.startChild("Inside Mono", "map");
      Sentry.captureMessage("Message inside Mono");
      span.finish();
      return it;
    })
).block();
System.out.println(result);
tx.finish();
```

For more complex use cases, you can also use `SentryReactorUtils.withSentryForkedRoots` to fork the root scopes or `SentryReactorUtils.withSentryScopes` to wrap the operation in arbitrary scopes.

For more information on scopes and scope forking, please consult our [scopes documentation](https://docs.sentry.io/platforms/java/enriching-events/scopes.md).

You can also consult our GitHub repository for practical examples on how to use our Reactor integration with Spring WebFlux with [Spring Boot 2](https://github.com/getsentry/sentry-java/tree/main/sentry-samples/sentry-samples-spring-boot-webflux) and [Spring Boot 3](https://github.com/getsentry/sentry-java/tree/main/sentry-samples/sentry-samples-spring-boot-webflux-jakarta).
