Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs:postgres): add usage instructions #539

Merged
merged 7 commits into from
Dec 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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',
dyladan marked this conversation as resolved.
Show resolved Hide resolved
},
}
});
```

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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to add supported version of pg-pool here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Added in 0af2c10

Expand Down