0.41.0 • Published 11 days ago

@opentelemetry/instrumentation-pg v0.41.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 days ago

OpenTelemetry Postgres Instrumentation for Node.js

NPM Published Version Apache License

This module provides automatic instrumentation for the pgmodule, which may be loaded using the @opentelemetry/sdk-trace-node package and is included in the @opentelemetry/auto-instrumentations-node bundle.

If total installation size is not constrained, it is recommended to use the @opentelemetry/auto-instrumentations-node bundle with @opentelemetry/sdk-node for the most seamless instrumentation experience.

Compatible with OpenTelemetry JS API and SDK 1.0+.

Installation

npm install --save @opentelemetry/instrumentation-pg

Supported Versions

  • >=8 <9

Usage

const { PgInstrumentation } = require('@opentelemetry/instrumentation-pg');
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [
    new PgInstrumentation(),
  ],
});

PgInstrumentation contains both pg and pg.Pool so it will be instrumented automatically.

See examples/postgres for a short example.

PostgreSQL Instrumentation Options

PostgreSQL instrumentation has few options available to choose from. You can set the following:

OptionsTypeDescription
enhancedDatabaseReportingbooleanIf true, additional information about query parameters and results will be attached (as attributes) to spans representing database operations
requestHookPgInstrumentationExecutionRequestHook (function)Function for adding custom span attributes using information about the query being issued and the db to which it's directed
responseHookPgInstrumentationExecutionResponseHook (function)Function for adding custom span attributes from db response
requireParentSpanbooleanIf true, requires a parent span to create new spans (default false)
addSqlCommenterCommentToQueriesbooleanIf true, adds sqlcommenter specification compliant comment to queries with tracing context (default false). NOTE: A comment will not be added to queries that already contain -- or /* ... */ in them, even if these are not actually part of comments

Useful links

License

Apache 2.0 - See LICENSE for more information.

0.41.0

11 days ago

0.40.0

1 month ago

0.39.1

2 months ago

0.39.0

2 months ago

0.38.0

3 months ago

0.37.2

4 months ago

0.37.1

6 months ago

0.36.2

7 months ago

0.37.0

6 months ago

0.36.1

9 months ago

0.36.0

10 months ago

0.35.3

11 months ago

0.35.2

12 months ago

0.35.1

1 year ago

0.35.0

1 year ago

0.34.1

1 year ago

0.34.0

1 year ago

0.33.0

1 year ago

0.32.0

2 years ago

0.31.1

2 years ago

0.31.0

2 years ago

0.30.0

2 years ago

0.29.0

2 years ago

0.28.0

2 years ago

0.27.0

2 years ago

0.26.0

3 years ago

0.25.0

3 years ago

0.24.0

3 years ago

0.23.0

3 years ago

0.22.0

3 years ago

0.21.0

3 years ago

0.20.0

3 years ago

0.16.0

3 years ago

0.15.0

3 years ago

0.14.0

3 years ago