From d4b1a2aef60ee74b4e013f951ed1be192c558ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Tue, 11 May 2021 09:40:30 +0200 Subject: [PATCH 1/3] ref: Node DB auto-instrumentation docs --- .../node/common/performance/database.mdx | 53 +++++-------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/src/platforms/node/common/performance/database.mdx b/src/platforms/node/common/performance/database.mdx index 4846fa19751b54..628ffaeef706e0 100644 --- a/src/platforms/node/common/performance/database.mdx +++ b/src/platforms/node/common/performance/database.mdx @@ -2,56 +2,27 @@ title: Database integrations --- -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`: +Node.js has a few integrations that support tracking database queries as Spans. Starting version `6.4.0`, when you are using one of the supported database drivers or ORMs, the integration is installed automatically for you, there is nothing you need to change. -### MongoDB +Supported packages and their integration name are respectively: `pg` (Postgres), `mongodb` (Mongo), `mongoose` (Mongo) and `mysql` (Mysql). -```javascript -const Sentry = require("@sentry/node"); -const Tracing = require("@sentry/tracing"); -const mongodb = require("mongodb"); - -Sentry.init({ - // .... - integrations: [ - // .... - new Tracing.Integrations.Mongo(), // Add this integration - ], - // .... -}); -``` +### Disabling automatic instrumentation -### MySQL / MariaDB +To remove an integration, please refer to our [integrations](/platforms/node/configuration/integrations/#removing-an-integration) docs. -```javascript -const Sentry = require("@sentry/node"); -const Tracing = require("@sentry/tracing"); -const mysql = require("mysql"); - -Sentry.init({ - // .... - integrations: [ - // .... - new Tracing.Integrations.Mysql(), // Add this integration - ], - // .... -}); -``` +### Adding integrations manually -### PostgreSQL +If for some reason you need to add a specific database integration manually (for example when using multiple client instances), you can import them from `@sentry/tracing` package, under `Integrations` namespace. +For example, to add MongoDB instrumentation to a custom client: ```javascript const Sentry = require("@sentry/node"); const Tracing = require("@sentry/tracing"); -const pg = require("pg"); - -Sentry.init({ - // .... - integrations: [ - // .... - new Tracing.Integrations.Postgres(), // Add this integration - ], - // .... +const mongodb = require("mongodb"); + +const client = new Sentry.NodeClient({ + dsn: "___PUBLIC_DSN___", + integrations: [new Tracing.Integrations.Mongo()], }); ``` From b9304f431422fbc88ab5d6e46f88e9194b22a561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Tue, 11 May 2021 17:12:47 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Katie Byers --- src/platforms/node/common/performance/database.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platforms/node/common/performance/database.mdx b/src/platforms/node/common/performance/database.mdx index 628ffaeef706e0..bcf1d4dd612fb4 100644 --- a/src/platforms/node/common/performance/database.mdx +++ b/src/platforms/node/common/performance/database.mdx @@ -2,13 +2,13 @@ title: Database integrations --- -Node.js has a few integrations that support tracking database queries as Spans. Starting version `6.4.0`, when you are using one of the supported database drivers or ORMs, the integration is installed automatically for you, there is nothing you need to change. +Node.js has a few integrations that support tracking database queries as spans. Starting 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 - no additional code necessary. -Supported packages and their integration name are respectively: `pg` (Postgres), `mongodb` (Mongo), `mongoose` (Mongo) and `mysql` (Mysql). +Supported packages and their integration name are, respectively: `pg` (Postgres), `mongodb` (Mongo), `mongoose` (Mongo) and `mysql` (Mysql). ### Disabling automatic instrumentation -To remove an integration, please refer to our [integrations](/platforms/node/configuration/integrations/#removing-an-integration) docs. +To learn how to remove an automatically-enabled integration, please refer to our [integrations](/platforms/node/configuration/integrations/#removing-an-integration) docs. ### Adding integrations manually From 26d2210a44c6c9e13526a9836887837ec88ed5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Wed, 12 May 2021 09:18:19 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Fiona <61481573+PeloWriter@users.noreply.github.com> --- .../node/common/performance/database.mdx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/platforms/node/common/performance/database.mdx b/src/platforms/node/common/performance/database.mdx index bcf1d4dd612fb4..bd0a7249e95fd5 100644 --- a/src/platforms/node/common/performance/database.mdx +++ b/src/platforms/node/common/performance/database.mdx @@ -2,17 +2,21 @@ title: Database integrations --- -Node.js has a few integrations that support tracking database queries as spans. Starting 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 - no additional code necessary. +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. -Supported packages and their integration name are, respectively: `pg` (Postgres), `mongodb` (Mongo), `mongoose` (Mongo) and `mysql` (Mysql). +Supported packages and their integration name: +- `pg` (Postgres) +- `mongodb` (Mongo) +- `mongoose` (Mongo) +- `mysql` (MySQL) -### Disabling automatic instrumentation +### Disabling Automatic Instrumentation -To learn how to remove an automatically-enabled integration, please refer to our [integrations](/platforms/node/configuration/integrations/#removing-an-integration) docs. +You can also (remove an automatically-enabled integration)[integrations](/platforms/node/configuration/integrations/#removing-an-integration), if needed. -### Adding integrations manually +### Manually Adding Integrations -If for some reason you need to add a specific database integration manually (for example when using multiple client instances), you can import them from `@sentry/tracing` package, under `Integrations` namespace. +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. For example, to add MongoDB instrumentation to a custom client: