Apollo

Learn more about the Sentry Apollo integration for the Android SDK.

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.

Copied
implementation 'io.sentry:sentry-apollo:7.9.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();
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").