Skip to content

Add Node Apollo and GraphQL Integrations #5089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/platforms/node/common/performance/database/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Auto-instrumented:
Opt-in:

- [Prisma ORM](https://www.prisma.io/) _Available from version 7.0.0_
- [GraphQL](https://graphql.org/graphql-js/) _Available from version <TODO: Version>_
- [Apollo Server](https://www.apollographql.com/docs/apollo-server/) _Available from version <TODO: Version>_


## Next Steps

Expand Down
41 changes: 40 additions & 1 deletion src/platforms/node/common/performance/database/opt-in.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,43 @@ Sentry.init({
tracesSampleRate: 1.0,
integrations: [new Tracing.Integrations.Prisma({ client })],
});
```
```

## GraphQL Integration

_(Available from `7.2.0`)_

Sentry supports the tracing GraphQL execution process with an opt-in tracing integration. It creates a `db.graphql` transaction for each GraphQL process that may contain one or more resolvers.

This integration doesn't work on the resolver level, but instead provides a single transaction that covers the whole execution of a GraphQL process.
If you use Apollo Server to define your GraphQL resolvers, Sentry's Apollo Server integration can be combined with this integration to get more precise resolver-level hierarchical tracing data.

For example:

```javascript
import * as Sentry from '@sentry/node';
import * as Tracing from '@sentry/tracing';

Sentry.init({
tracesSampleRate: 1.0,
integrations: [new Tracing.Integrations.GraphQL()],
});
```

## Apollo Server Integration

_(Available from `7.2.0`)_

Sentry provides an opt-in tracing integration for [Apollo resolvers](https://www.apollographql.com/docs/apollo-server/data/resolvers/). It supports nested resolvers, and also works well with the other `@sentry/node` database tracing integrations when there are database operations inside resolvers.

The Apollo integration creates `db.graphql.apollo` spans for each resolver and reports to Sentry with a `description` containing the resolver's name and group:

```javascript
import * as Sentry from '@sentry/node';
import * as Tracing from '@sentry/tracing';

Sentry.init({
tracesSampleRate: 1.0,
integrations: [new Tracing.Integrations.Apollo()],
});
```