Apollo 2
Learn more about the Sentry Apollo 2 integration for the Android SDK.
Capturing transactions requires that you first set up tracing 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.
This integration supports Apollo 2.x. For Apollo 3.x use our Apollo 3 integration. For Apollo 4.x use our Apollo 4 integration.
Copied
implementation 'io.sentry:sentry-apollo:8.2.0'
For other dependency managers, see the central Maven repository.
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();
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();
Was this helpful?
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").