Skip to content

Commit 1bc4bd8

Browse files
authored
Remove references to @sentry/tracing for node performance (#6523)
1 parent 1ad5d48 commit 1bc4bd8

File tree

12 files changed

+55
-76
lines changed

12 files changed

+55
-76
lines changed

src/platform-includes/performance/configure-sample-rate/node.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
```javascript {tabTitle: JavaScript}
22
import * as Sentry from "@sentry/node";
3-
import * as _ from "@sentry/tracing"
4-
// Note: You MUST import the package in some way for tracing to work
53

64
Sentry.init({
75
dsn: "___PUBLIC_DSN___",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`@sentry/node` has tracing enabled by default.

src/platforms/node/common/performance/database/auto-instrument.mdx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,60 @@
11
---
2-
title: Auto-instrumented
2+
title: Auto-discovered
33
---
44

5-
Node.js integrations support tracking database queries as spans. Starting in version `6.4.0`, `@sentry/tracing` will auto-detect supported database drivers or ORMs being used in your project, and automatically enable the relevant integrations with default options - without needing additional code.
5+
Node.js integrations support tracking database queries as spans. `@sentry/node`
6+
can auto-detect supported database drivers or ORMs being used in your project.
67

7-
Supported packages and their integration name:
8+
<Note>
9+
10+
Automatic discovery can fail if your code has been bundled. In that case you
11+
will need to manually add the required integrations.
12+
13+
</Note>
14+
15+
```javascript
16+
const Sentry = require("@sentry/node");
17+
18+
const client = new Sentry.init({
19+
dsn: "___PUBLIC_DSN___",
20+
integrations: [...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations()],
21+
});
22+
```
23+
24+
Supported packages and their integration name:
825
- `pg` (Postgres)
9-
- `pg-native` (Postgres) _Available from version 6.12.0_
26+
- `pg-native` (Postgres)
1027
- `mongodb` (Mongo)
1128
- `mongoose` (Mongo)
1229
- `mysql` (MySQL)
13-
14-
### Disabling Automatic Instrumentation
15-
16-
You can also [remove an automatically-enabled integration](/platforms/node/configuration/integrations/#removing-an-integration), if needed.
30+
- `graphql` (GraphQL)
31+
- `apollo-server-core` (Apollo)
32+
- `@nestjs/graphql` (Apollo)
1733

1834
### Manually Adding Integrations
1935

20-
If you need to add a specific database integration manually (for example, when using multiple client instances), you can import them from the `@sentry/tracing` package under the `Integrations` namespace.
36+
If you need to add a specific database integration manually (for example, when using multiple client instances), you can import them from the `Integrations` namespace.
2137

2238
For example:
2339

2440
```javascript{tabTitle: MongoDB}
2541
const Sentry = require("@sentry/node");
26-
const Tracing = require("@sentry/tracing");
2742
const mongodb = require("mongodb");
2843
29-
const client = new Sentry.NodeClient({
44+
const client = new Sentry.init({
3045
dsn: "___PUBLIC_DSN___",
31-
integrations: [new Tracing.Integrations.Mongo({
46+
integrations: [new Sentry.Integrations.Mongo({
3247
useMongoose: true // Default: false
3348
})],
3449
});
3550
```
3651

3752
```javascript{tabTitle: Postgres}
3853
const Sentry = require("@sentry/node");
39-
const Tracing = require("@sentry/tracing");
4054
41-
const client = new Sentry.NodeClient({
55+
const client = new Sentry.init({
4256
dsn: "___PUBLIC_DSN___",
43-
integrations: [new Tracing.Integrations.Postgres({
57+
integrations: [new Sentry.Integrations.Postgres({
4458
usePgNative: true // Default: false
4559
})],
4660
});

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ Node.js integrations support tracking database queries as spans.
77

88
## Supported Platforms
99

10-
Auto-instrumented:
10+
Auto-discovered:
1111

1212
- `pg` (Postgres)
13-
- `pg-native` (Postgres) _Available from version 6.12.0_
13+
- `pg-native` (Postgres)
1414
- `mongodb` (Mongo)
1515
- `mongoose` (Mongo)
1616
- `mysql` (MySQL)
17+
- `graphql` (GraphQL)
18+
- `apollo-server-core` (Apollo)
19+
- `@nestjs/graphql` (Apollo)
1720

1821
Opt-in:
1922

20-
- [Prisma ORM](https://www.prisma.io/) _Available from version 7.0.0_
21-
- [GraphQL](https://graphql.org/graphql-js/) _Available from version 7.2.0_
22-
- [Apollo Server](https://www.apollographql.com/docs/apollo-server/) _Available from version 7.2.0_
23-
23+
- [Prisma ORM](https://www.prisma.io/)
24+
- [Express](https://expressjs.com/)
2425

2526
## Next Steps
2627

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ For example:
1515
```javascript
1616
import { PrismaClient } from "@prisma/client";
1717
import * as Sentry from "@sentry/node";
18-
import * as Tracing from "@sentry/tracing";
1918

2019
const client = new PrismaClient();
2120

2221
Sentry.init({
2322
dsn: ___PUBLIC_DSN___,
2423
release: "1.0",
2524
tracesSampleRate: 1.0,
26-
integrations: [new Tracing.Integrations.Prisma({ client })],
25+
integrations: [new Sentry.Integrations.Prisma({ client })],
2726
});
2827
```
2928

@@ -40,11 +39,10 @@ For example:
4039

4140
```javascript
4241
import * as Sentry from "@sentry/node";
43-
import * as Tracing from "@sentry/tracing";
4442

4543
Sentry.init({
4644
tracesSampleRate: 1.0,
47-
integrations: [new Tracing.Integrations.GraphQL()],
45+
integrations: [new Sentry.Integrations.GraphQL()],
4846
});
4947
```
5048

@@ -58,18 +56,17 @@ The Apollo integration creates `db.graphql.apollo` spans for each resolver and r
5856

5957
```javascript
6058
import * as Sentry from "@sentry/node";
61-
import * as Tracing from "@sentry/tracing";
6259

6360
Sentry.init({
6461
tracesSampleRate: 1.0,
65-
integrations: [new Tracing.Integrations.Apollo()],
62+
integrations: [new Sentry.Integrations.Apollo()],
6663
});
6764
```
6865

6966
If you use `NestJs`, initialize the integration with the `useNestjs` option
7067

7168
```javascript
72-
new Tracing.Integrations.Apollo({ useNestjs: true });
69+
new Sentry.Integrations.Apollo({ useNestjs: true });
7370
```
7471

7572
**Known Limitation:**

src/platforms/node/common/performance/instrumentation/automatic-instrumentation.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ redirect_from:
88
- /performance/included-instrumentation
99
---
1010

11-
By default, Sentry's Node.js SDK can automatically instrument HTTP calls.
11+
By default, Sentry's Node.js SDK can automatically instrument HTTP calls.
1212
In order for this to work, you have to create transactions which the HTTP calls will be added to as spans.
1313

1414
Read more about [Custom Instrumentation](./../custom-instrumentation/) to learn how to create transactions and add your own spans.
@@ -21,8 +21,6 @@ If you’re adopting Performance in a high-throughput environment, we recommend
2121

2222
```javascript
2323
const Sentry = require("@sentry/node");
24-
const Tracing = require("@sentry/tracing");
25-
// Note: You MUST import the package for tracing to work
2624

2725
Sentry.init({
2826
dsn: "___PUBLIC_DSN___",

src/platforms/node/common/profiling/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ For the Profiling integration to work, you must have the Sentry Node SDK package
1818

1919
```bash
2020
# Using yarn
21-
yarn add @sentry/node @sentry/tracing @sentry/profiling-node
21+
yarn add @sentry/node @sentry/profiling-node
2222

2323
# Using npm
24-
npm install --save @sentry/node @sentry/tracing @sentry/profiling-node
24+
npm install --save @sentry/node @sentry/profiling-node
2525
```
2626

2727
## Enabling Profiling

src/platforms/node/guides/express/index.mdx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,10 @@ app.use(Sentry.Handlers.errorHandler() as express.ErrorRequestHandler);
141141

142142
## Monitor Performance
143143

144-
```bash {tabTitle:npm}
145-
npm install --save @sentry/node @sentry/tracing
146-
```
147-
148-
```bash {tabTitle:Yarn}
149-
yarn add @sentry/node @sentry/tracing
150-
```
151-
152144
It’s possible to add tracing to all popular frameworks; however, we only provide pre-written handlers for Express.
153145

154146
```javascript
155147
const Sentry = require("@sentry/node");
156-
const Tracing = require("@sentry/tracing");
157148
const express = require("express");
158149
const app = express();
159150

@@ -163,7 +154,7 @@ Sentry.init({
163154
// enable HTTP calls tracing
164155
new Sentry.Integrations.Http({ tracing: true }),
165156
// enable Express.js middleware tracing
166-
new Tracing.Integrations.Express({
157+
new Sentry.Integrations.Express({
167158
// to trace all requests to the default router
168159
app,
169160
// alternatively, you can specify the routes you want to trace:

src/platforms/node/guides/express/performance/index.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ If you’re adopting Performance in a high-throughput environment, we recommend
1313

1414
```javascript
1515
const Sentry = require("@sentry/node");
16-
const SentryTracing = require("@sentry/tracing");
1716
const express = require("express");
1817
const app = express();
1918

@@ -23,7 +22,7 @@ Sentry.init({
2322
// enable HTTP calls tracing
2423
new Sentry.Integrations.Http({ tracing: true }),
2524
// enable Express.js middleware tracing
26-
new SentryTracing.Integrations.Express({
25+
new Sentry.Integrations.Express({
2726
// to trace all requests to the default router
2827
app,
2928
// alternatively, you can specify the routes you want to trace:
@@ -112,13 +111,11 @@ app.use(function processItems(req, res, next) {
112111

113112
### Retrieving a Transaction
114113

115-
In cases where you want to attach Spans to an already ongoing Transaction you can use `Sentry.getCurrentHub().getScope().getTransaction()`. This function will return a `Transaction` in case there is a running Transaction otherwise it returns `undefined`. If you are using our Express integration by default we attach the Transaction to the Scope. So you could do something like this:
114+
In cases where you want to attach Spans to an already ongoing Transaction you can use `Sentry.getActiveTransaction()`. This function will return a `Transaction` in case there is a running Transaction otherwise it returns `undefined`. If you are using our Express integration by default we attach the Transaction to the Scope. So you could do something like this:
116115

117116
```javascript
118117
app.get("/success", function successHandler(req, res) {
119-
const transaction = Sentry.getCurrentHub()
120-
.getScope()
121-
.getTransaction();
118+
const transaction = Sentry.getActiveTransaction();
122119

123120
if (transaction) {
124121
let span = transaction.startChild({

src/platforms/node/guides/express/performance/instrumentation/automatic-instrumentation.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ If you’re adopting Performance in a high-throughput environment, we recommend
1313

1414
```javascript
1515
const Sentry = require("@sentry/node");
16-
const SentryTracing = require("@sentry/tracing");
1716
const express = require("express");
1817
const app = express();
1918

@@ -23,7 +22,7 @@ Sentry.init({
2322
// enable HTTP calls tracing
2423
new Sentry.Integrations.Http({ tracing: true }),
2524
// enable Express.js middleware tracing
26-
new SentryTracing.Integrations.Express({
25+
new Sentry.Integrations.Express({
2726
// to trace all requests to the default router
2827
app,
2928
// alternatively, you can specify the routes you want to trace:
@@ -48,4 +47,4 @@ app.use(Sentry.Handlers.tracingHandler());
4847
app.use(Sentry.Handlers.errorHandler());
4948

5049
app.listen(3000);
51-
```
50+
```

src/platforms/node/guides/koa/index.mdx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ description: "Learn about using Sentry with Koa."
99
Add `@sentry/node` as a dependency:
1010

1111
```bash {tabTitle:npm}
12-
npm install --save @sentry/node
12+
npm install --save @sentry/node @sentry/utils
1313
```
1414

1515
```bash {tabTitle:Yarn}
16-
yarn add @sentry/node
16+
yarn add @sentry/node @sentry/utils
1717
```
1818

1919
Initialize the Sentry SDK and install the on error hook:
@@ -42,23 +42,11 @@ app.listen(3000);
4242

4343
## Monitor Performance
4444

45-
```bash {tabTitle:npm}
46-
npm install --save @sentry/node @sentry/tracing
47-
```
48-
49-
```bash {tabTitle:Yarn}
50-
yarn add @sentry/node @sentry/tracing
51-
```
52-
5345
Create and attach a transaction to each request:
5446

5547
```javascript
5648
const Sentry = require("@sentry/node");
57-
const {
58-
extractTraceparentData,
59-
Span,
60-
stripUrlQueryAndFragment,
61-
} = require("@sentry/tracing");
49+
const { stripUrlQueryAndFragment } = require("@sentry/utils");
6250
const Koa = require("koa");
6351
const app = new Koa();
6452
const domain = require("domain");
@@ -106,7 +94,7 @@ const tracingMiddleWare = async (ctx, next) => {
10694
// connect to trace of upstream app
10795
let traceparentData;
10896
if (ctx.request.get("sentry-trace")) {
109-
traceparentData = extractTraceparentData(ctx.request.get("sentry-trace"));
97+
traceparentData = Sentry.extractTraceparentData(ctx.request.get("sentry-trace"));
11098
}
11199

112100
const transaction = Sentry.startTransaction({

src/platforms/node/guides/serverless-cloud/index.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,8 @@ api.use(
113113

114114
## Monitor Performance
115115

116-
```bash {tabTitle:npm}
117-
cloud install --save @sentry/node @sentry/tracing
118-
```
119-
120116
```javascript
121117
const Sentry = require("@sentry/node");
122-
const Tracing = require("@sentry/tracing");
123118
const api = require("@serverless/cloud");
124119

125120
Sentry.init({
@@ -130,7 +125,7 @@ Sentry.init({
130125
// enable HTTP calls tracing
131126
new Sentry.Integrations.Http({ tracing: true }),
132127
// enable Express.js middleware tracing
133-
new Tracing.Integrations.Express({
128+
new Sentry.Integrations.Express({
134129
// to trace all requests to the default router
135130
api,
136131
// alternatively, you can specify the routes you want to trace:

0 commit comments

Comments
 (0)