kysely-neon
kysely-neon copied to clipboard
Overiding pg functions for instrumentation purposes
Before using the Neon dialect, we were using pg
up front. We had also overridden certain functions for instrumentation purposes. Our implementation looked something like this:
class InstrumentedPool extends pg.Pool {
async connect(...args) {
const _super = super.connect.bind(this);
return withSpan("Database Connect", function () {
return _super(...args);
});
}
}
class InstrumentedClient extends pg.Client {
async query(...args) {
const _super = super.query.bind(this);
return withSpan("Database Query", function (span) {
span.setAttribute("sql", args[0]);
return _super(...args);
});
}
}
const client = new PostgresDialect({
pool: new InstrumentedPool({
Client: InstrumentedClient
})
});
How could we achieve something similar using the Neon dialect? I am a little weak on the Typescript front, so would appreciate any guidance here.