From 093a73826bf4fa2b526c331747e3b33ac86993a5 Mon Sep 17 00:00:00 2001 From: Mark Wolff Date: Thu, 26 Dec 2019 13:35:33 -0500 Subject: [PATCH 1/2] chore(docs:postgres): add usage instructions (#539) * chore(docs:postgres): add usage instructions * docs: add pg-pool install * docs: add pg-pool version Co-authored-by: Valentin Marchaud --- .../opentelemetry-plugin-pg/README.md | 47 ++++++++++++++++++- 1 file changed, 45 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 985e82bc5fa..ba0627c815a 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md @@ -13,19 +13,62 @@ For automatic instrumentation see the ```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 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` +- [pg-pool](https://npmjs.com/package/pg-pool): `2.x` (Installed by `pg`) ## Useful links - For more information on OpenTelemetry, visit: From e859b8e930e121d4226eda7671d096c7ee253b16 Mon Sep 17 00:00:00 2001 From: Mayur Kale Date: Fri, 27 Dec 2019 05:58:24 -0800 Subject: [PATCH 2/2] chore: update plugin readme with example links (#647) --- .../README.md | 2 ++ packages/opentelemetry-plugin-mysql/README.md | 24 +++++++++++++++++-- packages/opentelemetry-plugin-redis/README.md | 2 +- .../README.md | 4 +++- .../opentelemetry-shim-opentracing/README.md | 2 ++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/opentelemetry-plugin-document-load/README.md b/packages/opentelemetry-plugin-document-load/README.md index a3a8d30533a..f9f3ab45251 100644 --- a/packages/opentelemetry-plugin-document-load/README.md +++ b/packages/opentelemetry-plugin-document-load/README.md @@ -57,6 +57,8 @@ Because the browser does not send a trace context header for the initial page na ``` +See [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/tracer-web) for a short example. + ## Useful links - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: diff --git a/packages/opentelemetry-plugin-mysql/README.md b/packages/opentelemetry-plugin-mysql/README.md index 253c22e0d22..fb2e08e1835 100644 --- a/packages/opentelemetry-plugin-mysql/README.md +++ b/packages/opentelemetry-plugin-mysql/README.md @@ -20,12 +20,32 @@ npm install --save @opentelemetry/plugin-mysql ## Usage +OpenTelemetry MySQL Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [mysql](https://www.npmjs.com/package/mysql). + +To load a specific plugin (**MySQL** in this case), specify it in the Node Tracer's configuration +```js +const { NodeTracer } = require('@opentelemetry/node'); + +const tracer = new NodeTracer({ + plugins: { + mysql: { + enabled: true, + // You may use a package name or absolute path to the file. + path: '@opentelemetry/plugin-mysql', + } + } +}); +``` + +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. ```js -const opentelemetry = require('@opentelemetry/plugin-mysql'); +const { NodeTracer } = require('@opentelemetry/node'); -// TODO: DEMONSTRATE API +const tracer = new NodeTracer(); ``` +See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/mysql) for a short example. + ## Useful links - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: diff --git a/packages/opentelemetry-plugin-redis/README.md b/packages/opentelemetry-plugin-redis/README.md index 9c0a44ef441..25f5f62f3f5 100644 --- a/packages/opentelemetry-plugin-redis/README.md +++ b/packages/opentelemetry-plugin-redis/README.md @@ -44,7 +44,7 @@ const { NodeTracer } = require('@opentelemetry/node'); const tracer = new NodeTracer(); ``` - +See [examples/redis](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/redis) for a short example. ## Useful links - For more information on OpenTelemetry, visit: diff --git a/packages/opentelemetry-plugin-xml-http-request/README.md b/packages/opentelemetry-plugin-xml-http-request/README.md index e647c8a6b05..a19f8a7d34c 100644 --- a/packages/opentelemetry-plugin-xml-http-request/README.md +++ b/packages/opentelemetry-plugin-xml-http-request/README.md @@ -25,7 +25,7 @@ const webTracerWithZone = new WebTracer({ scopeManager: new ZoneScopeManager(), plugins: [ new XMLHttpRequestPlugin({ - propagateTraceHeaderCorsUrls: ['http://localhost:8090'] + propagateTraceHeaderCorsUrls: ['http://localhost:8090'] }) ] }); @@ -43,6 +43,8 @@ req.send(); ![Screenshot of the running example](images/request.jpg) ![Screenshot of the running example](images/cors.jpg) +See [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/tracer-web) for a short example. + ## Useful links - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: diff --git a/packages/opentelemetry-shim-opentracing/README.md b/packages/opentelemetry-shim-opentracing/README.md index d6686be1b07..c5a3bec21c2 100644 --- a/packages/opentelemetry-shim-opentracing/README.md +++ b/packages/opentelemetry-shim-opentracing/README.md @@ -34,6 +34,8 @@ opentracing.initGlobalTracer(new TracerShim(tracer)); ``` +See [examples/opentracing-shim](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/opentracing-shim) for a short example. + ## License