OpenFeign Integration
Capturing transactions requires that you first set up performance monitoring if you haven't already.
Sentry OpenFeign integration provides the SentryFeignClient
, which creates a span for each outgoing HTTP request executed with a Feign-based HTTP client.
Install
Copied
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-openfeign</artifactId>
<version>7.13.0</version>
</dependency>
For other dependency managers see the central Maven repository.
Configure
Add SentryCapability
to Feign builder:
Copied
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
Spans created around HTTP requests can be modified or dropped using SentryFeignClient.BeforeSpanCallback
passed to SentryCapability
:
Copied
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/");
- Package:
- maven:io.sentry:sentry
- Version:
- 7.13.0
- Repository:
- https://github.com/getsentry/sentry-java