From 8711f2b7940c216789649a43b1822b1c8e63d005 Mon Sep 17 00:00:00 2001 From: Xiao Date: Tue, 28 Jan 2020 06:15:03 -0800 Subject: [PATCH] chore: add instruction for pg-pool plugin (#733) * chore: add instruction for pg-pool plugin * chore: update NodeTracer to NodeTracerRegistry * chore: address comments Co-authored-by: Valentin Marchaud Co-authored-by: Daniel Dyla --- packages/opentelemetry-plugin-grpc/README.md | 2 +- packages/opentelemetry-plugin-http/README.md | 2 +- packages/opentelemetry-plugin-https/README.md | 2 +- .../opentelemetry-plugin-ioredis/README.md | 10 +++--- .../opentelemetry-plugin-mongodb/README.md | 2 +- packages/opentelemetry-plugin-mysql/README.md | 10 +++--- .../opentelemetry-plugin-pg-pool/README.md | 33 +++++++++++++++++-- .../opentelemetry-plugin-pg/README.md | 16 ++++----- packages/opentelemetry-plugin-redis/README.md | 2 +- 9 files changed, 53 insertions(+), 26 deletions(-) diff --git a/packages/opentelemetry-plugin-grpc/README.md b/packages/opentelemetry-plugin-grpc/README.md index e728f8e6947..acd3871178b 100644 --- a/packages/opentelemetry-plugin-grpc/README.md +++ b/packages/opentelemetry-plugin-grpc/README.md @@ -35,7 +35,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. ```javascript const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-http/README.md b/packages/opentelemetry-plugin-http/README.md index 59c7fa31e52..375619266f8 100644 --- a/packages/opentelemetry-plugin-http/README.md +++ b/packages/opentelemetry-plugin-http/README.md @@ -36,7 +36,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. ```js const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-https/README.md b/packages/opentelemetry-plugin-https/README.md index a47a71a6caa..3271ff2ba81 100644 --- a/packages/opentelemetry-plugin-https/README.md +++ b/packages/opentelemetry-plugin-https/README.md @@ -36,7 +36,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. ```js const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-ioredis/README.md b/packages/opentelemetry-plugin-ioredis/README.md index 78095ac4e2f..9ccd46aca36 100644 --- a/packages/opentelemetry-plugin-ioredis/README.md +++ b/packages/opentelemetry-plugin-ioredis/README.md @@ -22,9 +22,9 @@ npm install --save @opentelemetry/plugin-ioredis To load a specific plugin (**ioredis** in this case), specify it in the Node Tracer's configuration ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { ioredis: { enabled: true, @@ -35,11 +35,11 @@ const tracer = new NodeTracer({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. ```javascript -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer(); +const registry = new NodeTracerRegistry(); ``` ## Useful links diff --git a/packages/opentelemetry-plugin-mongodb/README.md b/packages/opentelemetry-plugin-mongodb/README.md index e9489b07015..ecccac7fc75 100644 --- a/packages/opentelemetry-plugin-mongodb/README.md +++ b/packages/opentelemetry-plugin-mongodb/README.md @@ -36,7 +36,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. ```js const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-mysql/README.md b/packages/opentelemetry-plugin-mysql/README.md index fb2e08e1835..5aba3e68a33 100644 --- a/packages/opentelemetry-plugin-mysql/README.md +++ b/packages/opentelemetry-plugin-mysql/README.md @@ -24,9 +24,9 @@ OpenTelemetry MySQL Instrumentation allows the user to automatically collect tra To load a specific plugin (**MySQL** in this case), specify it in the Node Tracer's configuration ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { mysql: { enabled: true, @@ -37,11 +37,11 @@ const tracer = new NodeTracer({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer(); +const registry = new NodeTracerRegistry(); ``` See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/mysql) for a short example. diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md index 498830104cf..d831db00b08 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md @@ -12,20 +12,47 @@ For automatic instrumentation see the ## Installation ```bash +npm install --save @opentelemetry/plugin-pg npm install --save @opentelemetry/plugin-pg-pool ``` ## 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 plugins for unused modules. + ```js -const opentelemetry = require('@opentelemetry/plugin-pg-pool'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -// TODO: DEMONSTRATE API +const registry = new NodeTracerRegistry(); // All default plugins will be used ``` +If instead you would just want to load a specific plugin (**pg** and **pg-pool** in this case), specify it in the `NodeTracer` configuration. You'll need to install both plugins for full functionality. + +```js +const { NodeTracerRegistry } = require('@opentelemetry/node'); + +const registry = new NodeTracerRegistry({ + 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-pool): `2.x` +- [pg](https://npmjs.com/package/pg): `7.x` +- [pg-pool](https://npmjs.com/package/pg-pool): `2.x` ## Useful links - For more information on OpenTelemetry, visit: diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md index ba0627c815a..88cc40c2e77 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md @@ -18,20 +18,20 @@ npm install --save @opentelemetry/plugin-pg-pool ## 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. +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 plugins for unused modules. ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer(); // All default plugins will be used +const registry = new NodeTracerRegistry(); // 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. +If instead you would just want to load a specific plugin (**pg** in this case), specify it in the `NodeTracer` configuration. ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { pg: { enabled: true, @@ -45,9 +45,9 @@ const tracer = new NodeTracer({ 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 { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { pg: { enabled: true, diff --git a/packages/opentelemetry-plugin-redis/README.md b/packages/opentelemetry-plugin-redis/README.md index 5751420c8e4..bfb2d1e4783 100644 --- a/packages/opentelemetry-plugin-redis/README.md +++ b/packages/opentelemetry-plugin-redis/README.md @@ -37,7 +37,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use 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 plugins for unused modules. ```javascript const { NodeTracerRegistry } = require('@opentelemetry/node');