Apollo Integration
Capturing transactions requires that you first set up performance monitoring if you haven't already.
Sentry Apollo integration provides the SentryApolloInterceptor
, which creates a span for each outgoing HTTP request executed with an Apollo Android GraphQL client.
Install
Copied
implementation 'io.sentry:sentry-apollo:7.13.0'
For other dependency managers, see the central Maven repository.
Configure
Add SentryApolloInterceptor
to Apollo builder:
Copied
import com.apollographql.apollo.ApolloClient;
import io.sentry.apollo.SentryApolloInterceptor;
ApolloClient apollo = ApolloClient.builder()
.serverUrl("https://your-api-host/")
.addApplicationInterceptor(new SentryApolloInterceptor())
.build();
Modify or Drop Spans
Spans created around requests can be modified or dropped using SentryApolloInterceptor.BeforeSpanCallback
passed to SentryApolloInterceptor
:
Copied
import com.apollographql.apollo.ApolloClient;
import io.sentry.apollo.SentryApolloInterceptor;
ApolloClient apollo = ApolloClient.builder()
.serverUrl("https://your-api-host/")
.addApplicationInterceptor(new SentryApolloInterceptor(
(span, request, response) -> {
if ("aQuery".equals(request.operation.name().name())) {
span.setTag("tag-name", "tag-value");
}
return span;
}
))
.build();
- Package:
- maven:io.sentry:sentry-android
- Version:
- 7.13.0
- Repository:
- https://github.com/getsentry/sentry-java