OpenFeign Integration
Learn how to capture tracing information of OpenFeign-based HTTP clients.
Capturing transactions requires that you first set up tracing 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.
Copied
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-openfeign</artifactId>
<version>7.18.1</version>
</dependency>
For other dependency managers see the central Maven repository.
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/");
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!) or 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!) or suggesting an update ("yeah, this would be better").