@monocle.sh/instrumentation-kysely traces queries, streams, and transactions. Configure it manually after initializing OpenTelemetry; the Monocle agent does not enable it automatically.
Installation
Supports Kysely^0.28.16 and ^0.29.6. This example uses pg:
Terminal
Configure query tracing
Wrap your dialect withobserveDialect() and set dbSystem to your database type.
app/services/database.ts
Use postgres.js
For postgres.js, usePostgresJSDialect from kysely-postgres-js:
Terminal
app/services/database.ts
dialect to your Kysely instance. OpenTelemetry’s pg instrumentation does not cover postgres.js, so it adds no duplicate spans here.
Control captured data
SQL and errors are recorded by default and may contain sensitive data. Options forobserveDialect():
recordQueryText: false: omit SQL text.recordErrors: false: omit error details while still marking failures.requireParentSpan: true: trace only within an active span.connection: addhost,port, anddatabasedetails.
Pool metrics with pg
After initializing your metrics provider, callregisterPgPoolMetrics() to track used and idle connections, pending requests, and the configured limit. Stop collection before closing the pool:
app/services/database.ts
Pool metrics require
pg.Pool. postgres.js does not expose the pool statistics this helper needs.
Query tracing still works with postgres.js and other Kysely drivers.