Apollo3 Integration

Sentry Apollo3 integration provides the SentryApollo3Interceptor and the SentryApollo3HttpInterceptor, which create a span for each outgoing HTTP request executed with an Apollo Kotlin GraphQL client. For easier usage, the integration also provides extension functions on the ApolloClient.Builder.



For other dependency managers, see the central Maven repository.

Configure With Extension

Add Interceptors to ApolloClient.Builder using SentryApolloBuilderExtensions:

import com.apollographql.apollo3.ApolloClient;
import io.sentry.apollo3.SentryApolloBuilderExtensionsKt;

ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing(new ApolloClient.Builder())

Manual Configuration

When using a custom NetworkTransport, the SentryInterceptors need to be added manually, because HttpInterceptors need to be added to the NetworkTransport:

import com.apollographql.apollo3.ApolloClient;
import com.apollographql.apollo3.network.http.HttpNetworkTransport;
import io.sentry.apollo3.SentryApollo3HttpInterceptor;
import io.sentry.apollo3.SentryApollo3Interceptor;

ApolloClient apollo = new ApolloClient.Builder()
            new HttpNetworkTransport.Builder()
                .addInterceptor(new SentryApollo3HttpInterceptor())
        .addInterceptor(new SentryApollo3Interceptor())

Using With Java

Configure Global Hub Mode:

import io.sentry.Sentry;

Sentry.init(options -> {
}, true)

Using With Kotlin Coroutines

To make sure that a coroutine has access to the correct Sentry context, provide an instance of SentryContext when launching a coroutine:

import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.exception.ApolloException
import io.sentry.kotlin.SentryContext
import kotlinx.coroutines.launch

launch(SentryContext()) {
  val response = try {
  } catch (e: ApolloException) {
    // handle protocol errors

Modify or Drop Spans

Spans created around requests can be modified or dropped using SentryApollo3HttpInterceptor.BeforeSpanCallback passed to SentryApollo3HttpInterceptor or the sentryTracing extension function:

import com.apollographql.apollo3.ApolloClient;
import io.sentry.apollo3.SentryApolloBuilderExtensionsKt;

ApolloClient apollo = SentryApolloBuilderExtensionsKt.sentryTracing(
            new ApolloClient.Builder(),
            (span, request, response) -> {
              if ("LaunchDetails".equals(span.getOperation())) {
                span.setTag("tag-name", "tag-value");
              return span;
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").