Skip to content

Commit

Permalink
chore(docs:postgres): add usage instructions (#539)
Browse files Browse the repository at this point in the history
* chore(docs:postgres): add usage instructions

* docs: add pg-pool install

* docs: add pg-pool version

Co-authored-by: Valentin Marchaud <thisismac47@gmail.com>
  • Loading branch information
2 people authored and dyladan committed Dec 26, 2019
1 parent 3ca2df4 commit 093a738
Showing 1 changed file with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://opentelemetry.io/>
Expand Down

0 comments on commit 093a738

Please sign in to comment.