Skip to content

Commit ff6d05a

Browse files
kamilogoreklobsterkatiePeloWriter
authored
ref: Node DB auto-instrumentation docs (#3563)
* ref: Node DB auto-instrumentation docs * Apply suggestions from code review Co-authored-by: Katie Byers <[email protected]> * Apply suggestions from code review Co-authored-by: Fiona <[email protected]> Co-authored-by: Katie Byers <[email protected]> Co-authored-by: Fiona <[email protected]>
1 parent e9e289d commit ff6d05a

File tree

1 file changed

+16
-41
lines changed

1 file changed

+16
-41
lines changed

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

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,31 @@
22
title: Database integrations
33
---
44

5-
Node.js has a few integrations that support tracking database queries as Spans. For now you only need to use the latest version of our SDK and add the specific integration to `Sentry.init`:
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.
66

7-
### MongoDB
7+
Supported packages and their integration name:
8+
- `pg` (Postgres)
9+
- `mongodb` (Mongo)
10+
- `mongoose` (Mongo)
11+
- `mysql` (MySQL)
812

9-
```javascript
10-
const Sentry = require("@sentry/node");
11-
const Tracing = require("@sentry/tracing");
12-
const mongodb = require("mongodb");
13-
14-
Sentry.init({
15-
// ....
16-
integrations: [
17-
// ....
18-
new Tracing.Integrations.Mongo(), // Add this integration
19-
],
20-
// ....
21-
});
22-
```
13+
### Disabling Automatic Instrumentation
2314

24-
### MySQL / MariaDB
15+
You can also (remove an automatically-enabled integration)[integrations](/platforms/node/configuration/integrations/#removing-an-integration), if needed.
2516

26-
```javascript
27-
const Sentry = require("@sentry/node");
28-
const Tracing = require("@sentry/tracing");
29-
const mysql = require("mysql");
30-
31-
Sentry.init({
32-
// ....
33-
integrations: [
34-
// ....
35-
new Tracing.Integrations.Mysql(), // Add this integration
36-
],
37-
// ....
38-
});
39-
```
17+
### Manually Adding Integrations
4018

41-
### PostgreSQL
19+
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.
4220

21+
For example, to add MongoDB instrumentation to a custom client:
4322

4423
```javascript
4524
const Sentry = require("@sentry/node");
4625
const Tracing = require("@sentry/tracing");
47-
const pg = require("pg");
48-
49-
Sentry.init({
50-
// ....
51-
integrations: [
52-
// ....
53-
new Tracing.Integrations.Postgres(), // Add this integration
54-
],
55-
// ....
26+
const mongodb = require("mongodb");
27+
28+
const client = new Sentry.NodeClient({
29+
dsn: "___PUBLIC_DSN___",
30+
integrations: [new Tracing.Integrations.Mongo()],
5631
});
5732
```

0 commit comments

Comments
 (0)