autotel-drizzle 0.0.29 → 0.0.31
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.
- package/dist/drizzle-C2xv1qdm.js +270 -0
- package/dist/drizzle-C2xv1qdm.js.map +1 -0
- package/dist/drizzle-D46sVvOa.cjs +413 -0
- package/dist/drizzle-D46sVvOa.cjs.map +1 -0
- package/dist/drizzle.cjs +4 -339
- package/dist/drizzle.d.cts +24 -22
- package/dist/drizzle.d.cts.map +1 -0
- package/dist/drizzle.d.ts +24 -22
- package/dist/drizzle.d.ts.map +1 -0
- package/dist/drizzle.js +1 -335
- package/dist/index.cjs +26 -375
- package/dist/index.d.cts +5 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -349
- package/package.json +5 -5
- package/dist/drizzle.cjs.map +0 -1
- package/dist/drizzle.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { SpanKind, trace } from "@opentelemetry/api";
|
|
3
|
+
import { finalizeSpan, runWithSpan } from "autotel/trace-helpers";
|
|
4
|
+
//#region src/common/constants.ts
|
|
5
|
+
/**
|
|
6
|
+
* OpenTelemetry semantic conventions for database operations.
|
|
7
|
+
* These constants are shared across all plugins.
|
|
8
|
+
*/
|
|
9
|
+
const SEMATTRS_DB_SYSTEM = "db.system";
|
|
10
|
+
const SEMATTRS_DB_SYSTEM_NAME = "db.system.name";
|
|
11
|
+
const SEMATTRS_DB_OPERATION = "db.operation";
|
|
12
|
+
const SEMATTRS_DB_STATEMENT = "db.statement";
|
|
13
|
+
const SEMATTRS_DB_NAME = "db.name";
|
|
14
|
+
const SEMATTRS_DB_NAMESPACE = "db.namespace";
|
|
15
|
+
const SEMATTRS_DB_COLLECTION_NAME = "db.collection.name";
|
|
16
|
+
const SEMATTRS_DB_OPERATION_NAME = "db.operation.name";
|
|
17
|
+
const SEMATTRS_DB_QUERY_TEXT = "db.query.text";
|
|
18
|
+
const SEMATTRS_DB_QUERY_SUMMARY = "db.query.summary";
|
|
19
|
+
/**
|
|
20
|
+
* sha1 hex of the (parameterised, sanitized) statement text. Use to group
|
|
21
|
+
* identical queries in observability tools — the raw `db.statement` is
|
|
22
|
+
* usually unique per call due to inline params or comments, so high-
|
|
23
|
+
* cardinality grouping by it is unhelpful. Example use: aggregate the top
|
|
24
|
+
* 20 queries by total duration by `db.statement.hash`.
|
|
25
|
+
*/
|
|
26
|
+
const SEMATTRS_DB_STATEMENT_HASH = "db.statement.hash";
|
|
27
|
+
const SEMATTRS_NET_PEER_NAME = "net.peer.name";
|
|
28
|
+
const SEMATTRS_NET_PEER_PORT = "net.peer.port";
|
|
29
|
+
const SEMATTRS_GCP_BIGQUERY_JOB_ID = "gcp.bigquery.job.id";
|
|
30
|
+
const SEMATTRS_GCP_BIGQUERY_JOB_LOCATION = "gcp.bigquery.job.location";
|
|
31
|
+
const SEMATTRS_GCP_BIGQUERY_PROJECT_ID = "gcp.bigquery.project.id";
|
|
32
|
+
const SEMATTRS_GCP_BIGQUERY_DESTINATION_TABLE = "gcp.bigquery.destination.table";
|
|
33
|
+
const SEMATTRS_GCP_BIGQUERY_SOURCE_TABLES = "gcp.bigquery.source.tables";
|
|
34
|
+
const SEMATTRS_GCP_BIGQUERY_STATEMENT_TYPE = "gcp.bigquery.statement_type";
|
|
35
|
+
const SEMATTRS_GCP_BIGQUERY_QUERY_HASH = "gcp.bigquery.query.hash";
|
|
36
|
+
const SEMATTRS_GCP_BIGQUERY_ROWS_AFFECTED = "gcp.bigquery.rows.affected";
|
|
37
|
+
const SEMATTRS_GCP_BIGQUERY_ROWS_RETURNED = "gcp.bigquery.rows.returned";
|
|
38
|
+
const SEMATTRS_GCP_BIGQUERY_SCHEMA_FIELDS = "gcp.bigquery.schema.fields";
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/drizzle/index.ts
|
|
41
|
+
const DEFAULT_TRACER_NAME = "autotel-plugins/drizzle";
|
|
42
|
+
const DEFAULT_DB_SYSTEM = "postgresql";
|
|
43
|
+
const INSTRUMENTED_FLAG = "__autotelDrizzleInstrumented";
|
|
44
|
+
const PREPARED_QUERY_METHODS = [
|
|
45
|
+
"all",
|
|
46
|
+
"execute",
|
|
47
|
+
"get",
|
|
48
|
+
"run",
|
|
49
|
+
"values"
|
|
50
|
+
];
|
|
51
|
+
function resolveConfig(config) {
|
|
52
|
+
return {
|
|
53
|
+
tracerName: config?.tracerName ?? DEFAULT_TRACER_NAME,
|
|
54
|
+
dbSystem: config?.dbSystem ?? DEFAULT_DB_SYSTEM,
|
|
55
|
+
dbName: config?.dbName,
|
|
56
|
+
captureQueryText: config?.captureQueryText ?? true,
|
|
57
|
+
maxQueryTextLength: config?.maxQueryTextLength ?? 1e3,
|
|
58
|
+
peerName: config?.peerName,
|
|
59
|
+
peerPort: config?.peerPort
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function getState(config) {
|
|
63
|
+
const resolved = resolveConfig(config);
|
|
64
|
+
return {
|
|
65
|
+
config: resolved,
|
|
66
|
+
tracer: trace.getTracer(resolved.tracerName)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function getFlagKey(suffix) {
|
|
70
|
+
return `${INSTRUMENTED_FLAG}:${suffix}`;
|
|
71
|
+
}
|
|
72
|
+
function isObject(value) {
|
|
73
|
+
return value !== null && typeof value === "object";
|
|
74
|
+
}
|
|
75
|
+
function isPromiseLike(value) {
|
|
76
|
+
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
77
|
+
}
|
|
78
|
+
function extractQueryText(queryArg) {
|
|
79
|
+
if (typeof queryArg === "string") return queryArg;
|
|
80
|
+
if (!isObject(queryArg)) return;
|
|
81
|
+
if (typeof queryArg.sql === "string") return queryArg.sql;
|
|
82
|
+
if (typeof queryArg.text === "string") return queryArg.text;
|
|
83
|
+
if (typeof queryArg.queryString === "string") return queryArg.queryString;
|
|
84
|
+
if (isObject(queryArg.queryChunks) && typeof queryArg.sql === "string") return queryArg.sql;
|
|
85
|
+
}
|
|
86
|
+
function sanitizeQueryText(queryText, maxLength) {
|
|
87
|
+
if (queryText.length <= maxLength) return queryText;
|
|
88
|
+
return `${queryText.slice(0, Math.max(0, maxLength))}...`;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Stable sha1 of a parameterised SQL statement, used as `db.statement.hash`.
|
|
92
|
+
* Hashes the full original text (not the truncated form) so the hash is
|
|
93
|
+
* identical for queries that only differ in trailing length. We keep this
|
|
94
|
+
* cheap (sha1, hex, take 16 chars) — the goal is grouping, not crypto.
|
|
95
|
+
*/
|
|
96
|
+
function hashQueryText(queryText) {
|
|
97
|
+
return createHash("sha1").update(queryText).digest("hex").slice(0, 16);
|
|
98
|
+
}
|
|
99
|
+
function extractOperation(queryText) {
|
|
100
|
+
const trimmed = queryText.trimStart();
|
|
101
|
+
return /^(?<operation>\w+)/u.exec(trimmed)?.groups?.operation?.toUpperCase();
|
|
102
|
+
}
|
|
103
|
+
function buildSpan(state, queryText, extraAttributes) {
|
|
104
|
+
const operation = queryText ? extractOperation(queryText) : void 0;
|
|
105
|
+
const spanName = operation ? `drizzle.${operation.toLowerCase()}` : "drizzle.query";
|
|
106
|
+
const span = state.tracer.startSpan(spanName, { kind: SpanKind.CLIENT });
|
|
107
|
+
span.setAttribute(SEMATTRS_DB_SYSTEM, state.config.dbSystem);
|
|
108
|
+
if (operation) span.setAttribute(SEMATTRS_DB_OPERATION, operation);
|
|
109
|
+
if (state.config.dbName !== void 0) span.setAttribute(SEMATTRS_DB_NAME, state.config.dbName);
|
|
110
|
+
if (queryText !== void 0) span.setAttribute(SEMATTRS_DB_STATEMENT_HASH, hashQueryText(queryText));
|
|
111
|
+
if (state.config.captureQueryText && queryText !== void 0) span.setAttribute(SEMATTRS_DB_STATEMENT, sanitizeQueryText(queryText, state.config.maxQueryTextLength));
|
|
112
|
+
if (state.config.peerName !== void 0) span.setAttribute(SEMATTRS_NET_PEER_NAME, state.config.peerName);
|
|
113
|
+
if (state.config.peerPort !== void 0) span.setAttribute(SEMATTRS_NET_PEER_PORT, state.config.peerPort);
|
|
114
|
+
if (extraAttributes) for (const [key, value] of Object.entries(extraAttributes)) span.setAttribute(key, value);
|
|
115
|
+
return span;
|
|
116
|
+
}
|
|
117
|
+
function executeWithSpan(span, fn) {
|
|
118
|
+
return runWithSpan(span, () => {
|
|
119
|
+
try {
|
|
120
|
+
const result = fn();
|
|
121
|
+
if (isPromiseLike(result)) return result.then((value) => {
|
|
122
|
+
finalizeSpan(span);
|
|
123
|
+
return value;
|
|
124
|
+
}, (error) => {
|
|
125
|
+
finalizeSpan(span, error);
|
|
126
|
+
throw error;
|
|
127
|
+
});
|
|
128
|
+
finalizeSpan(span);
|
|
129
|
+
return result;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
finalizeSpan(span, error);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function instrumentMethod(target, methodName, state, options) {
|
|
137
|
+
if (typeof target[methodName] !== "function") return false;
|
|
138
|
+
const flagKey = getFlagKey(options.flagSuffix);
|
|
139
|
+
if (target[flagKey]) return false;
|
|
140
|
+
const originalMethod = target[methodName];
|
|
141
|
+
target[methodName] = function instrumentedMethod(...incomingArgs) {
|
|
142
|
+
const args = [...incomingArgs];
|
|
143
|
+
const callback = options.callbackStyle === "last-arg" && typeof args.at(-1) === "function" ? args.pop() : void 0;
|
|
144
|
+
const span = buildSpan(state, options.queryText(args), options.extraAttributes);
|
|
145
|
+
if (callback) return runWithSpan(span, () => {
|
|
146
|
+
const wrappedCallback = (error, result) => {
|
|
147
|
+
finalizeSpan(span, error);
|
|
148
|
+
callback(error, result);
|
|
149
|
+
};
|
|
150
|
+
try {
|
|
151
|
+
return Reflect.apply(originalMethod, this, [...args, wrappedCallback]);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
finalizeSpan(span, error);
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return executeWithSpan(span, () => Reflect.apply(originalMethod, this, args));
|
|
158
|
+
};
|
|
159
|
+
target[flagKey] = true;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
function instrumentPreparedQuery(prepared, state, querySource, extraAttributes) {
|
|
163
|
+
if (!isObject(prepared)) return false;
|
|
164
|
+
let instrumented = false;
|
|
165
|
+
const queryText = extractQueryText(querySource);
|
|
166
|
+
for (const methodName of PREPARED_QUERY_METHODS) instrumented = instrumentMethod(prepared, methodName, state, {
|
|
167
|
+
flagSuffix: `prepared:${methodName}`,
|
|
168
|
+
queryText: () => queryText,
|
|
169
|
+
extraAttributes
|
|
170
|
+
}) || instrumented;
|
|
171
|
+
return instrumented;
|
|
172
|
+
}
|
|
173
|
+
function instrumentPrepareQuery(target, state, extraAttributes) {
|
|
174
|
+
if (typeof target.prepareQuery !== "function") return false;
|
|
175
|
+
const flagKey = getFlagKey("prepareQuery");
|
|
176
|
+
if (target[flagKey]) return false;
|
|
177
|
+
const originalPrepareQuery = target.prepareQuery;
|
|
178
|
+
target.prepareQuery = function instrumentedPrepareQuery(...prepareArgs) {
|
|
179
|
+
const prepared = Reflect.apply(originalPrepareQuery, this, prepareArgs);
|
|
180
|
+
instrumentPreparedQuery(prepared, state, prepareArgs[0], extraAttributes);
|
|
181
|
+
return prepared;
|
|
182
|
+
};
|
|
183
|
+
target[flagKey] = true;
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
function instrumentTransactionTarget(target, state) {
|
|
187
|
+
if (!isObject(target)) return false;
|
|
188
|
+
const transactionAttributes = { "db.transaction": true };
|
|
189
|
+
let instrumented = false;
|
|
190
|
+
instrumented = instrumentMethod(target, "query", state, {
|
|
191
|
+
flagSuffix: "transaction:query",
|
|
192
|
+
queryText: (args) => extractQueryText(args[0]),
|
|
193
|
+
callbackStyle: "last-arg",
|
|
194
|
+
extraAttributes: transactionAttributes
|
|
195
|
+
}) || instrumented;
|
|
196
|
+
instrumented = instrumentMethod(target, "execute", state, {
|
|
197
|
+
flagSuffix: "transaction:execute",
|
|
198
|
+
queryText: (args) => extractQueryText(args[0]),
|
|
199
|
+
callbackStyle: "last-arg",
|
|
200
|
+
extraAttributes: transactionAttributes
|
|
201
|
+
}) || instrumented;
|
|
202
|
+
instrumented = instrumentPrepareQuery(target, state, transactionAttributes) || instrumented;
|
|
203
|
+
if (isObject(target.session)) instrumented = instrumentTransactionTarget(target.session, state) || instrumented;
|
|
204
|
+
if (isObject(target._?.session)) instrumented = instrumentTransactionTarget(target._.session, state) || instrumented;
|
|
205
|
+
return instrumented;
|
|
206
|
+
}
|
|
207
|
+
function instrumentSession(session, state) {
|
|
208
|
+
let instrumented = false;
|
|
209
|
+
instrumented = instrumentMethod(session, "query", state, {
|
|
210
|
+
flagSuffix: "session:query",
|
|
211
|
+
queryText: (args) => extractQueryText(args[0]),
|
|
212
|
+
callbackStyle: "last-arg"
|
|
213
|
+
}) || instrumented;
|
|
214
|
+
instrumented = instrumentMethod(session, "execute", state, {
|
|
215
|
+
flagSuffix: "session:execute",
|
|
216
|
+
queryText: (args) => extractQueryText(args[0]),
|
|
217
|
+
callbackStyle: "last-arg"
|
|
218
|
+
}) || instrumented;
|
|
219
|
+
instrumented = instrumentPrepareQuery(session, state) || instrumented;
|
|
220
|
+
if (typeof session.transaction === "function") {
|
|
221
|
+
const flagKey = getFlagKey("session:transaction");
|
|
222
|
+
if (!session[flagKey]) {
|
|
223
|
+
const originalTransaction = session.transaction;
|
|
224
|
+
session.transaction = function instrumentedTransaction(callback, ...restArgs) {
|
|
225
|
+
if (typeof callback !== "function") return Reflect.apply(originalTransaction, this, [callback, ...restArgs]);
|
|
226
|
+
const wrappedCallback = (tx, ...callbackArgs) => {
|
|
227
|
+
instrumentTransactionTarget(tx, state);
|
|
228
|
+
return Reflect.apply(callback, this, [tx, ...callbackArgs]);
|
|
229
|
+
};
|
|
230
|
+
return Reflect.apply(originalTransaction, this, [wrappedCallback, ...restArgs]);
|
|
231
|
+
};
|
|
232
|
+
session[flagKey] = true;
|
|
233
|
+
instrumented = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (instrumented) session[INSTRUMENTED_FLAG] = true;
|
|
237
|
+
return instrumented;
|
|
238
|
+
}
|
|
239
|
+
function instrumentDrizzle(client, config) {
|
|
240
|
+
if (!client || !isObject(client)) return client;
|
|
241
|
+
const state = getState(config);
|
|
242
|
+
let instrumented = false;
|
|
243
|
+
instrumented = instrumentMethod(client, "query", state, {
|
|
244
|
+
flagSuffix: "client:query",
|
|
245
|
+
queryText: (args) => extractQueryText(args[0]),
|
|
246
|
+
callbackStyle: "last-arg"
|
|
247
|
+
}) || instrumented;
|
|
248
|
+
instrumented = instrumentMethod(client, "execute", state, {
|
|
249
|
+
flagSuffix: "client:execute",
|
|
250
|
+
queryText: (args) => extractQueryText(args[0]),
|
|
251
|
+
callbackStyle: "last-arg"
|
|
252
|
+
}) || instrumented;
|
|
253
|
+
if (instrumented) client[INSTRUMENTED_FLAG] = true;
|
|
254
|
+
return client;
|
|
255
|
+
}
|
|
256
|
+
function instrumentDrizzleClient(db, config) {
|
|
257
|
+
if (!db || !isObject(db)) return db;
|
|
258
|
+
if (db[INSTRUMENTED_FLAG]) return db;
|
|
259
|
+
const state = getState(config);
|
|
260
|
+
let instrumented = false;
|
|
261
|
+
instrumented = instrumentSession(db, state) || instrumented;
|
|
262
|
+
if (isObject(db.session)) instrumented = instrumentSession(db.session, state) || instrumented;
|
|
263
|
+
if (isObject(db._?.session)) instrumented = instrumentSession(db._.session, state) || instrumented;
|
|
264
|
+
if (instrumented) db[INSTRUMENTED_FLAG] = true;
|
|
265
|
+
return db;
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
export { SEMATTRS_NET_PEER_NAME as C, SEMATTRS_GCP_BIGQUERY_STATEMENT_TYPE as S, SEMATTRS_GCP_BIGQUERY_QUERY_HASH as _, SEMATTRS_DB_NAMESPACE as a, SEMATTRS_GCP_BIGQUERY_SCHEMA_FIELDS as b, SEMATTRS_DB_QUERY_SUMMARY as c, SEMATTRS_DB_SYSTEM as d, SEMATTRS_DB_SYSTEM_NAME as f, SEMATTRS_GCP_BIGQUERY_PROJECT_ID as g, SEMATTRS_GCP_BIGQUERY_JOB_LOCATION as h, SEMATTRS_DB_NAME as i, SEMATTRS_DB_QUERY_TEXT as l, SEMATTRS_GCP_BIGQUERY_JOB_ID as m, instrumentDrizzleClient as n, SEMATTRS_DB_OPERATION as o, SEMATTRS_GCP_BIGQUERY_DESTINATION_TABLE as p, SEMATTRS_DB_COLLECTION_NAME as r, SEMATTRS_DB_OPERATION_NAME as s, instrumentDrizzle as t, SEMATTRS_DB_STATEMENT as u, SEMATTRS_GCP_BIGQUERY_ROWS_AFFECTED as v, SEMATTRS_NET_PEER_PORT as w, SEMATTRS_GCP_BIGQUERY_SOURCE_TABLES as x, SEMATTRS_GCP_BIGQUERY_ROWS_RETURNED as y };
|
|
269
|
+
|
|
270
|
+
//# sourceMappingURL=drizzle-C2xv1qdm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drizzle-C2xv1qdm.js","names":[],"sources":["../src/common/constants.ts","../src/drizzle/index.ts"],"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 * sha1 hex of the (parameterised, sanitized) statement text. Use to group\n * identical queries in observability tools — the raw `db.statement` is\n * usually unique per call due to inline params or comments, so high-\n * cardinality grouping by it is unhelpful. Example use: aggregate the top\n * 20 queries by total duration by `db.statement.hash`.\n */\nexport const SEMATTRS_DB_STATEMENT_HASH = 'db.statement.hash' 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 */\nimport { createHash } from 'node:crypto';\nimport { SpanKind, trace } from '@opentelemetry/api';\nimport {\n SEMATTRS_DB_NAME,\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_STATEMENT_HASH,\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n} from '../common/constants';\nimport { finalizeSpan, runWithSpan } from 'autotel/trace-helpers';\n\nconst DEFAULT_TRACER_NAME = 'autotel-plugins/drizzle';\nconst DEFAULT_DB_SYSTEM = 'postgresql';\nconst INSTRUMENTED_FLAG = '__autotelDrizzleInstrumented' as const;\nconst PREPARED_QUERY_METHODS = [\n 'all',\n 'execute',\n 'get',\n 'run',\n 'values',\n] as const;\n\ntype QueryCallback = (error: unknown, result: unknown) => void;\ntype QueryFunction = (...args: any[]) => any;\ntype AttributeValue = string | number | boolean;\ntype AttributeMap = Record<string, AttributeValue>;\n\ninterface InstrumentableObject {\n [key: string]: any;\n [INSTRUMENTED_FLAG]?: true;\n}\n\ninterface DrizzleClientLike extends InstrumentableObject {\n query?: QueryFunction;\n execute?: QueryFunction;\n}\n\ninterface DrizzleSessionLike extends InstrumentableObject {\n query?: QueryFunction;\n execute?: QueryFunction;\n prepareQuery?: QueryFunction;\n transaction?: QueryFunction;\n}\n\ninterface DrizzleDbLike extends InstrumentableObject {\n $client?: DrizzleClientLike;\n session?: DrizzleSessionLike;\n _?: {\n session?: DrizzleSessionLike;\n [key: string]: any;\n };\n}\n\nexport interface InstrumentDrizzleConfig {\n tracerName?: string;\n dbSystem?: string;\n dbName?: string;\n captureQueryText?: boolean;\n maxQueryTextLength?: number;\n peerName?: string;\n peerPort?: number;\n}\n\ninterface ResolvedConfig {\n tracerName: string;\n dbSystem: string;\n dbName?: string;\n captureQueryText: boolean;\n maxQueryTextLength: number;\n peerName?: string;\n peerPort?: number;\n}\n\ninterface InstrumentationState {\n tracer: ReturnType<typeof trace.getTracer>;\n config: ResolvedConfig;\n}\n\ninterface MethodInstrumentationOptions {\n flagSuffix: string;\n queryText: (args: any[]) => string | undefined;\n callbackStyle?: 'last-arg';\n extraAttributes?: AttributeMap;\n}\n\nfunction resolveConfig(config?: InstrumentDrizzleConfig): ResolvedConfig {\n return {\n tracerName: config?.tracerName ?? DEFAULT_TRACER_NAME,\n dbSystem: config?.dbSystem ?? DEFAULT_DB_SYSTEM,\n dbName: config?.dbName,\n captureQueryText: config?.captureQueryText ?? true,\n maxQueryTextLength: config?.maxQueryTextLength ?? 1000,\n peerName: config?.peerName,\n peerPort: config?.peerPort,\n };\n}\n\nfunction getState(config?: InstrumentDrizzleConfig): InstrumentationState {\n const resolved = resolveConfig(config);\n return {\n config: resolved,\n tracer: trace.getTracer(resolved.tracerName),\n };\n}\n\nfunction getFlagKey(suffix: string): string {\n return `${INSTRUMENTED_FLAG}:${suffix}`;\n}\n\nfunction isObject(value: unknown): value is InstrumentableObject {\n return value !== null && typeof value === 'object';\n}\n\nfunction isPromiseLike<T>(value: T | PromiseLike<T>): value is PromiseLike<T> {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as PromiseLike<T>).then === 'function'\n );\n}\n\nfunction extractQueryText(queryArg: unknown): string | undefined {\n if (typeof queryArg === 'string') {\n return queryArg;\n }\n\n if (!isObject(queryArg)) {\n return undefined;\n }\n\n if (typeof queryArg.sql === 'string') {\n return queryArg.sql;\n }\n\n if (typeof queryArg.text === 'string') {\n return queryArg.text;\n }\n\n if (typeof queryArg.queryString === 'string') {\n return queryArg.queryString;\n }\n\n if (\n isObject(queryArg.queryChunks) &&\n typeof (queryArg as Record<string, unknown>).sql === 'string'\n ) {\n return queryArg.sql as string;\n }\n\n return undefined;\n}\n\nfunction sanitizeQueryText(queryText: string, maxLength: number): string {\n if (queryText.length <= maxLength) {\n return queryText;\n }\n\n return `${queryText.slice(0, Math.max(0, maxLength))}...`;\n}\n\n/**\n * Stable sha1 of a parameterised SQL statement, used as `db.statement.hash`.\n * Hashes the full original text (not the truncated form) so the hash is\n * identical for queries that only differ in trailing length. We keep this\n * cheap (sha1, hex, take 16 chars) — the goal is grouping, not crypto.\n */\nfunction hashQueryText(queryText: string): string {\n return createHash('sha1').update(queryText).digest('hex').slice(0, 16);\n}\n\nfunction extractOperation(queryText: string): string | undefined {\n const trimmed = queryText.trimStart();\n const match = /^(?<operation>\\w+)/u.exec(trimmed);\n return match?.groups?.operation?.toUpperCase();\n}\n\nfunction buildSpan(\n state: InstrumentationState,\n queryText: string | undefined,\n extraAttributes?: AttributeMap,\n) {\n const operation = queryText ? extractOperation(queryText) : undefined;\n const spanName = operation\n ? `drizzle.${operation.toLowerCase()}`\n : 'drizzle.query';\n const span = state.tracer.startSpan(spanName, { kind: SpanKind.CLIENT });\n\n span.setAttribute(SEMATTRS_DB_SYSTEM, state.config.dbSystem);\n\n if (operation) {\n span.setAttribute(SEMATTRS_DB_OPERATION, operation);\n }\n\n if (state.config.dbName !== undefined) {\n span.setAttribute(SEMATTRS_DB_NAME, state.config.dbName);\n }\n\n if (queryText !== undefined) {\n // The hash always lives on the span — even when captureQueryText is off\n // (e.g. for privacy / size reasons) — so query grouping still works.\n span.setAttribute(SEMATTRS_DB_STATEMENT_HASH, hashQueryText(queryText));\n }\n\n if (state.config.captureQueryText && queryText !== undefined) {\n span.setAttribute(\n SEMATTRS_DB_STATEMENT,\n sanitizeQueryText(queryText, state.config.maxQueryTextLength),\n );\n }\n\n if (state.config.peerName !== undefined) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, state.config.peerName);\n }\n\n if (state.config.peerPort !== undefined) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, state.config.peerPort);\n }\n\n if (extraAttributes) {\n for (const [key, value] of Object.entries(extraAttributes)) {\n span.setAttribute(key, value);\n }\n }\n\n return span;\n}\n\nfunction executeWithSpan<T>(span: any, fn: () => T): T {\n return runWithSpan(span, () => {\n try {\n const result = fn();\n\n if (isPromiseLike(result)) {\n return result.then(\n (value) => {\n finalizeSpan(span);\n return value;\n },\n (error) => {\n finalizeSpan(span, error);\n throw error;\n },\n ) as T;\n }\n\n finalizeSpan(span);\n return result;\n } catch (error) {\n finalizeSpan(span, error);\n throw error;\n }\n });\n}\n\nfunction instrumentMethod(\n target: InstrumentableObject,\n methodName: string,\n state: InstrumentationState,\n options: MethodInstrumentationOptions,\n): boolean {\n if (typeof target[methodName] !== 'function') {\n return false;\n }\n\n const flagKey = getFlagKey(options.flagSuffix);\n if (target[flagKey]) {\n return false;\n }\n\n const originalMethod = target[methodName] as QueryFunction;\n\n target[methodName] = function instrumentedMethod(\n this: any,\n ...incomingArgs: any[]\n ) {\n const args = [...incomingArgs];\n const callback =\n options.callbackStyle === 'last-arg' && typeof args.at(-1) === 'function'\n ? (args.pop() as QueryCallback)\n : undefined;\n const span = buildSpan(\n state,\n options.queryText(args),\n options.extraAttributes,\n );\n\n if (callback) {\n return runWithSpan(span, () => {\n const wrappedCallback: QueryCallback = (error, result) => {\n finalizeSpan(span, error);\n callback(error, result);\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 return executeWithSpan(span, () =>\n Reflect.apply(originalMethod, this, args),\n );\n };\n\n target[flagKey] = true;\n return true;\n}\n\nfunction instrumentPreparedQuery(\n prepared: unknown,\n state: InstrumentationState,\n querySource: unknown,\n extraAttributes?: AttributeMap,\n): boolean {\n if (!isObject(prepared)) {\n return false;\n }\n\n let instrumented = false;\n const queryText = extractQueryText(querySource);\n\n for (const methodName of PREPARED_QUERY_METHODS) {\n instrumented =\n instrumentMethod(prepared, methodName, state, {\n flagSuffix: `prepared:${methodName}`,\n queryText: () => queryText,\n extraAttributes,\n }) || instrumented;\n }\n\n return instrumented;\n}\n\nfunction instrumentPrepareQuery(\n target: DrizzleSessionLike,\n state: InstrumentationState,\n extraAttributes?: AttributeMap,\n): boolean {\n if (typeof target.prepareQuery !== 'function') {\n return false;\n }\n\n const flagKey = getFlagKey('prepareQuery');\n if (target[flagKey]) {\n return false;\n }\n\n const originalPrepareQuery = target.prepareQuery;\n\n target.prepareQuery = function instrumentedPrepareQuery(\n this: any,\n ...prepareArgs: any[]\n ) {\n const prepared = Reflect.apply(originalPrepareQuery, this, prepareArgs);\n instrumentPreparedQuery(prepared, state, prepareArgs[0], extraAttributes);\n return prepared;\n };\n\n target[flagKey] = true;\n return true;\n}\n\nfunction instrumentTransactionTarget(\n target: unknown,\n state: InstrumentationState,\n): boolean {\n if (!isObject(target)) {\n return false;\n }\n\n const transactionAttributes = { 'db.transaction': true };\n let instrumented = false;\n\n instrumented =\n instrumentMethod(target, 'query', state, {\n flagSuffix: 'transaction:query',\n queryText: (args) => extractQueryText(args[0]),\n callbackStyle: 'last-arg',\n extraAttributes: transactionAttributes,\n }) || instrumented;\n\n instrumented =\n instrumentMethod(target, 'execute', state, {\n flagSuffix: 'transaction:execute',\n queryText: (args) => extractQueryText(args[0]),\n callbackStyle: 'last-arg',\n extraAttributes: transactionAttributes,\n }) || instrumented;\n\n instrumented =\n instrumentPrepareQuery(\n target as DrizzleSessionLike,\n state,\n transactionAttributes,\n ) || instrumented;\n\n if (isObject(target.session)) {\n instrumented =\n instrumentTransactionTarget(target.session, state) || instrumented;\n }\n\n if (isObject(target._?.session)) {\n instrumented =\n instrumentTransactionTarget(target._.session, state) || instrumented;\n }\n\n return instrumented;\n}\n\nfunction instrumentSession(\n session: DrizzleSessionLike,\n state: InstrumentationState,\n): boolean {\n let instrumented = false;\n\n instrumented =\n instrumentMethod(session, 'query', state, {\n flagSuffix: 'session:query',\n queryText: (args) => extractQueryText(args[0]),\n callbackStyle: 'last-arg',\n }) || instrumented;\n\n instrumented =\n instrumentMethod(session, 'execute', state, {\n flagSuffix: 'session:execute',\n queryText: (args) => extractQueryText(args[0]),\n callbackStyle: 'last-arg',\n }) || instrumented;\n\n instrumented = instrumentPrepareQuery(session, state) || instrumented;\n\n if (typeof session.transaction === 'function') {\n const flagKey = getFlagKey('session:transaction');\n\n if (!session[flagKey]) {\n const originalTransaction = session.transaction;\n\n session.transaction = function instrumentedTransaction(\n this: any,\n callback: QueryFunction,\n ...restArgs: any[]\n ) {\n if (typeof callback !== 'function') {\n return Reflect.apply(originalTransaction, this, [\n callback,\n ...restArgs,\n ]);\n }\n\n const wrappedCallback = (tx: unknown, ...callbackArgs: any[]) => {\n instrumentTransactionTarget(tx, state);\n return Reflect.apply(callback, this, [tx, ...callbackArgs]);\n };\n\n return Reflect.apply(originalTransaction, this, [\n wrappedCallback,\n ...restArgs,\n ]);\n };\n\n session[flagKey] = true;\n instrumented = true;\n }\n }\n\n if (instrumented) {\n session[INSTRUMENTED_FLAG] = true;\n }\n\n return instrumented;\n}\n\nexport function instrumentDrizzle<TClient extends DrizzleClientLike>(\n client: TClient,\n config?: InstrumentDrizzleConfig,\n): TClient {\n if (!client || !isObject(client)) {\n return client;\n }\n\n const state = getState(config);\n let instrumented = false;\n\n instrumented =\n instrumentMethod(client, 'query', state, {\n flagSuffix: 'client:query',\n queryText: (args) => extractQueryText(args[0]),\n callbackStyle: 'last-arg',\n }) || instrumented;\n\n instrumented =\n instrumentMethod(client, 'execute', state, {\n flagSuffix: 'client:execute',\n queryText: (args) => extractQueryText(args[0]),\n callbackStyle: 'last-arg',\n }) || instrumented;\n\n if (instrumented) {\n client[INSTRUMENTED_FLAG] = true;\n }\n\n return client;\n}\n\nexport function instrumentDrizzleClient<TDb extends DrizzleDbLike>(\n db: TDb,\n config?: InstrumentDrizzleConfig,\n): TDb {\n if (!db || !isObject(db)) {\n return db;\n }\n\n if (db[INSTRUMENTED_FLAG]) {\n return db;\n }\n\n const state = getState(config);\n let instrumented = false;\n\n instrumented =\n instrumentSession(db as unknown as DrizzleSessionLike, state) ||\n instrumented;\n\n if (isObject(db.session)) {\n instrumented = instrumentSession(db.session, state) || instrumented;\n }\n\n if (isObject(db._?.session)) {\n instrumented = instrumentSession(db._.session, state) || instrumented;\n }\n\n // Intentionally do NOT instrument db.$client here. The raw client (e.g.\n // pg.Pool) is the same object that drizzle's session invokes internally from\n // its prepared query's execute(). Wrapping both layers produces nested\n // duplicate spans for every query. Users who need to trace a standalone\n // client without a drizzle wrapper should call `instrumentDrizzle` directly.\n\n if (instrumented) {\n db[INSTRUMENTED_FLAG] = true;\n }\n\n return db;\n}\n"],"mappings":";;;;;;;;AAMA,MAAa,qBAAqB;AAClC,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAChC,MAAa,wBAAwB;AACrC,MAAa,8BAA8B;AAC3C,MAAa,6BAA6B;AAC1C,MAAa,yBAAyB;AACtC,MAAa,4BAA4B;;;;;;;;AAQzC,MAAa,6BAA6B;AAM1C,MAAa,yBAAyB;AACtC,MAAa,yBAAyB;AAwBtC,MAAa,+BAA+B;AAC5C,MAAa,qCACX;AACF,MAAa,mCACX;AACF,MAAa,0CACX;AACF,MAAa,sCACX;AACF,MAAa,uCACX;AACF,MAAa,mCACX;AACF,MAAa,sCACX;AACF,MAAa,sCACX;AACF,MAAa,sCACX;;;AC1DF,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB;AA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