Apollo Integration

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();