# OpenFeign Integration | Sentry for Java

Capturing transactions requires that you first [set up tracing](https://docs.sentry.io/platforms/java/tracing.md) if you haven't already.

Sentry OpenFeign integration provides the `SentryFeignClient`, which creates a span for each outgoing HTTP request executed with a [Feign](https://github.com/OpenFeign/feign.md)-based HTTP client.

### [Install](https://docs.sentry.io/.md#install)

```xml
<dependency>
    <groupId>io.sentry</groupId>
    <artifactId>sentry-openfeign</artifactId>
    <version>8.17.0</version>
</dependency>
```

For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-openfeign.md).

## [Configure](https://docs.sentry.io/.md#configure)

Add `SentryCapability` to Feign builder:

```java
import feign.Feign;
import io.sentry.openfeign.SentryCapability;

YourApi api = Feign.builder()
    .addCapability(new SentryCapability())
    ...
    .target(YourApi.class, "https://your-api-host/");
```

## [Modify or Drop Spans](https://docs.sentry.io/.md#modify-or-drop-spans)

Spans created around HTTP requests can be modified or dropped using `SentryFeignClient.BeforeSpanCallback` passed to `SentryCapability`:

```java
import feign.Feign;
import io.sentry.openfeign.SentryCapability;

YourApi api = Feign.builder()
    .addCapability(
        new SentryCapability(
            (span, request, response) -> {
              // modify span or return `null` to drop
              if (request.url().endsWith("/todos")) {
                span.setTag("tag-name", "tag-value");
              }
              return span;
            }))
    ...
    .target(YourApi.class, "https://your-api-host/");
```
