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>6.22.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/");
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- maven:io.sentry:sentry
- Version:
- 6.22.0
- Repository:
- https://github.com/getsentry/sentry-java