Skip to content

Drizzle ORM

Drizzle ORM has no official OpenTelemetry instrumentation. autotel-drizzle fills the gap.

Terminal window
npm install autotel autotel-drizzle
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { instrumentDrizzleClient } from 'autotel-drizzle';
const queryClient = postgres(process.env.DATABASE_URL!);
const db = drizzle({ client: queryClient });
instrumentDrizzleClient(db, {
dbSystem: 'postgresql',
dbName: 'myapp',
peerName: 'db.example.com',
peerPort: 5432,
captureQueryText: true,
});
// All queries are now traced
await db.select().from(users).where(eq(users.id, 123));
  • PostgreSQL (dbSystem: 'postgresql')
  • MySQL (dbSystem: 'mysql')
  • SQLite / LibSQL (dbSystem: 'sqlite')
OptionDefaultDescription
dbSystemrequired'postgresql' | 'mysql' | 'sqlite'
dbNameDatabase name
captureQueryTextfalseCapture SQL text (may contain PII)
maxQueryTextLength2048Max captured query length
peerNameDatabase hostname
peerPortDatabase port
  • example-drizzle — Drizzle ORM with PostgreSQL, MySQL, and SQLite tracing.

For databases with working official instrumentation, use those directly:

  • PostgreSQL@opentelemetry/instrumentation-pg
  • MySQL@opentelemetry/instrumentation-mysql2

Drizzle itself has no official package, so use autotel-drizzle for the ORM layer.