Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 908 Bytes

File metadata and controls

36 lines (26 loc) · 908 Bytes

zipkin-instrumentation-postgres

npm

This library will wrap the pg client.

Usage

const {Tracer} = require('zipkin');
const Postgres = require('pg');
const zipkinClient = require('zipkin-instrumentation-postgres');

const tracer = new Tracer({ctxImpl, recorder}); // configure your tracer properly here

const ZipkinPostgres = zipkinClient(tracer, Postgres);

const connectionOptions = {
  user: 'postgres',
  password: 'secret',
  host: 'localhost',
  database: 'mydb'
};

const client = new ZipkinPostgres.Client(connectionOptions);
const pool = new ZipkinPostgres.Pool(connectionOptions);

// Your application code here
client.query('SELECT NOW()', (err, result) => {
  console.log(err, result);
});

pool.query('SELECT NOW()')
  .then(console.log)
  .catch(console.error);