From b62f0f5a217c73f39a9ff2ff24bab5eb776591e3 Mon Sep 17 00:00:00 2001 From: Mark Wolff Date: Thu, 14 Nov 2019 11:03:08 -0800 Subject: [PATCH 1/3] chore(docs:postgres): add usage instructions --- .../opentelemetry-plugin-pg/README.md | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md index 985e82bc5f..ab28d731db 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md @@ -17,12 +17,53 @@ npm install --save @opentelemetry/plugin-pg ## Usage +To load all of the [default supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use the below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugsin for unused modules. + +```js +const { NodeTracer } = require('@opentelemetry/node'); + +const tracer = new NodeTracer(); // All default plugins will be used +``` + +If instead you would just load a specific plugin (**pg** in this case), specify it in the `NodeTracer` configuration. + ```js -const opentelemetry = require('@opentelemetry/plugin-pg'); +const { NodeTracer } = require('@opentelemetry/node'); -// TODO: DEMONSTRATE API +const tracer = new NodeTracer({ + plugins: { + pg: { + enabled: true, + // You may use a package name or absolute path to the module + path: '@opentelemetry/plugin-pg', + } + } +}); ``` +If you are using any of the [`pg.Pool`](https://node-postgres.com/api/pool) APIs, you will also need to include the [`pg-pool` plugin](../opentelemetry-plugin-pg-pool). + +```js +const { NodeTracer } = require('@opentelemetry/node'); + +const tracer = new NodeTracer({ + plugins: { + pg: { + enabled: true, + // You may use a package name or absolute path to the module + path: '@opentelemetry/plugin-pg', + }, + 'pg-pool': { + enabled: true, + // You may use a package name or absolute path to the module + path: '@opentelemetry/plugin-pg-pool', + }, + } +}); +``` + +See [examples/postgres](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/postgres) for a short example. + ## Supported Versions - [pg](https://npmjs.com/package/pg): `7.x` From bf39a09ffaacea8b1cf2b5ba3275f7988b7b3243 Mon Sep 17 00:00:00 2001 From: Mark Wolff Date: Thu, 14 Nov 2019 11:22:33 -0800 Subject: [PATCH 2/3] docs: add pg-pool install --- .../opentelemetry-plugin-pg/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md index ab28d731db..71e74a15c8 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md @@ -13,6 +13,7 @@ For automatic instrumentation see the ```bash npm install --save @opentelemetry/plugin-pg +npm install --save @opentelemetry/plugin-pg-pool ``` ## Usage From 0af2c103137ed2716517d2504e0e26c60899e1f9 Mon Sep 17 00:00:00 2001 From: Mark Wolff Date: Thu, 21 Nov 2019 14:35:01 -0800 Subject: [PATCH 3/3] docs: add pg-pool version --- .../opentelemetry-plugin-pg/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md index 71e74a15c8..ba0627c815 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md @@ -68,6 +68,7 @@ See [examples/postgres](https://github.com/open-telemetry/opentelemetry-js/tree/ ## Supported Versions - [pg](https://npmjs.com/package/pg): `7.x` +- [pg-pool](https://npmjs.com/package/pg-pool): `2.x` (Installed by `pg`) ## Useful links - For more information on OpenTelemetry, visit: