Skip to content

Commit cd41acb

Browse files
onurtemizkanimatwawanaAbhiPrasad
authored
Add Node Apollo and GraphQL Integrations (#5089)
Co-authored-by: Isabel <[email protected]> Co-authored-by: Abhijeet Prasad <[email protected]>
1 parent d7313bd commit cd41acb

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/platforms/node/common/performance/database/index.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Auto-instrumented:
1717
Opt-in:
1818

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

2124
## Next Steps
2225

src/platforms/node/common/performance/database/opt-in.mdx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,43 @@ Sentry.init({
2626
tracesSampleRate: 1.0,
2727
integrations: [new Tracing.Integrations.Prisma({ client })],
2828
});
29-
```
29+
```
30+
31+
## GraphQL Integration
32+
33+
_(Available from `7.2.0`)_
34+
35+
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.
36+
37+
This integration doesn't work on the resolver level, but instead provides a single transaction that covers the whole execution of a GraphQL process.
38+
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.
39+
40+
For example:
41+
42+
```javascript
43+
import * as Sentry from '@sentry/node';
44+
import * as Tracing from '@sentry/tracing';
45+
46+
Sentry.init({
47+
tracesSampleRate: 1.0,
48+
integrations: [new Tracing.Integrations.GraphQL()],
49+
});
50+
```
51+
52+
## Apollo Server Integration
53+
54+
_(Available from `7.2.0`)_
55+
56+
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.
57+
58+
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:
59+
60+
```javascript
61+
import * as Sentry from '@sentry/node';
62+
import * as Tracing from '@sentry/tracing';
63+
64+
Sentry.init({
65+
tracesSampleRate: 1.0,
66+
integrations: [new Tracing.Integrations.Apollo()],
67+
});
68+
```

0 commit comments

Comments
 (0)