---
title: "Apollo 2"
description: "Learn more about the Sentry Apollo 2 integration for the Android SDK."
url: https://docs.sentry.io/platforms/android/integrations/apollo2/
---

# Apollo 2 | Sentry for Android

Capturing transactions requires that you first [set up tracing](https://docs.sentry.io/platforms/android/tracing.md) 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](https://github.com/apollographql/apollo-android) GraphQL client.

This integration supports Apollo 2.x. For Apollo 3.x use our [Apollo 3 integration](https://docs.sentry.io/platforms/android/integrations/apollo3.md). For Apollo 4.x use our [Apollo 4 integration](https://docs.sentry.io/platforms/android/integrations/apollo4.md).

## [Install](https://docs.sentry.io/platforms/android/integrations/apollo2.md#install)

```groovy
implementation 'io.sentry:sentry-apollo:8.39.1'
```

For other dependency managers, see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-apollo).

## [Configure](https://docs.sentry.io/platforms/android/integrations/apollo2.md#configure)

Add `SentryApolloInterceptor` to Apollo builder:

```java
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](https://docs.sentry.io/platforms/android/integrations/apollo2.md#modify-or-drop-spans)

Spans created around requests can be modified or dropped using `SentryApolloInterceptor.BeforeSpanCallback` passed to `SentryApolloInterceptor`:

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