autotel-plugins 0.19.2 → 0.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/common/constants.ts","../src/drizzle/index.ts"],"names":["trace","SpanKind","runWithSpan","finalizeSpan","tracerName","dbSystem","dbName","captureQueryText","maxQueryTextLength","peerName","peerPort","tracer","instrumented"],"mappings":";;;;;;;;AAMO,IAAM,kBAAA,GAAqB,WAAA;AAE3B,IAAM,qBAAA,GAAwB,cAAA;AAC9B,IAAM,qBAAA,GAAwB,cAAA;AAC9B,IAAM,gBAAA,GAAmB,SAAA;AAWzB,IAAM,sBAAA,GAAyB,eAAA;AAC/B,IAAM,sBAAA,GAAyB,eAAA;ACRtC,IAAM,mBAAA,GAAsB,yBAAA;AAC5B,IAAM,iBAAA,GAAoB,YAAA;AAC1B,IAAM,iBAAA,GAAoB,8BAAA;AA6D1B,SAAS,iBAAiB,QAAA,EAAuC;AAC/D,EAAA,IAAI,OAAO,aAAa,QAAA,EAAU;AAChC,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,IAAI,QAAA,IAAY,OAAO,QAAA,KAAa,QAAA,EAAU;AAE5C,IAAA,IAAI,OAAQ,QAAA,CAA+B,GAAA,KAAQ,QAAA,EAAU;AAC3D,MAAA,OAAQ,QAAA,CAA6B,GAAA;AAAA,IACvC;AAEA,IAAA,IAAI,OAAQ,QAAA,CAAgC,IAAA,KAAS,QAAA,EAAU;AAC7D,MAAA,OAAQ,QAAA,CAA8B,IAAA;AAAA,IACxC;AAEA,IAAA,IACE,OAAQ,QAAA,CAAuC,WAAA,KAAgB,QAAA,EAC/D;AAEA,MAAA,MAAM,YAAA,GAAe,QAAA;AACrB,MAAA,IAAI,OAAO,YAAA,CAAa,GAAA,KAAQ,QAAA,EAAU;AACxC,QAAA,OAAO,YAAA,CAAa,GAAA;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACA,EAA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SAAAA,EAAU;AACZ,QAAA,IAAA,CAAK,YAAA,CAAa,wBAAwBA,SAAQ,CAAA;AAAA,MACpD;AAEA,MAAA,IAAIC,SAAAA,EAAU;AACZ,QAAA,IAAA,CAAK,YAAA,CAAa,wBAAwBA,SAAQ,CAAA;AAAA,MACpD;AAGA,MAAA,OAAOR,wBAAA,CAAY,MAAM,MAAM;AAC7B,QAAA,IAAI;AACF,UAAA,MAAM,MAAA,GAAS,eAAA,CAAgB,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA;AAC/C,UAAA,OAAO,QAAQ,OAAA,CAAQ,MAAM,CAAA,CAC1B,IAAA,CAAK,CAAC,KAAA,KAAU;AACf,YAAAC,yBAAA,CAAa,IAAI,CAAA;AACjB,YAAA,OAAO,KAAA;AAAA,UACT,CAAC,CAAA,CACA,KAAA,CAAM,CAAC,KAAA,KAAU;AAChB,YAAAA,yBAAA,CAAa,MAAM,KAAK,CAAA;AACxB,YAAA,MAAM,KAAA;AAAA,UACR,CAAC,CAAA;AAAA,QACL,SAAS,KAAA,EAAO;AACd,UAAAA,yBAAA,CAAa,MAAM,KAAK,CAAA;AACxB,UAAA,MAAM,KAAA;AAAA,QACR;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAA;AAEA,IAAA,OAAA,CAAQ,iBAAiB,CAAA,GAAI,IAAA;AAC7B,IAAA,OAAA,CAAQ,OAAA,GAAU,mBAAA;AAClB,IAAA,YAAA,GAAe,IAAA;AAAA,EACjB;AAGA,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,EAAA,CAAG,iBAAiB,CAAA,GAAI,IAAA;AAAA,EAC1B;AAEA,EAAA,OAAO,EAAA;AACT","file":"drizzle.cjs","sourcesContent":["/**\n * OpenTelemetry semantic conventions for database operations.\n * These constants are shared across all plugins.\n */\n\n// Common database attributes\nexport const SEMATTRS_DB_SYSTEM = 'db.system' as const;\nexport const SEMATTRS_DB_SYSTEM_NAME = 'db.system.name' as const;\nexport const SEMATTRS_DB_OPERATION = 'db.operation' as const;\nexport const SEMATTRS_DB_STATEMENT = 'db.statement' as const;\nexport const SEMATTRS_DB_NAME = 'db.name' as const;\nexport const SEMATTRS_DB_NAMESPACE = 'db.namespace' as const;\nexport const SEMATTRS_DB_COLLECTION_NAME = 'db.collection.name' as const;\nexport const SEMATTRS_DB_OPERATION_NAME = 'db.operation.name' as const;\nexport const SEMATTRS_DB_QUERY_TEXT = 'db.query.text' as const;\nexport const SEMATTRS_DB_QUERY_SUMMARY = 'db.query.summary' as const;\n\n// MongoDB-specific attributes\nexport const SEMATTRS_DB_MONGODB_COLLECTION = 'db.mongodb.collection' as const;\n\n// Network attributes\nexport const SEMATTRS_NET_PEER_NAME = 'net.peer.name' as const;\nexport const SEMATTRS_NET_PEER_PORT = 'net.peer.port' as const;\n\n// Messaging attributes (Kafka, etc.)\nexport const SEMATTRS_MESSAGING_SYSTEM = 'messaging.system' as const;\nexport const SEMATTRS_MESSAGING_DESTINATION_NAME =\n 'messaging.destination.name' as const;\nexport const SEMATTRS_MESSAGING_OPERATION = 'messaging.operation' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_CONSUMER_GROUP =\n 'messaging.kafka.consumer.group' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_PARTITION =\n 'messaging.kafka.partition' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_OFFSET =\n 'messaging.kafka.offset' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_MESSAGE_KEY =\n 'messaging.kafka.message.key' as const;\n\n// Batch lineage attributes\nexport const SEMATTRS_LINKED_TRACE_ID_COUNT = 'linked_trace_id_count' as const;\nexport const SEMATTRS_LINKED_TRACE_ID_HASH = 'linked_trace_id_hash' as const;\n\n// Correlation ID header name\nexport const CORRELATION_ID_HEADER = 'x-correlation-id' as const;\n\n// BigQuery-specific attributes (namespaced under gcp.bigquery per OTel spec)\nexport const SEMATTRS_GCP_BIGQUERY_JOB_ID = 'gcp.bigquery.job.id' as const;\nexport const SEMATTRS_GCP_BIGQUERY_JOB_LOCATION =\n 'gcp.bigquery.job.location' as const;\nexport const SEMATTRS_GCP_BIGQUERY_PROJECT_ID =\n 'gcp.bigquery.project.id' as const;\nexport const SEMATTRS_GCP_BIGQUERY_DESTINATION_TABLE =\n 'gcp.bigquery.destination.table' as const;\nexport const SEMATTRS_GCP_BIGQUERY_SOURCE_TABLES =\n 'gcp.bigquery.source.tables' as const;\nexport const SEMATTRS_GCP_BIGQUERY_STATEMENT_TYPE =\n 'gcp.bigquery.statement_type' as const;\nexport const SEMATTRS_GCP_BIGQUERY_QUERY_HASH =\n 'gcp.bigquery.query.hash' as const;\nexport const SEMATTRS_GCP_BIGQUERY_ROWS_AFFECTED =\n 'gcp.bigquery.rows.affected' as const;\nexport const SEMATTRS_GCP_BIGQUERY_ROWS_RETURNED =\n 'gcp.bigquery.rows.returned' as const;\nexport const SEMATTRS_GCP_BIGQUERY_SCHEMA_FIELDS =\n 'gcp.bigquery.schema.fields' as const;\n\n// RabbitMQ-specific attributes (aligned with OTel messaging semantic conventions)\nexport const SEMATTRS_MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY =\n 'messaging.rabbitmq.destination.routing_key' as const;\nexport const SEMATTRS_MESSAGING_RABBITMQ_DESTINATION_EXCHANGE =\n 'messaging.rabbitmq.destination.exchange' as const;\nexport const SEMATTRS_MESSAGING_RABBITMQ_ACK_RESULT =\n 'messaging.rabbitmq.ack_result' as const;\nexport const SEMATTRS_MESSAGING_RABBITMQ_REQUEUE =\n 'messaging.rabbitmq.requeue' as const;\n\n// Messaging attributes (shared across messaging systems)\nexport const SEMATTRS_MESSAGING_MESSAGE_ID = 'messaging.message.id' as const;\nexport const SEMATTRS_MESSAGING_MESSAGE_CONVERSATION_ID =\n 'messaging.message.conversation_id' as const;\nexport const SEMATTRS_MESSAGING_CONSUMER_ID = 'messaging.consumer.id' as const;\nexport const SEMATTRS_MESSAGING_OPERATION_NAME =\n 'messaging.operation.name' as const;\n\n// Kafka batch consumer attributes\nexport const SEMATTRS_MESSAGING_BATCH_MESSAGE_COUNT =\n 'messaging.batch.message_count' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_BATCH_FIRST_OFFSET =\n 'messaging.kafka.batch.first_offset' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_BATCH_LAST_OFFSET =\n 'messaging.kafka.batch.last_offset' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_BATCH_MESSAGES_PROCESSED =\n 'messaging.kafka.batch.messages_processed' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_BATCH_MESSAGES_FAILED =\n 'messaging.kafka.batch.messages_failed' as const;\nexport const SEMATTRS_MESSAGING_KAFKA_BATCH_PROCESSING_TIME_MS =\n 'messaging.kafka.batch.processing_time_ms' as const;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n// Note: `any` types are necessary for dynamic instrumentation patterns\n// where we need to wrap arbitrary methods and preserve their signatures\nimport { SpanKind, trace } from '@opentelemetry/api';\nimport {\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_NAME,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n} from '../common/constants';\nimport { runWithSpan, finalizeSpan } from 'autotel/trace-helpers';\n\nconst DEFAULT_TRACER_NAME = 'autotel-plugins/drizzle';\nconst DEFAULT_DB_SYSTEM = 'postgresql';\nconst INSTRUMENTED_FLAG = '__autotelDrizzleInstrumented' as const;\n\ntype QueryCallback = (error: unknown, result: unknown) => void;\n\ntype QueryFunction = (...args: any[]) => any;\n\ninterface DrizzleClientLike {\n query?: QueryFunction;\n execute?: QueryFunction;\n [INSTRUMENTED_FLAG]?: true;\n [key: string]: any; // Allow other properties\n}\n\n/**\n * Configuration options for Drizzle instrumentation.\n */\nexport interface InstrumentDrizzleConfig {\n /**\n * Custom tracer name. Defaults to \"autotel-plugins/drizzle\".\n */\n tracerName?: string;\n\n /**\n * Database system identifier (e.g., \"postgresql\", \"mysql\", \"sqlite\").\n * Defaults to \"postgresql\".\n */\n dbSystem?: string;\n\n /**\n * Database name to include in spans.\n */\n dbName?: string;\n\n /**\n * Whether to capture full SQL query text in spans.\n * Defaults to true.\n */\n captureQueryText?: boolean;\n\n /**\n * Maximum length for captured query text. Queries longer than this\n * will be truncated. Defaults to 1000 characters.\n */\n maxQueryTextLength?: number;\n\n /**\n * Remote hostname or IP address of the database server.\n * Example: \"db.example.com\" or \"192.168.1.100\"\n */\n peerName?: string;\n\n /**\n * Remote port number of the database server.\n * Example: 5432 for PostgreSQL, 3306 for MySQL\n */\n peerPort?: number;\n}\n\n/**\n * Extracts SQL query text from various query argument formats.\n */\nfunction extractQueryText(queryArg: unknown): string | undefined {\n if (typeof queryArg === 'string') {\n return queryArg;\n }\n if (queryArg && typeof queryArg === 'object') {\n // Generic SQL object format (used by LibSQL, MySQL, and others)\n if (typeof (queryArg as { sql?: unknown }).sql === 'string') {\n return (queryArg as { sql: string }).sql;\n }\n // PostgreSQL-style query object\n if (typeof (queryArg as { text?: unknown }).text === 'string') {\n return (queryArg as { text: string }).text;\n }\n // Drizzle SQL object\n if (\n typeof (queryArg as { queryChunks?: unknown }).queryChunks === 'object'\n ) {\n // Drizzle query objects may have complex structure, try to extract meaningful info\n const drizzleQuery = queryArg as Record<string, unknown>;\n if (typeof drizzleQuery.sql === 'string') {\n return drizzleQuery.sql;\n }\n }\n }\n return undefined;\n}\n\n/**\n * Sanitizes and truncates query text for safe inclusion in spans.\n */\nfunction sanitizeQueryText(queryText: string, maxLength: number): string {\n if (queryText.length <= maxLength) {\n return queryText;\n }\n return `${queryText.slice(0, Math.max(0, maxLength))}...`;\n}\n\n/**\n * Extracts the SQL operation (SELECT, INSERT, etc.) from query text.\n */\nfunction extractOperation(queryText: string): string | undefined {\n const trimmed = queryText.trimStart();\n const match = /^(?<op>\\w+)/u.exec(trimmed);\n return match?.groups?.op?.toUpperCase();\n}\n\n/**\n * Instruments a database connection pool/client with OpenTelemetry tracing.\n *\n * This function wraps the connection's `query` and `execute` methods to create spans for each database\n * operation.\n * The instrumentation is idempotent - calling it multiple times on the same connection will only\n * instrument it once.\n *\n * @typeParam TClient - The type of the database connection pool or client\n * @param client - The database connection pool or client to instrument\n * @param config - Optional configuration for instrumentation behavior\n * @returns The instrumented pool/client (same instance, modified in place)\n *\n * @example\n * ```typescript\n * // PostgreSQL with node-postgres\n * import { drizzle } from 'drizzle-orm/node-postgres';\n * import { Pool } from 'pg';\n * import { instrumentDrizzle } from 'autotel-plugins/drizzle';\n *\n * const pool = new Pool({ connectionString: process.env.DATABASE_URL });\n * const instrumentedPool = instrumentDrizzle(pool, {\n * dbSystem: 'postgresql',\n * dbName: 'myapp',\n * peerName: 'db.example.com',\n * peerPort: 5432,\n * });\n * const db = drizzle({ client: instrumentedPool });\n * ```\n *\n * @example\n * ```typescript\n * // MySQL with mysql2\n * import { drizzle } from 'drizzle-orm/mysql2';\n * import mysql from 'mysql2/promise';\n * import { instrumentDrizzle } from 'autotel-plugins/drizzle';\n *\n * const connection = await mysql.createConnection({\n * host: 'localhost',\n * user: 'root',\n * database: 'mydb',\n * });\n * const instrumentedConnection = instrumentDrizzle(connection, { dbSystem: 'mysql' });\n * const db = drizzle({ client: instrumentedConnection });\n * ```\n *\n * @example\n * ```typescript\n * // SQLite with better-sqlite3\n * import { drizzle } from 'drizzle-orm/better-sqlite3';\n * import Database from 'better-sqlite3';\n * import { instrumentDrizzle } from 'autotel-plugins/drizzle';\n *\n * const sqlite = new Database('sqlite.db');\n * const instrumentedSqlite = instrumentDrizzle(sqlite, { dbSystem: 'sqlite' });\n * const db = drizzle({ client: instrumentedSqlite });\n * ```\n *\n * @example\n * ```typescript\n * // LibSQL/Turso\n * import { drizzle } from 'drizzle-orm/libsql';\n * import { createClient } from '@libsql/client';\n * import { instrumentDrizzle } from 'autotel-plugins/drizzle';\n *\n * const client = createClient({\n * url: process.env.DATABASE_URL!,\n * authToken: process.env.DATABASE_AUTH_TOKEN,\n * });\n * const instrumentedClient = instrumentDrizzle(client, { dbSystem: 'sqlite' });\n * const db = drizzle({ client: instrumentedClient });\n * ```\n */\nexport function instrumentDrizzle<TClient extends DrizzleClientLike>(\n client: TClient,\n config?: InstrumentDrizzleConfig,\n): TClient {\n if (!client) {\n return client;\n }\n\n // Check if client has query or execute method\n const hasQuery = typeof client.query === 'function';\n const hasExecute = typeof client.execute === 'function';\n\n if (!hasQuery && !hasExecute) {\n return client;\n }\n\n if (client[INSTRUMENTED_FLAG]) {\n return client;\n }\n\n const {\n tracerName = DEFAULT_TRACER_NAME,\n dbSystem = DEFAULT_DB_SYSTEM,\n dbName,\n captureQueryText = true,\n maxQueryTextLength = 1000,\n peerName,\n peerPort,\n } = config ?? {};\n\n const tracer = trace.getTracer(tracerName);\n\n // Store the original method (query or execute)\n const originalMethod = hasQuery ? client.query : client.execute;\n\n if (!originalMethod) {\n return client;\n }\n\n const instrumentedMethod: QueryFunction = function instrumented(\n this: any,\n ...incomingArgs: any[]\n ) {\n const args = [...incomingArgs];\n let callback: QueryCallback | undefined;\n\n // Detect callback pattern\n if (typeof args.at(-1) === 'function') {\n callback = args.pop() as QueryCallback;\n }\n\n // Extract query information\n const queryText = extractQueryText(args[0]);\n const operation = queryText ? extractOperation(queryText) : undefined;\n const spanName = operation\n ? `drizzle.${operation.toLowerCase()}`\n : 'drizzle.query';\n\n // Start span\n const span = tracer.startSpan(spanName, { kind: SpanKind.CLIENT });\n span.setAttribute(SEMATTRS_DB_SYSTEM, dbSystem);\n\n if (operation) {\n span.setAttribute(SEMATTRS_DB_OPERATION, operation);\n }\n\n if (dbName) {\n span.setAttribute(SEMATTRS_DB_NAME, dbName);\n }\n\n if (captureQueryText && queryText !== undefined) {\n const sanitized = sanitizeQueryText(queryText, maxQueryTextLength);\n span.setAttribute(SEMATTRS_DB_STATEMENT, sanitized);\n }\n\n if (peerName) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, peerName);\n }\n\n if (peerPort) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, peerPort);\n }\n\n // Callback-based pattern\n if (callback) {\n return runWithSpan(span, () => {\n const wrappedCallback: QueryCallback = (err, result) => {\n finalizeSpan(span, err);\n if (callback) {\n callback(err, result);\n }\n };\n\n try {\n return Reflect.apply(originalMethod, this, [\n ...args,\n wrappedCallback,\n ]);\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n }\n\n // Promise-based pattern\n return runWithSpan(span, () => {\n try {\n const result = originalMethod.apply(this, args);\n return Promise.resolve(result)\n .then((value) => {\n finalizeSpan(span);\n return value;\n })\n .catch((error) => {\n finalizeSpan(span, error);\n throw error;\n });\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n };\n\n client[INSTRUMENTED_FLAG] = true;\n\n // Replace the original method with the instrumented one\n if (hasQuery) {\n client.query = instrumentedMethod;\n } else {\n client.execute = instrumentedMethod;\n }\n\n return client;\n}\n\n/**\n * Interface for Drizzle database instances with minimal type requirements.\n */\ninterface DrizzleDbLike {\n $client?: DrizzleClientLike | any; // Allow any client type\n execute?: QueryFunction; // Direct execute method on db\n transaction?: QueryFunction; // Transaction method on db\n _?: {\n session?: {\n execute?: QueryFunction;\n [INSTRUMENTED_FLAG]?: true;\n [key: string]: any;\n };\n [key: string]: any;\n };\n [INSTRUMENTED_FLAG]?: true;\n [key: string]: any; // Allow other properties\n}\n\n/**\n * Instruments a Drizzle database instance with OpenTelemetry tracing.\n *\n * This function instruments the database at the session level, automatically tracing all database\n * operations including query builders, direct SQL execution, and transactions.\n *\n * The instrumentation is idempotent - calling it multiple times on the same\n * database will only instrument it once.\n *\n * @typeParam TDb - The type of the Drizzle database instance\n * @param db - The Drizzle database instance to instrument\n * @param config - Optional configuration for instrumentation behavior\n * @returns The instrumented database instance (same instance, modified in place)\n *\n * @example\n * ```typescript\n * // PostgreSQL with postgres.js\n * import { drizzle } from 'drizzle-orm/postgres-js';\n * import postgres from 'postgres';\n * import { instrumentDrizzleClient } from 'autotel-plugins/drizzle';\n *\n * // Using connection string\n * const db = drizzle(process.env.DATABASE_URL!);\n * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });\n *\n * // Or with a client instance\n * const queryClient = postgres(process.env.DATABASE_URL!);\n * const db = drizzle({ client: queryClient });\n * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });\n * ```\n *\n * @example\n * ```typescript\n * // PostgreSQL with node-postgres (pg)\n * import { drizzle } from 'drizzle-orm/node-postgres';\n * import { Pool } from 'pg';\n * import { instrumentDrizzleClient } from 'autotel-plugins/drizzle';\n *\n * // Using connection string\n * const db = drizzle(process.env.DATABASE_URL!);\n * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });\n *\n * // Or with a pool\n * const pool = new Pool({ connectionString: process.env.DATABASE_URL });\n * const db = drizzle({ client: pool });\n * instrumentDrizzleClient(db, {\n * dbSystem: 'postgresql',\n * dbName: 'myapp',\n * peerName: 'db.example.com',\n * peerPort: 5432,\n * });\n * ```\n */\nexport function instrumentDrizzleClient<TDb extends DrizzleDbLike>(\n db: TDb,\n config?: InstrumentDrizzleConfig,\n): TDb {\n if (!db) {\n return db;\n }\n\n // Check if already instrumented\n if (db[INSTRUMENTED_FLAG]) {\n return db;\n }\n\n const {\n tracerName = DEFAULT_TRACER_NAME,\n dbSystem = DEFAULT_DB_SYSTEM,\n dbName,\n captureQueryText = true,\n maxQueryTextLength = 1000,\n peerName,\n peerPort,\n } = config ?? {};\n\n const tracer = trace.getTracer(tracerName);\n let instrumented = false;\n\n // First priority: Instrument the session directly\n // This is where all queries actually go through\n if ((db as any).session && !instrumented) {\n const session = (db as any).session;\n\n // Check if session has prepareQuery method (used by select/insert/update/delete)\n if (\n typeof session.prepareQuery === 'function' &&\n !session[INSTRUMENTED_FLAG]\n ) {\n const originalPrepareQuery = session.prepareQuery;\n\n session.prepareQuery = function (...args: any[]) {\n const prepared = originalPrepareQuery.apply(this, args);\n\n // Wrap the prepared query's execute method\n if (prepared && typeof prepared.execute === 'function') {\n const originalPreparedExecute = prepared.execute;\n\n prepared.execute = function (this: any, ...executeArgs: any[]) {\n // Extract query information from the query object\n const queryObj = args[0]; // The query object passed to prepareQuery\n const queryText =\n queryObj?.sql ||\n queryObj?.queryString ||\n extractQueryText(queryObj);\n const operation = queryText\n ? extractOperation(queryText)\n : undefined;\n const spanName = operation\n ? `drizzle.${operation.toLowerCase()}`\n : 'drizzle.query';\n\n // Start span\n const span = tracer.startSpan(spanName, { kind: SpanKind.CLIENT });\n span.setAttribute(SEMATTRS_DB_SYSTEM, dbSystem);\n\n if (operation) {\n span.setAttribute(SEMATTRS_DB_OPERATION, operation);\n }\n\n if (dbName) {\n span.setAttribute(SEMATTRS_DB_NAME, dbName);\n }\n\n if (captureQueryText && queryText !== undefined) {\n const sanitized = sanitizeQueryText(\n queryText,\n maxQueryTextLength,\n );\n span.setAttribute(SEMATTRS_DB_STATEMENT, sanitized);\n }\n\n if (peerName) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, peerName);\n }\n\n if (peerPort) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, peerPort);\n }\n\n // Execute the prepared query\n return runWithSpan(span, () => {\n try {\n const result = originalPreparedExecute.apply(this, executeArgs);\n return Promise.resolve(result)\n .then((value) => {\n finalizeSpan(span);\n return value;\n })\n .catch((error) => {\n finalizeSpan(span, error);\n throw error;\n });\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n };\n }\n\n return prepared;\n };\n\n session[INSTRUMENTED_FLAG] = true;\n instrumented = true;\n }\n\n // Also instrument direct query method if exists\n if (\n typeof session.query === 'function' &&\n !session[INSTRUMENTED_FLAG + '_query']\n ) {\n const originalQuery = session.query;\n\n session.query = function (this: any, queryString: string, params: any[]) {\n const operation = queryString\n ? extractOperation(queryString)\n : undefined;\n const spanName = operation\n ? `drizzle.${operation.toLowerCase()}`\n : 'drizzle.query';\n\n // Start span\n const span = tracer.startSpan(spanName, { kind: SpanKind.CLIENT });\n span.setAttribute(SEMATTRS_DB_SYSTEM, dbSystem);\n\n if (operation) {\n span.setAttribute(SEMATTRS_DB_OPERATION, operation);\n }\n\n if (dbName) {\n span.setAttribute(SEMATTRS_DB_NAME, dbName);\n }\n\n if (captureQueryText && queryString !== undefined) {\n const sanitized = sanitizeQueryText(queryString, maxQueryTextLength);\n span.setAttribute(SEMATTRS_DB_STATEMENT, sanitized);\n }\n\n if (peerName) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, peerName);\n }\n\n if (peerPort) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, peerPort);\n }\n\n // Execute the query\n return runWithSpan(span, () => {\n try {\n const result = Reflect.apply(originalQuery, this, [\n queryString,\n params,\n ]);\n return Promise.resolve(result)\n .then((value) => {\n finalizeSpan(span);\n return value;\n })\n .catch((error) => {\n finalizeSpan(span, error);\n throw error;\n });\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n };\n\n session[INSTRUMENTED_FLAG + '_query'] = true;\n instrumented = true;\n }\n\n // Instrument transaction method to ensure transaction sessions are also instrumented\n if (\n typeof session.transaction === 'function' &&\n !session[INSTRUMENTED_FLAG + '_transaction']\n ) {\n const originalTransaction = session.transaction;\n\n session.transaction = function (\n this: any,\n transactionCallback: any,\n ...restArgs: any[]\n ) {\n // Wrap the transaction callback to instrument the tx object\n const wrappedCallback = async function (tx: any) {\n // Instrument the transaction's session if it has one\n if (tx && (tx.session || tx._?.session || tx)) {\n const txSession = tx.session || tx._?.session || tx;\n\n // Instrument tx.execute if it exists\n if (\n typeof tx.execute === 'function' &&\n !tx[INSTRUMENTED_FLAG + '_execute']\n ) {\n const originalTxExecute = tx.execute;\n\n tx.execute = function (this: any, ...executeArgs: any[]) {\n const queryText = extractQueryText(executeArgs[0]);\n const operation = queryText\n ? extractOperation(queryText)\n : undefined;\n const spanName = operation\n ? `drizzle.${operation.toLowerCase()}`\n : 'drizzle.query';\n\n // Start span\n const span = tracer.startSpan(spanName, {\n kind: SpanKind.CLIENT,\n });\n span.setAttribute(SEMATTRS_DB_SYSTEM, dbSystem);\n span.setAttribute('db.transaction', true);\n\n if (operation) {\n span.setAttribute(SEMATTRS_DB_OPERATION, operation);\n }\n\n if (dbName) {\n span.setAttribute(SEMATTRS_DB_NAME, dbName);\n }\n\n if (captureQueryText && queryText !== undefined) {\n const sanitized = sanitizeQueryText(\n queryText,\n maxQueryTextLength,\n );\n span.setAttribute(SEMATTRS_DB_STATEMENT, sanitized);\n }\n\n if (peerName) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, peerName);\n }\n\n if (peerPort) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, peerPort);\n }\n\n // Execute the query\n return runWithSpan(span, () => {\n try {\n const result = originalTxExecute.apply(this, executeArgs);\n return Promise.resolve(result)\n .then((value) => {\n finalizeSpan(span);\n return value;\n })\n .catch((error) => {\n finalizeSpan(span, error);\n throw error;\n });\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n };\n\n tx[INSTRUMENTED_FLAG + '_execute'] = true;\n }\n\n // Also instrument txSession.prepareQuery if it exists\n if (\n typeof txSession.prepareQuery === 'function' &&\n !txSession[INSTRUMENTED_FLAG + '_tx']\n ) {\n const originalTxPrepareQuery = txSession.prepareQuery;\n\n txSession.prepareQuery = function (...prepareArgs: any[]) {\n const prepared = originalTxPrepareQuery.apply(\n this,\n prepareArgs,\n );\n\n // Wrap the prepared query's execute method\n if (prepared && typeof prepared.execute === 'function') {\n const originalPreparedExecute = prepared.execute;\n\n prepared.execute = function (\n this: any,\n ...executeArgs: any[]\n ) {\n // Extract query information from the query object\n const queryObj = prepareArgs[0]; // The query object passed to prepareQuery\n const queryText =\n queryObj?.sql ||\n queryObj?.queryString ||\n extractQueryText(queryObj);\n const operation = queryText\n ? extractOperation(queryText)\n : undefined;\n const spanName = operation\n ? `drizzle.${operation.toLowerCase()}`\n : 'drizzle.query';\n\n // Start span\n const span = tracer.startSpan(spanName, {\n kind: SpanKind.CLIENT,\n });\n span.setAttribute(SEMATTRS_DB_SYSTEM, dbSystem);\n span.setAttribute('db.transaction', true);\n\n if (operation) {\n span.setAttribute(SEMATTRS_DB_OPERATION, operation);\n }\n\n if (dbName) {\n span.setAttribute(SEMATTRS_DB_NAME, dbName);\n }\n\n if (captureQueryText && queryText !== undefined) {\n const sanitized = sanitizeQueryText(\n queryText,\n maxQueryTextLength,\n );\n span.setAttribute(SEMATTRS_DB_STATEMENT, sanitized);\n }\n\n if (peerName) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, peerName);\n }\n\n if (peerPort) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, peerPort);\n }\n\n // Execute the prepared query\n return runWithSpan(span, () => {\n try {\n const result = originalPreparedExecute.apply(\n this,\n executeArgs,\n );\n return Promise.resolve(result)\n .then((value) => {\n finalizeSpan(span);\n return value;\n })\n .catch((error) => {\n finalizeSpan(span, error);\n throw error;\n });\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n };\n }\n\n return prepared;\n };\n\n txSession[INSTRUMENTED_FLAG + '_tx'] = true;\n }\n }\n\n // Call the original callback with the instrumented tx\n return transactionCallback(tx);\n };\n\n // Call the original transaction with the wrapped callback\n return Reflect.apply(originalTransaction, this, [\n wrappedCallback,\n ...restArgs,\n ]);\n };\n\n session[INSTRUMENTED_FLAG + '_transaction'] = true;\n instrumented = true;\n }\n }\n\n if (db.$client && !instrumented) {\n const client = db.$client;\n // Check if client has query or execute function\n if (\n typeof client.query === 'function' ||\n typeof client.execute === 'function'\n ) {\n instrumentDrizzle(client, config);\n instrumented = true;\n }\n }\n\n // Third priority: Try to instrument via session.execute as fallback\n if (\n db._ &&\n db._.session &&\n typeof db._.session.execute === 'function' &&\n !instrumented\n ) {\n const session = db._.session;\n\n // Check if already instrumented\n if (session[INSTRUMENTED_FLAG]) {\n return db;\n }\n\n const {\n tracerName = DEFAULT_TRACER_NAME,\n dbSystem = DEFAULT_DB_SYSTEM,\n dbName,\n captureQueryText = true,\n maxQueryTextLength = 1000,\n peerName,\n peerPort,\n } = config ?? {};\n\n const tracer = trace.getTracer(tracerName);\n const originalExecute = session.execute;\n\n if (!originalExecute) {\n return db;\n }\n\n const instrumentedExecute: QueryFunction = function instrumented(\n this: any,\n ...args: any[]\n ) {\n // Extract query information\n const queryText = extractQueryText(args[0]);\n const operation = queryText ? extractOperation(queryText) : undefined;\n const spanName = operation\n ? `drizzle.${operation.toLowerCase()}`\n : 'drizzle.query';\n\n // Start span\n const span = tracer.startSpan(spanName, { kind: SpanKind.CLIENT });\n span.setAttribute(SEMATTRS_DB_SYSTEM, dbSystem);\n\n if (operation) {\n span.setAttribute(SEMATTRS_DB_OPERATION, operation);\n }\n\n if (dbName) {\n span.setAttribute(SEMATTRS_DB_NAME, dbName);\n }\n\n if (captureQueryText && queryText !== undefined) {\n const sanitized = sanitizeQueryText(queryText, maxQueryTextLength);\n span.setAttribute(SEMATTRS_DB_STATEMENT, sanitized);\n }\n\n if (peerName) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, peerName);\n }\n\n if (peerPort) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, peerPort);\n }\n\n // Promise-based pattern (session.execute is typically promise-based)\n return runWithSpan(span, () => {\n try {\n const result = originalExecute.apply(this, args);\n return Promise.resolve(result)\n .then((value) => {\n finalizeSpan(span);\n return value;\n })\n .catch((error) => {\n finalizeSpan(span, error);\n throw error;\n });\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n };\n\n session[INSTRUMENTED_FLAG] = true;\n session.execute = instrumentedExecute;\n instrumented = true;\n }\n\n // Mark the db as instrumented if we instrumented anything\n if (instrumented) {\n db[INSTRUMENTED_FLAG] = true;\n }\n\n return db;\n}\n"]}
@@ -1,194 +0,0 @@
1
- declare const INSTRUMENTED_FLAG: "__autotelDrizzleInstrumented";
2
- type QueryFunction = (...args: any[]) => any;
3
- interface DrizzleClientLike {
4
- query?: QueryFunction;
5
- execute?: QueryFunction;
6
- [INSTRUMENTED_FLAG]?: true;
7
- [key: string]: any;
8
- }
9
- /**
10
- * Configuration options for Drizzle instrumentation.
11
- */
12
- interface InstrumentDrizzleConfig {
13
- /**
14
- * Custom tracer name. Defaults to "autotel-plugins/drizzle".
15
- */
16
- tracerName?: string;
17
- /**
18
- * Database system identifier (e.g., "postgresql", "mysql", "sqlite").
19
- * Defaults to "postgresql".
20
- */
21
- dbSystem?: string;
22
- /**
23
- * Database name to include in spans.
24
- */
25
- dbName?: string;
26
- /**
27
- * Whether to capture full SQL query text in spans.
28
- * Defaults to true.
29
- */
30
- captureQueryText?: boolean;
31
- /**
32
- * Maximum length for captured query text. Queries longer than this
33
- * will be truncated. Defaults to 1000 characters.
34
- */
35
- maxQueryTextLength?: number;
36
- /**
37
- * Remote hostname or IP address of the database server.
38
- * Example: "db.example.com" or "192.168.1.100"
39
- */
40
- peerName?: string;
41
- /**
42
- * Remote port number of the database server.
43
- * Example: 5432 for PostgreSQL, 3306 for MySQL
44
- */
45
- peerPort?: number;
46
- }
47
- /**
48
- * Instruments a database connection pool/client with OpenTelemetry tracing.
49
- *
50
- * This function wraps the connection's `query` and `execute` methods to create spans for each database
51
- * operation.
52
- * The instrumentation is idempotent - calling it multiple times on the same connection will only
53
- * instrument it once.
54
- *
55
- * @typeParam TClient - The type of the database connection pool or client
56
- * @param client - The database connection pool or client to instrument
57
- * @param config - Optional configuration for instrumentation behavior
58
- * @returns The instrumented pool/client (same instance, modified in place)
59
- *
60
- * @example
61
- * ```typescript
62
- * // PostgreSQL with node-postgres
63
- * import { drizzle } from 'drizzle-orm/node-postgres';
64
- * import { Pool } from 'pg';
65
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
66
- *
67
- * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
68
- * const instrumentedPool = instrumentDrizzle(pool, {
69
- * dbSystem: 'postgresql',
70
- * dbName: 'myapp',
71
- * peerName: 'db.example.com',
72
- * peerPort: 5432,
73
- * });
74
- * const db = drizzle({ client: instrumentedPool });
75
- * ```
76
- *
77
- * @example
78
- * ```typescript
79
- * // MySQL with mysql2
80
- * import { drizzle } from 'drizzle-orm/mysql2';
81
- * import mysql from 'mysql2/promise';
82
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
83
- *
84
- * const connection = await mysql.createConnection({
85
- * host: 'localhost',
86
- * user: 'root',
87
- * database: 'mydb',
88
- * });
89
- * const instrumentedConnection = instrumentDrizzle(connection, { dbSystem: 'mysql' });
90
- * const db = drizzle({ client: instrumentedConnection });
91
- * ```
92
- *
93
- * @example
94
- * ```typescript
95
- * // SQLite with better-sqlite3
96
- * import { drizzle } from 'drizzle-orm/better-sqlite3';
97
- * import Database from 'better-sqlite3';
98
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
99
- *
100
- * const sqlite = new Database('sqlite.db');
101
- * const instrumentedSqlite = instrumentDrizzle(sqlite, { dbSystem: 'sqlite' });
102
- * const db = drizzle({ client: instrumentedSqlite });
103
- * ```
104
- *
105
- * @example
106
- * ```typescript
107
- * // LibSQL/Turso
108
- * import { drizzle } from 'drizzle-orm/libsql';
109
- * import { createClient } from '@libsql/client';
110
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
111
- *
112
- * const client = createClient({
113
- * url: process.env.DATABASE_URL!,
114
- * authToken: process.env.DATABASE_AUTH_TOKEN,
115
- * });
116
- * const instrumentedClient = instrumentDrizzle(client, { dbSystem: 'sqlite' });
117
- * const db = drizzle({ client: instrumentedClient });
118
- * ```
119
- */
120
- declare function instrumentDrizzle<TClient extends DrizzleClientLike>(client: TClient, config?: InstrumentDrizzleConfig): TClient;
121
- /**
122
- * Interface for Drizzle database instances with minimal type requirements.
123
- */
124
- interface DrizzleDbLike {
125
- $client?: DrizzleClientLike | any;
126
- execute?: QueryFunction;
127
- transaction?: QueryFunction;
128
- _?: {
129
- session?: {
130
- execute?: QueryFunction;
131
- [INSTRUMENTED_FLAG]?: true;
132
- [key: string]: any;
133
- };
134
- [key: string]: any;
135
- };
136
- [INSTRUMENTED_FLAG]?: true;
137
- [key: string]: any;
138
- }
139
- /**
140
- * Instruments a Drizzle database instance with OpenTelemetry tracing.
141
- *
142
- * This function instruments the database at the session level, automatically tracing all database
143
- * operations including query builders, direct SQL execution, and transactions.
144
- *
145
- * The instrumentation is idempotent - calling it multiple times on the same
146
- * database will only instrument it once.
147
- *
148
- * @typeParam TDb - The type of the Drizzle database instance
149
- * @param db - The Drizzle database instance to instrument
150
- * @param config - Optional configuration for instrumentation behavior
151
- * @returns The instrumented database instance (same instance, modified in place)
152
- *
153
- * @example
154
- * ```typescript
155
- * // PostgreSQL with postgres.js
156
- * import { drizzle } from 'drizzle-orm/postgres-js';
157
- * import postgres from 'postgres';
158
- * import { instrumentDrizzleClient } from 'autotel-plugins/drizzle';
159
- *
160
- * // Using connection string
161
- * const db = drizzle(process.env.DATABASE_URL!);
162
- * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });
163
- *
164
- * // Or with a client instance
165
- * const queryClient = postgres(process.env.DATABASE_URL!);
166
- * const db = drizzle({ client: queryClient });
167
- * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });
168
- * ```
169
- *
170
- * @example
171
- * ```typescript
172
- * // PostgreSQL with node-postgres (pg)
173
- * import { drizzle } from 'drizzle-orm/node-postgres';
174
- * import { Pool } from 'pg';
175
- * import { instrumentDrizzleClient } from 'autotel-plugins/drizzle';
176
- *
177
- * // Using connection string
178
- * const db = drizzle(process.env.DATABASE_URL!);
179
- * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });
180
- *
181
- * // Or with a pool
182
- * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
183
- * const db = drizzle({ client: pool });
184
- * instrumentDrizzleClient(db, {
185
- * dbSystem: 'postgresql',
186
- * dbName: 'myapp',
187
- * peerName: 'db.example.com',
188
- * peerPort: 5432,
189
- * });
190
- * ```
191
- */
192
- declare function instrumentDrizzleClient<TDb extends DrizzleDbLike>(db: TDb, config?: InstrumentDrizzleConfig): TDb;
193
-
194
- export { type InstrumentDrizzleConfig, instrumentDrizzle, instrumentDrizzleClient };
package/dist/drizzle.d.ts DELETED
@@ -1,194 +0,0 @@
1
- declare const INSTRUMENTED_FLAG: "__autotelDrizzleInstrumented";
2
- type QueryFunction = (...args: any[]) => any;
3
- interface DrizzleClientLike {
4
- query?: QueryFunction;
5
- execute?: QueryFunction;
6
- [INSTRUMENTED_FLAG]?: true;
7
- [key: string]: any;
8
- }
9
- /**
10
- * Configuration options for Drizzle instrumentation.
11
- */
12
- interface InstrumentDrizzleConfig {
13
- /**
14
- * Custom tracer name. Defaults to "autotel-plugins/drizzle".
15
- */
16
- tracerName?: string;
17
- /**
18
- * Database system identifier (e.g., "postgresql", "mysql", "sqlite").
19
- * Defaults to "postgresql".
20
- */
21
- dbSystem?: string;
22
- /**
23
- * Database name to include in spans.
24
- */
25
- dbName?: string;
26
- /**
27
- * Whether to capture full SQL query text in spans.
28
- * Defaults to true.
29
- */
30
- captureQueryText?: boolean;
31
- /**
32
- * Maximum length for captured query text. Queries longer than this
33
- * will be truncated. Defaults to 1000 characters.
34
- */
35
- maxQueryTextLength?: number;
36
- /**
37
- * Remote hostname or IP address of the database server.
38
- * Example: "db.example.com" or "192.168.1.100"
39
- */
40
- peerName?: string;
41
- /**
42
- * Remote port number of the database server.
43
- * Example: 5432 for PostgreSQL, 3306 for MySQL
44
- */
45
- peerPort?: number;
46
- }
47
- /**
48
- * Instruments a database connection pool/client with OpenTelemetry tracing.
49
- *
50
- * This function wraps the connection's `query` and `execute` methods to create spans for each database
51
- * operation.
52
- * The instrumentation is idempotent - calling it multiple times on the same connection will only
53
- * instrument it once.
54
- *
55
- * @typeParam TClient - The type of the database connection pool or client
56
- * @param client - The database connection pool or client to instrument
57
- * @param config - Optional configuration for instrumentation behavior
58
- * @returns The instrumented pool/client (same instance, modified in place)
59
- *
60
- * @example
61
- * ```typescript
62
- * // PostgreSQL with node-postgres
63
- * import { drizzle } from 'drizzle-orm/node-postgres';
64
- * import { Pool } from 'pg';
65
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
66
- *
67
- * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
68
- * const instrumentedPool = instrumentDrizzle(pool, {
69
- * dbSystem: 'postgresql',
70
- * dbName: 'myapp',
71
- * peerName: 'db.example.com',
72
- * peerPort: 5432,
73
- * });
74
- * const db = drizzle({ client: instrumentedPool });
75
- * ```
76
- *
77
- * @example
78
- * ```typescript
79
- * // MySQL with mysql2
80
- * import { drizzle } from 'drizzle-orm/mysql2';
81
- * import mysql from 'mysql2/promise';
82
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
83
- *
84
- * const connection = await mysql.createConnection({
85
- * host: 'localhost',
86
- * user: 'root',
87
- * database: 'mydb',
88
- * });
89
- * const instrumentedConnection = instrumentDrizzle(connection, { dbSystem: 'mysql' });
90
- * const db = drizzle({ client: instrumentedConnection });
91
- * ```
92
- *
93
- * @example
94
- * ```typescript
95
- * // SQLite with better-sqlite3
96
- * import { drizzle } from 'drizzle-orm/better-sqlite3';
97
- * import Database from 'better-sqlite3';
98
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
99
- *
100
- * const sqlite = new Database('sqlite.db');
101
- * const instrumentedSqlite = instrumentDrizzle(sqlite, { dbSystem: 'sqlite' });
102
- * const db = drizzle({ client: instrumentedSqlite });
103
- * ```
104
- *
105
- * @example
106
- * ```typescript
107
- * // LibSQL/Turso
108
- * import { drizzle } from 'drizzle-orm/libsql';
109
- * import { createClient } from '@libsql/client';
110
- * import { instrumentDrizzle } from 'autotel-plugins/drizzle';
111
- *
112
- * const client = createClient({
113
- * url: process.env.DATABASE_URL!,
114
- * authToken: process.env.DATABASE_AUTH_TOKEN,
115
- * });
116
- * const instrumentedClient = instrumentDrizzle(client, { dbSystem: 'sqlite' });
117
- * const db = drizzle({ client: instrumentedClient });
118
- * ```
119
- */
120
- declare function instrumentDrizzle<TClient extends DrizzleClientLike>(client: TClient, config?: InstrumentDrizzleConfig): TClient;
121
- /**
122
- * Interface for Drizzle database instances with minimal type requirements.
123
- */
124
- interface DrizzleDbLike {
125
- $client?: DrizzleClientLike | any;
126
- execute?: QueryFunction;
127
- transaction?: QueryFunction;
128
- _?: {
129
- session?: {
130
- execute?: QueryFunction;
131
- [INSTRUMENTED_FLAG]?: true;
132
- [key: string]: any;
133
- };
134
- [key: string]: any;
135
- };
136
- [INSTRUMENTED_FLAG]?: true;
137
- [key: string]: any;
138
- }
139
- /**
140
- * Instruments a Drizzle database instance with OpenTelemetry tracing.
141
- *
142
- * This function instruments the database at the session level, automatically tracing all database
143
- * operations including query builders, direct SQL execution, and transactions.
144
- *
145
- * The instrumentation is idempotent - calling it multiple times on the same
146
- * database will only instrument it once.
147
- *
148
- * @typeParam TDb - The type of the Drizzle database instance
149
- * @param db - The Drizzle database instance to instrument
150
- * @param config - Optional configuration for instrumentation behavior
151
- * @returns The instrumented database instance (same instance, modified in place)
152
- *
153
- * @example
154
- * ```typescript
155
- * // PostgreSQL with postgres.js
156
- * import { drizzle } from 'drizzle-orm/postgres-js';
157
- * import postgres from 'postgres';
158
- * import { instrumentDrizzleClient } from 'autotel-plugins/drizzle';
159
- *
160
- * // Using connection string
161
- * const db = drizzle(process.env.DATABASE_URL!);
162
- * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });
163
- *
164
- * // Or with a client instance
165
- * const queryClient = postgres(process.env.DATABASE_URL!);
166
- * const db = drizzle({ client: queryClient });
167
- * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });
168
- * ```
169
- *
170
- * @example
171
- * ```typescript
172
- * // PostgreSQL with node-postgres (pg)
173
- * import { drizzle } from 'drizzle-orm/node-postgres';
174
- * import { Pool } from 'pg';
175
- * import { instrumentDrizzleClient } from 'autotel-plugins/drizzle';
176
- *
177
- * // Using connection string
178
- * const db = drizzle(process.env.DATABASE_URL!);
179
- * instrumentDrizzleClient(db, { dbSystem: 'postgresql' });
180
- *
181
- * // Or with a pool
182
- * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
183
- * const db = drizzle({ client: pool });
184
- * instrumentDrizzleClient(db, {
185
- * dbSystem: 'postgresql',
186
- * dbName: 'myapp',
187
- * peerName: 'db.example.com',
188
- * peerPort: 5432,
189
- * });
190
- * ```
191
- */
192
- declare function instrumentDrizzleClient<TDb extends DrizzleDbLike>(db: TDb, config?: InstrumentDrizzleConfig): TDb;
193
-
194
- export { type InstrumentDrizzleConfig, instrumentDrizzle, instrumentDrizzleClient };