@use-tusk/drift-node-sdk 0.1.21 → 0.1.23
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/index.cjs +498 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +498 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11139,13 +11139,23 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11139
11139
|
let requestOptions;
|
|
11140
11140
|
if (typeof args[0] === "string") {
|
|
11141
11141
|
const url = new URL(args[0]);
|
|
11142
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11142
11143
|
requestOptions = {
|
|
11143
11144
|
protocol: url.protocol,
|
|
11144
11145
|
hostname: url.hostname,
|
|
11145
11146
|
port: url.port ? parseInt(url.port) : void 0,
|
|
11146
11147
|
path: url.pathname + url.search,
|
|
11147
|
-
method:
|
|
11148
|
-
headers:
|
|
11148
|
+
method: additionalOptions?.method || "GET",
|
|
11149
|
+
headers: additionalOptions?.headers || {}
|
|
11150
|
+
};
|
|
11151
|
+
} else if (self._isURLObject(args[0])) {
|
|
11152
|
+
const url = args[0];
|
|
11153
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11154
|
+
requestOptions = {
|
|
11155
|
+
...self._urlToRequestOptions(url),
|
|
11156
|
+
method: additionalOptions?.method || "GET",
|
|
11157
|
+
headers: additionalOptions?.headers || {},
|
|
11158
|
+
...additionalOptions
|
|
11149
11159
|
};
|
|
11150
11160
|
} else requestOptions = args[0] || {};
|
|
11151
11161
|
const method = requestOptions.method || "GET";
|
|
@@ -11235,12 +11245,21 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11235
11245
|
let requestOptions;
|
|
11236
11246
|
if (typeof args[0] === "string") {
|
|
11237
11247
|
const url = new URL(args[0]);
|
|
11248
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11238
11249
|
requestOptions = {
|
|
11239
11250
|
protocol: url.protocol,
|
|
11240
11251
|
hostname: url.hostname,
|
|
11241
11252
|
port: url.port ? parseInt(url.port) : void 0,
|
|
11242
11253
|
path: url.pathname + url.search,
|
|
11243
|
-
headers:
|
|
11254
|
+
headers: additionalOptions?.headers || {}
|
|
11255
|
+
};
|
|
11256
|
+
} else if (self._isURLObject(args[0])) {
|
|
11257
|
+
const url = args[0];
|
|
11258
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11259
|
+
requestOptions = {
|
|
11260
|
+
...self._urlToRequestOptions(url),
|
|
11261
|
+
headers: additionalOptions?.headers || {},
|
|
11262
|
+
...additionalOptions
|
|
11244
11263
|
};
|
|
11245
11264
|
} else requestOptions = args[0] || {};
|
|
11246
11265
|
const method = "GET";
|
|
@@ -11346,6 +11365,25 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11346
11365
|
};
|
|
11347
11366
|
};
|
|
11348
11367
|
}
|
|
11368
|
+
/**
|
|
11369
|
+
* Check if the input is a URL object (WHATWG URL API)
|
|
11370
|
+
* This is used to detect when a URL object is passed to http.get/request
|
|
11371
|
+
*/
|
|
11372
|
+
_isURLObject(input) {
|
|
11373
|
+
return input instanceof URL || input && typeof input.href === "string" && typeof input.pathname === "string";
|
|
11374
|
+
}
|
|
11375
|
+
/**
|
|
11376
|
+
* Convert a URL object to RequestOptions
|
|
11377
|
+
* Similar to Node.js's internal urlToHttpOptions function
|
|
11378
|
+
*/
|
|
11379
|
+
_urlToRequestOptions(url) {
|
|
11380
|
+
return {
|
|
11381
|
+
protocol: url.protocol,
|
|
11382
|
+
hostname: url.hostname,
|
|
11383
|
+
port: url.port ? parseInt(url.port) : void 0,
|
|
11384
|
+
path: url.pathname + (url.search || "")
|
|
11385
|
+
};
|
|
11386
|
+
}
|
|
11349
11387
|
_normalizeProtocol(protocol, fallback) {
|
|
11350
11388
|
if (!protocol) return fallback;
|
|
11351
11389
|
const normalized = protocol.toLowerCase().replace(/:$/, "");
|
|
@@ -11723,6 +11761,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11723
11761
|
packageName,
|
|
11724
11762
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
11725
11763
|
inputValue,
|
|
11764
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
11726
11765
|
isPreAppStart: false
|
|
11727
11766
|
}, (spanInfo) => {
|
|
11728
11767
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, stackTrace);
|
|
@@ -11742,6 +11781,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11742
11781
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
11743
11782
|
packageName,
|
|
11744
11783
|
inputValue,
|
|
11784
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
11745
11785
|
isPreAppStart
|
|
11746
11786
|
}, (spanInfo) => {
|
|
11747
11787
|
return self._handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, this);
|
|
@@ -11918,7 +11958,8 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11918
11958
|
kind: import_src$29.SpanKind.CLIENT,
|
|
11919
11959
|
stackTrace
|
|
11920
11960
|
},
|
|
11921
|
-
tuskDrift: this.tuskDrift
|
|
11961
|
+
tuskDrift: this.tuskDrift,
|
|
11962
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
11922
11963
|
});
|
|
11923
11964
|
if (!mockData) {
|
|
11924
11965
|
const queryText = queryConfig.text || inputValue.text || "UNKNOWN_QUERY";
|
|
@@ -12781,6 +12822,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12781
12822
|
packageName: "postgres",
|
|
12782
12823
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
12783
12824
|
inputValue,
|
|
12825
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
12784
12826
|
isPreAppStart
|
|
12785
12827
|
}, (spanInfo) => {
|
|
12786
12828
|
const wrappedOnFulfilled = (result) => {
|
|
@@ -12828,6 +12870,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12828
12870
|
packageName: "postgres",
|
|
12829
12871
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
12830
12872
|
inputValue,
|
|
12873
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
12831
12874
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
12832
12875
|
}, async (spanInfo) => {
|
|
12833
12876
|
const mockedResult = await self._handleReplayQueryOperation({
|
|
@@ -13030,7 +13073,8 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13030
13073
|
kind: import_src$27.SpanKind.CLIENT,
|
|
13031
13074
|
stackTrace
|
|
13032
13075
|
},
|
|
13033
|
-
tuskDrift: this.tuskDrift
|
|
13076
|
+
tuskDrift: this.tuskDrift,
|
|
13077
|
+
inputValueSchemaMerges: { parameters: { matchImportance: 0 } }
|
|
13034
13078
|
});
|
|
13035
13079
|
}
|
|
13036
13080
|
/**
|
|
@@ -13084,6 +13128,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13084
13128
|
packageName: "postgres",
|
|
13085
13129
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13086
13130
|
inputValue,
|
|
13131
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13087
13132
|
isPreAppStart
|
|
13088
13133
|
}, (spanInfo) => {
|
|
13089
13134
|
return self._executeAndRecordCursorCallback({
|
|
@@ -13142,6 +13187,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13142
13187
|
packageName: "postgres",
|
|
13143
13188
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13144
13189
|
inputValue,
|
|
13190
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13145
13191
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13146
13192
|
}, async (spanInfo) => {
|
|
13147
13193
|
try {
|
|
@@ -13343,6 +13389,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13343
13389
|
packageName: "postgres",
|
|
13344
13390
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13345
13391
|
inputValue,
|
|
13392
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13346
13393
|
isPreAppStart
|
|
13347
13394
|
}, async (spanInfo) => {
|
|
13348
13395
|
const allRows = [];
|
|
@@ -13397,6 +13444,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13397
13444
|
packageName: "postgres",
|
|
13398
13445
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13399
13446
|
inputValue,
|
|
13447
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13400
13448
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13401
13449
|
}, async (spanInfo) => {
|
|
13402
13450
|
try {
|
|
@@ -13451,6 +13499,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13451
13499
|
packageName: "postgres",
|
|
13452
13500
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13453
13501
|
inputValue,
|
|
13502
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13454
13503
|
isPreAppStart
|
|
13455
13504
|
}, (spanInfo) => {
|
|
13456
13505
|
const wrappedOnFulfilled = (result) => {
|
|
@@ -13498,6 +13547,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13498
13547
|
packageName: "postgres",
|
|
13499
13548
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13500
13549
|
inputValue,
|
|
13550
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13501
13551
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13502
13552
|
}, async (spanInfo) => {
|
|
13503
13553
|
const mockedResult = await self._handleReplayQueryOperation({
|
|
@@ -13897,7 +13947,8 @@ var TdMysqlQueryMock = class {
|
|
|
13897
13947
|
kind: import_src$26.SpanKind.CLIENT,
|
|
13898
13948
|
stackTrace
|
|
13899
13949
|
},
|
|
13900
|
-
tuskDrift: this.tuskDrift
|
|
13950
|
+
tuskDrift: this.tuskDrift,
|
|
13951
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
13901
13952
|
});
|
|
13902
13953
|
}
|
|
13903
13954
|
};
|
|
@@ -14153,6 +14204,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14153
14204
|
packageName: "mysql",
|
|
14154
14205
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14155
14206
|
inputValue,
|
|
14207
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14156
14208
|
isPreAppStart: false
|
|
14157
14209
|
}, (spanInfo) => {
|
|
14158
14210
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -14179,6 +14231,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14179
14231
|
packageName: "mysql",
|
|
14180
14232
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14181
14233
|
inputValue,
|
|
14234
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14182
14235
|
isPreAppStart
|
|
14183
14236
|
}, (spanInfo) => {
|
|
14184
14237
|
return self._handleRecordQuery(spanInfo, originalQuery, this, args, callback, isEventEmitterMode);
|
|
@@ -14201,11 +14254,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14201
14254
|
const connectionContext = this;
|
|
14202
14255
|
return handleReplayMode({
|
|
14203
14256
|
noOpRequestHandler: () => {
|
|
14257
|
+
connectionContext.state = "authenticated";
|
|
14204
14258
|
if (callback) setImmediate(() => callback(null));
|
|
14205
14259
|
setImmediate(() => connectionContext.emit("connect"));
|
|
14206
14260
|
},
|
|
14207
14261
|
isServerRequest: false,
|
|
14208
14262
|
replayModeHandler: () => {
|
|
14263
|
+
connectionContext.state = "authenticated";
|
|
14209
14264
|
if (callback) setImmediate(() => callback(null));
|
|
14210
14265
|
setImmediate(() => connectionContext.emit("connect"));
|
|
14211
14266
|
}
|
|
@@ -14626,6 +14681,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14626
14681
|
packageName: "mysql",
|
|
14627
14682
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14628
14683
|
inputValue,
|
|
14684
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14629
14685
|
isPreAppStart: false
|
|
14630
14686
|
}, (spanInfo) => {
|
|
14631
14687
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -14652,6 +14708,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14652
14708
|
packageName: "mysql",
|
|
14653
14709
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14654
14710
|
inputValue,
|
|
14711
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14655
14712
|
isPreAppStart
|
|
14656
14713
|
}, (spanInfo) => {
|
|
14657
14714
|
return self._handleRecordQuery(spanInfo, originalQuery, connection, args, callback, isEventEmitterMode);
|
|
@@ -14771,10 +14828,12 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14771
14828
|
return function connect(callback) {
|
|
14772
14829
|
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
14773
14830
|
noOpRequestHandler: () => {
|
|
14831
|
+
connection.state = "authenticated";
|
|
14774
14832
|
if (callback) setImmediate(() => callback(null));
|
|
14775
14833
|
},
|
|
14776
14834
|
isServerRequest: false,
|
|
14777
14835
|
replayModeHandler: () => {
|
|
14836
|
+
connection.state = "authenticated";
|
|
14778
14837
|
if (callback) setImmediate(() => callback(null));
|
|
14779
14838
|
}
|
|
14780
14839
|
});
|
|
@@ -15113,6 +15172,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15113
15172
|
packageName: "mysql",
|
|
15114
15173
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15115
15174
|
inputValue,
|
|
15175
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15116
15176
|
isPreAppStart: false
|
|
15117
15177
|
}, (spanInfo) => {
|
|
15118
15178
|
return self._handleReplayStream(inputValue, spanInfo, stackTrace, queryInstance);
|
|
@@ -15130,6 +15190,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15130
15190
|
packageName: "mysql",
|
|
15131
15191
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15132
15192
|
inputValue,
|
|
15193
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15133
15194
|
isPreAppStart
|
|
15134
15195
|
}, (spanInfo) => {
|
|
15135
15196
|
return self._handleRecordStream(spanInfo, originalStream, queryInstance, streamOptions);
|
|
@@ -15341,6 +15402,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15341
15402
|
packageName: "mysql",
|
|
15342
15403
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15343
15404
|
inputValue,
|
|
15405
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15344
15406
|
isPreAppStart: false
|
|
15345
15407
|
}, (spanInfo) => {
|
|
15346
15408
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -15536,6 +15598,27 @@ var TdMysql2ConnectionMock = class extends EventEmitter {
|
|
|
15536
15598
|
}
|
|
15537
15599
|
return Promise.resolve();
|
|
15538
15600
|
}
|
|
15601
|
+
prepare(sql, callback) {
|
|
15602
|
+
const sqlStr = typeof sql === "string" ? sql : sql.sql;
|
|
15603
|
+
const self = this;
|
|
15604
|
+
const mockStatement = {
|
|
15605
|
+
query: sqlStr,
|
|
15606
|
+
id: 1,
|
|
15607
|
+
columns: [],
|
|
15608
|
+
parameters: [],
|
|
15609
|
+
execute: (...args) => {
|
|
15610
|
+
const values = Array.isArray(args[0]) ? args[0] : [];
|
|
15611
|
+
const execCallback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
15612
|
+
return self.mysql2Instrumentation.handleNoOpReplayQuery({
|
|
15613
|
+
sql: sqlStr,
|
|
15614
|
+
values,
|
|
15615
|
+
callback: execCallback
|
|
15616
|
+
});
|
|
15617
|
+
},
|
|
15618
|
+
close: () => {}
|
|
15619
|
+
};
|
|
15620
|
+
if (callback) process.nextTick(() => callback(null, mockStatement));
|
|
15621
|
+
}
|
|
15539
15622
|
pause() {}
|
|
15540
15623
|
resume() {}
|
|
15541
15624
|
escape(value) {
|
|
@@ -15592,6 +15675,10 @@ var TdMysql2QueryMock = class {
|
|
|
15592
15675
|
});
|
|
15593
15676
|
}).then(onResolve, onReject);
|
|
15594
15677
|
};
|
|
15678
|
+
const self = this;
|
|
15679
|
+
emitter.stream = function(streamOptions) {
|
|
15680
|
+
return self._createReplayStreamForQuery(emitter, streamOptions);
|
|
15681
|
+
};
|
|
15595
15682
|
process.nextTick(() => {
|
|
15596
15683
|
const callback = queryConfig.callback;
|
|
15597
15684
|
if (callback) callback(null, [], []);
|
|
@@ -15618,6 +15705,10 @@ var TdMysql2QueryMock = class {
|
|
|
15618
15705
|
});
|
|
15619
15706
|
}).then(onResolve, onReject);
|
|
15620
15707
|
};
|
|
15708
|
+
const self = this;
|
|
15709
|
+
emitter.stream = function(streamOptions) {
|
|
15710
|
+
return self._createReplayStreamForQuery(emitter, streamOptions);
|
|
15711
|
+
};
|
|
15621
15712
|
(async () => {
|
|
15622
15713
|
try {
|
|
15623
15714
|
const mockData = await this._fetchMockData(inputValue, spanInfo, spanName, submoduleName, stackTrace);
|
|
@@ -15661,8 +15752,46 @@ var TdMysql2QueryMock = class {
|
|
|
15661
15752
|
kind: import_src$24.SpanKind.CLIENT,
|
|
15662
15753
|
stackTrace
|
|
15663
15754
|
},
|
|
15664
|
-
tuskDrift: this.tuskDrift
|
|
15755
|
+
tuskDrift: this.tuskDrift,
|
|
15756
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
15757
|
+
});
|
|
15758
|
+
}
|
|
15759
|
+
/**
|
|
15760
|
+
* Create a replay stream for query.stream() calls
|
|
15761
|
+
* This is called when user calls query.stream() on a query object
|
|
15762
|
+
*/
|
|
15763
|
+
_createReplayStreamForQuery(queryEmitter, streamOptions) {
|
|
15764
|
+
logger.debug(`[Mysql2Instrumentation] Creating replay stream for query.stream()`);
|
|
15765
|
+
const readableStream = new Readable({
|
|
15766
|
+
objectMode: true,
|
|
15767
|
+
read() {}
|
|
15768
|
+
});
|
|
15769
|
+
queryEmitter.on("result", (row) => {
|
|
15770
|
+
readableStream.push(row);
|
|
15771
|
+
});
|
|
15772
|
+
queryEmitter.on("error", (err) => {
|
|
15773
|
+
readableStream.destroy(err);
|
|
15774
|
+
});
|
|
15775
|
+
queryEmitter.on("end", () => {
|
|
15776
|
+
readableStream.push(null);
|
|
15665
15777
|
});
|
|
15778
|
+
return readableStream;
|
|
15779
|
+
}
|
|
15780
|
+
/**
|
|
15781
|
+
* Recursively restore Buffer objects from their JSON serialized form.
|
|
15782
|
+
* JSON.stringify converts Buffer to {"type":"Buffer","data":[...]}
|
|
15783
|
+
* This function converts them back to actual Buffer instances.
|
|
15784
|
+
*/
|
|
15785
|
+
_restoreBuffers(obj) {
|
|
15786
|
+
if (obj === null || obj === void 0) return obj;
|
|
15787
|
+
if (typeof obj === "object" && obj.type === "Buffer" && Array.isArray(obj.data)) return Buffer.from(obj.data);
|
|
15788
|
+
if (Array.isArray(obj)) return obj.map((item) => this._restoreBuffers(item));
|
|
15789
|
+
if (typeof obj === "object") {
|
|
15790
|
+
const result = {};
|
|
15791
|
+
for (const key of Object.keys(obj)) result[key] = this._restoreBuffers(obj[key]);
|
|
15792
|
+
return result;
|
|
15793
|
+
}
|
|
15794
|
+
return obj;
|
|
15666
15795
|
}
|
|
15667
15796
|
/**
|
|
15668
15797
|
* Convert stored MySQL2 values back to appropriate JavaScript types
|
|
@@ -15672,12 +15801,17 @@ var TdMysql2QueryMock = class {
|
|
|
15672
15801
|
rows: [],
|
|
15673
15802
|
fields: []
|
|
15674
15803
|
};
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15804
|
+
const restoredResult = this._restoreBuffers(result);
|
|
15805
|
+
if (restoredResult.rows !== void 0 && restoredResult.fields !== void 0) return {
|
|
15806
|
+
rows: restoredResult.rows,
|
|
15807
|
+
fields: restoredResult.fields
|
|
15808
|
+
};
|
|
15809
|
+
if (restoredResult.affectedRows !== void 0) return {
|
|
15810
|
+
rows: restoredResult,
|
|
15811
|
+
fields: []
|
|
15678
15812
|
};
|
|
15679
15813
|
return {
|
|
15680
|
-
rows:
|
|
15814
|
+
rows: restoredResult,
|
|
15681
15815
|
fields: []
|
|
15682
15816
|
};
|
|
15683
15817
|
}
|
|
@@ -15822,6 +15956,18 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15822
15956
|
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.end`);
|
|
15823
15957
|
}
|
|
15824
15958
|
}
|
|
15959
|
+
if (BaseConnectionClass.prototype && BaseConnectionClass.prototype.prepare) {
|
|
15960
|
+
if (!isWrapped$1(BaseConnectionClass.prototype.prepare)) {
|
|
15961
|
+
this._wrap(BaseConnectionClass.prototype, "prepare", this._getPreparePatchFn("connection"));
|
|
15962
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.prepare`);
|
|
15963
|
+
}
|
|
15964
|
+
}
|
|
15965
|
+
if (BaseConnectionClass.prototype && BaseConnectionClass.prototype.changeUser) {
|
|
15966
|
+
if (!isWrapped$1(BaseConnectionClass.prototype.changeUser)) {
|
|
15967
|
+
this._wrap(BaseConnectionClass.prototype, "changeUser", this._getChangeUserPatchFn("connection"));
|
|
15968
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.changeUser`);
|
|
15969
|
+
}
|
|
15970
|
+
}
|
|
15825
15971
|
this.markModuleAsPatched(BaseConnectionClass);
|
|
15826
15972
|
logger.debug(`[Mysql2Instrumentation] BaseConnection class patching complete`);
|
|
15827
15973
|
return BaseConnectionClass;
|
|
@@ -15873,6 +16019,18 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15873
16019
|
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.end`);
|
|
15874
16020
|
}
|
|
15875
16021
|
}
|
|
16022
|
+
if (ConnectionClass.prototype && ConnectionClass.prototype.prepare) {
|
|
16023
|
+
if (!isWrapped$1(ConnectionClass.prototype.prepare)) {
|
|
16024
|
+
this._wrap(ConnectionClass.prototype, "prepare", this._getPreparePatchFn("connection"));
|
|
16025
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.prepare`);
|
|
16026
|
+
}
|
|
16027
|
+
}
|
|
16028
|
+
if (ConnectionClass.prototype && ConnectionClass.prototype.changeUser) {
|
|
16029
|
+
if (!isWrapped$1(ConnectionClass.prototype.changeUser)) {
|
|
16030
|
+
this._wrap(ConnectionClass.prototype, "changeUser", this._getChangeUserPatchFn("connection"));
|
|
16031
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.changeUser`);
|
|
16032
|
+
}
|
|
16033
|
+
}
|
|
15876
16034
|
}
|
|
15877
16035
|
_patchPoolV2(PoolClass) {
|
|
15878
16036
|
logger.debug(`[Mysql2Instrumentation] Patching Pool class (v2)`);
|
|
@@ -15966,6 +16124,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15966
16124
|
packageName: "mysql2",
|
|
15967
16125
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15968
16126
|
inputValue,
|
|
16127
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15969
16128
|
isPreAppStart: false
|
|
15970
16129
|
}, (spanInfo) => {
|
|
15971
16130
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "query", stackTrace);
|
|
@@ -15984,6 +16143,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15984
16143
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15985
16144
|
packageName: "mysql2",
|
|
15986
16145
|
inputValue,
|
|
16146
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15987
16147
|
isPreAppStart
|
|
15988
16148
|
}, (spanInfo) => {
|
|
15989
16149
|
return self._handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, this);
|
|
@@ -16031,6 +16191,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16031
16191
|
packageName: "mysql2",
|
|
16032
16192
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16033
16193
|
inputValue,
|
|
16194
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16034
16195
|
isPreAppStart: false
|
|
16035
16196
|
}, (spanInfo) => {
|
|
16036
16197
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "execute", stackTrace);
|
|
@@ -16049,6 +16210,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16049
16210
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16050
16211
|
packageName: "mysql2",
|
|
16051
16212
|
inputValue,
|
|
16213
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16052
16214
|
isPreAppStart
|
|
16053
16215
|
}, (spanInfo) => {
|
|
16054
16216
|
return self._handleRecordQueryInSpan(spanInfo, originalExecute, queryConfig, args, this);
|
|
@@ -16272,6 +16434,251 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16272
16434
|
};
|
|
16273
16435
|
};
|
|
16274
16436
|
}
|
|
16437
|
+
_getChangeUserPatchFn(clientType) {
|
|
16438
|
+
const self = this;
|
|
16439
|
+
return (originalChangeUser) => {
|
|
16440
|
+
return function changeUser(options, callback) {
|
|
16441
|
+
if (typeof options === "function") {
|
|
16442
|
+
callback = options;
|
|
16443
|
+
options = {};
|
|
16444
|
+
}
|
|
16445
|
+
const inputValue = { clientType };
|
|
16446
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16447
|
+
noOpRequestHandler: () => {
|
|
16448
|
+
if (callback) {
|
|
16449
|
+
process.nextTick(() => callback(null));
|
|
16450
|
+
return;
|
|
16451
|
+
}
|
|
16452
|
+
return Promise.resolve();
|
|
16453
|
+
},
|
|
16454
|
+
isServerRequest: false,
|
|
16455
|
+
replayModeHandler: () => {
|
|
16456
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalChangeUser.apply(this, [options, callback]), {
|
|
16457
|
+
name: `mysql2.${clientType}.changeUser`,
|
|
16458
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16459
|
+
submodule: "changeUser",
|
|
16460
|
+
packageName: "mysql2",
|
|
16461
|
+
packageType: PackageType.MYSQL,
|
|
16462
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16463
|
+
inputValue,
|
|
16464
|
+
isPreAppStart: false
|
|
16465
|
+
}, (spanInfo) => {
|
|
16466
|
+
if (callback) {
|
|
16467
|
+
process.nextTick(() => callback(null));
|
|
16468
|
+
return;
|
|
16469
|
+
}
|
|
16470
|
+
return Promise.resolve();
|
|
16471
|
+
});
|
|
16472
|
+
}
|
|
16473
|
+
});
|
|
16474
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16475
|
+
originalFunctionCall: () => originalChangeUser.apply(this, [options, callback]),
|
|
16476
|
+
recordModeHandler: ({ isPreAppStart }) => {
|
|
16477
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalChangeUser.apply(this, [options, callback]), {
|
|
16478
|
+
name: `mysql2.${clientType}.changeUser`,
|
|
16479
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16480
|
+
submodule: "changeUser",
|
|
16481
|
+
packageName: "mysql2",
|
|
16482
|
+
packageType: PackageType.MYSQL,
|
|
16483
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16484
|
+
inputValue,
|
|
16485
|
+
isPreAppStart
|
|
16486
|
+
}, (spanInfo) => {
|
|
16487
|
+
return self._handleSimpleCallbackMethod(spanInfo, originalChangeUser.bind(this, options), callback, this);
|
|
16488
|
+
});
|
|
16489
|
+
},
|
|
16490
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16491
|
+
});
|
|
16492
|
+
else return originalChangeUser.apply(this, [options, callback]);
|
|
16493
|
+
};
|
|
16494
|
+
};
|
|
16495
|
+
}
|
|
16496
|
+
_getPreparePatchFn(clientType) {
|
|
16497
|
+
const self = this;
|
|
16498
|
+
return (originalPrepare) => {
|
|
16499
|
+
return function prepare(...args) {
|
|
16500
|
+
const firstArg = args[0];
|
|
16501
|
+
const sql = typeof firstArg === "string" ? firstArg : firstArg?.sql;
|
|
16502
|
+
const originalCallback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
16503
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16504
|
+
noOpRequestHandler: () => self._handleNoOpReplayPrepare(sql, originalCallback),
|
|
16505
|
+
isServerRequest: false,
|
|
16506
|
+
replayModeHandler: () => self._handleReplayPrepare(sql, originalCallback, clientType)
|
|
16507
|
+
});
|
|
16508
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16509
|
+
originalFunctionCall: () => originalPrepare.apply(this, args),
|
|
16510
|
+
recordModeHandler: ({ isPreAppStart }) => self._handleRecordPrepare(originalPrepare, args, sql, originalCallback, this, clientType, isPreAppStart),
|
|
16511
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16512
|
+
});
|
|
16513
|
+
return originalPrepare.apply(this, args);
|
|
16514
|
+
};
|
|
16515
|
+
};
|
|
16516
|
+
}
|
|
16517
|
+
_handleRecordPrepare(originalPrepare, args, sql, originalCallback, context$6, clientType, isPreAppStart) {
|
|
16518
|
+
const self = this;
|
|
16519
|
+
return SpanUtils.createAndExecuteSpan(this.mode, () => originalPrepare.apply(context$6, args), {
|
|
16520
|
+
name: `mysql2.${clientType}.prepare`,
|
|
16521
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16522
|
+
submodule: "prepare",
|
|
16523
|
+
packageType: PackageType.MYSQL,
|
|
16524
|
+
packageName: "mysql2",
|
|
16525
|
+
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
16526
|
+
inputValue: {
|
|
16527
|
+
sql,
|
|
16528
|
+
clientType
|
|
16529
|
+
},
|
|
16530
|
+
isPreAppStart
|
|
16531
|
+
}, (spanInfo) => {
|
|
16532
|
+
const wrappedCallback = (err, statement) => {
|
|
16533
|
+
if (err) {
|
|
16534
|
+
logger.debug(`[Mysql2Instrumentation] MySQL2 prepare error: ${err.message} (${SpanUtils.getTraceInfo()})`);
|
|
16535
|
+
try {
|
|
16536
|
+
SpanUtils.endSpan(spanInfo.span, {
|
|
16537
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16538
|
+
message: err.message
|
|
16539
|
+
});
|
|
16540
|
+
} catch (error) {
|
|
16541
|
+
logger.error(`[Mysql2Instrumentation] error ending span:`, error);
|
|
16542
|
+
}
|
|
16543
|
+
} else {
|
|
16544
|
+
logger.debug(`[Mysql2Instrumentation] MySQL2 prepare completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16545
|
+
try {
|
|
16546
|
+
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: {
|
|
16547
|
+
prepared: true,
|
|
16548
|
+
statementId: statement?.id
|
|
16549
|
+
} });
|
|
16550
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16551
|
+
} catch (error) {
|
|
16552
|
+
logger.error(`[Mysql2Instrumentation] error processing prepare response:`, error);
|
|
16553
|
+
}
|
|
16554
|
+
if (statement && statement.execute) {
|
|
16555
|
+
const originalExecute = statement.execute.bind(statement);
|
|
16556
|
+
statement.execute = self._getPreparedStatementExecuteWrapper(originalExecute, sql, clientType);
|
|
16557
|
+
}
|
|
16558
|
+
}
|
|
16559
|
+
if (originalCallback) originalCallback(err, statement);
|
|
16560
|
+
};
|
|
16561
|
+
const newArgs = [...args];
|
|
16562
|
+
const callbackIndex = newArgs.findIndex((a) => typeof a === "function");
|
|
16563
|
+
if (callbackIndex >= 0) newArgs[callbackIndex] = wrappedCallback;
|
|
16564
|
+
else newArgs.push(wrappedCallback);
|
|
16565
|
+
return originalPrepare.apply(context$6, newArgs);
|
|
16566
|
+
});
|
|
16567
|
+
}
|
|
16568
|
+
_getPreparedStatementExecuteWrapper(originalExecute, sql, clientType) {
|
|
16569
|
+
const self = this;
|
|
16570
|
+
return function execute(...args) {
|
|
16571
|
+
let values = [];
|
|
16572
|
+
let callback;
|
|
16573
|
+
for (const arg of args) if (typeof arg === "function") callback = arg;
|
|
16574
|
+
else if (Array.isArray(arg)) values = arg;
|
|
16575
|
+
else if (arg !== void 0) values = [arg];
|
|
16576
|
+
const inputValue = {
|
|
16577
|
+
sql,
|
|
16578
|
+
values,
|
|
16579
|
+
clientType
|
|
16580
|
+
};
|
|
16581
|
+
const queryConfig = {
|
|
16582
|
+
sql,
|
|
16583
|
+
values,
|
|
16584
|
+
callback
|
|
16585
|
+
};
|
|
16586
|
+
const stackTrace = captureStackTrace(["Mysql2Instrumentation"]);
|
|
16587
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16588
|
+
noOpRequestHandler: () => self.queryMock.handleNoOpReplayQuery(queryConfig),
|
|
16589
|
+
isServerRequest: false,
|
|
16590
|
+
replayModeHandler: () => {
|
|
16591
|
+
const spanName = `mysql2.${clientType}.preparedExecute`;
|
|
16592
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute(...args), {
|
|
16593
|
+
name: spanName,
|
|
16594
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16595
|
+
submodule: "preparedExecute",
|
|
16596
|
+
packageType: PackageType.MYSQL,
|
|
16597
|
+
packageName: "mysql2",
|
|
16598
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16599
|
+
inputValue,
|
|
16600
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16601
|
+
isPreAppStart: false
|
|
16602
|
+
}, (spanInfo) => {
|
|
16603
|
+
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "preparedExecute", stackTrace);
|
|
16604
|
+
});
|
|
16605
|
+
}
|
|
16606
|
+
});
|
|
16607
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16608
|
+
originalFunctionCall: () => originalExecute(...args),
|
|
16609
|
+
recordModeHandler: ({ isPreAppStart }) => {
|
|
16610
|
+
const spanName = `mysql2.${clientType}.preparedExecute`;
|
|
16611
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute(...args), {
|
|
16612
|
+
name: spanName,
|
|
16613
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16614
|
+
submodule: "preparedExecute",
|
|
16615
|
+
packageType: PackageType.MYSQL,
|
|
16616
|
+
packageName: "mysql2",
|
|
16617
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16618
|
+
inputValue,
|
|
16619
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16620
|
+
isPreAppStart
|
|
16621
|
+
}, (spanInfo) => {
|
|
16622
|
+
return self._handleRecordQueryInSpan(spanInfo, originalExecute, queryConfig, args, void 0);
|
|
16623
|
+
});
|
|
16624
|
+
},
|
|
16625
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16626
|
+
});
|
|
16627
|
+
return originalExecute(...args);
|
|
16628
|
+
};
|
|
16629
|
+
}
|
|
16630
|
+
_handleReplayPrepare(sql, originalCallback, clientType) {
|
|
16631
|
+
const self = this;
|
|
16632
|
+
return SpanUtils.createAndExecuteSpan(this.mode, () => {}, {
|
|
16633
|
+
name: `mysql2.${clientType}.prepare`,
|
|
16634
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16635
|
+
submodule: "prepare",
|
|
16636
|
+
packageType: PackageType.MYSQL,
|
|
16637
|
+
packageName: "mysql2",
|
|
16638
|
+
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
16639
|
+
inputValue: {
|
|
16640
|
+
sql,
|
|
16641
|
+
clientType
|
|
16642
|
+
},
|
|
16643
|
+
isPreAppStart: false
|
|
16644
|
+
}, (spanInfo) => {
|
|
16645
|
+
const mockStatement = {
|
|
16646
|
+
query: sql,
|
|
16647
|
+
id: 1,
|
|
16648
|
+
columns: [],
|
|
16649
|
+
parameters: [],
|
|
16650
|
+
execute: self._getPreparedStatementExecuteWrapper(() => {}, sql, clientType),
|
|
16651
|
+
close: () => {}
|
|
16652
|
+
};
|
|
16653
|
+
try {
|
|
16654
|
+
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { prepared: true } });
|
|
16655
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16656
|
+
} catch (error) {
|
|
16657
|
+
logger.error(`[Mysql2Instrumentation] error ending prepare span:`, error);
|
|
16658
|
+
}
|
|
16659
|
+
if (originalCallback) process.nextTick(() => originalCallback(null, mockStatement));
|
|
16660
|
+
});
|
|
16661
|
+
}
|
|
16662
|
+
_handleNoOpReplayPrepare(sql, originalCallback) {
|
|
16663
|
+
const self = this;
|
|
16664
|
+
const mockStatement = {
|
|
16665
|
+
query: sql,
|
|
16666
|
+
id: 1,
|
|
16667
|
+
columns: [],
|
|
16668
|
+
parameters: [],
|
|
16669
|
+
execute: (...args) => {
|
|
16670
|
+
const values = Array.isArray(args[0]) ? args[0] : [];
|
|
16671
|
+
const callback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
16672
|
+
return self.queryMock.handleNoOpReplayQuery({
|
|
16673
|
+
sql,
|
|
16674
|
+
values,
|
|
16675
|
+
callback
|
|
16676
|
+
});
|
|
16677
|
+
},
|
|
16678
|
+
close: () => {}
|
|
16679
|
+
};
|
|
16680
|
+
if (originalCallback) process.nextTick(() => originalCallback(null, mockStatement));
|
|
16681
|
+
}
|
|
16275
16682
|
_handleSimpleCallbackMethod(spanInfo, originalMethod, callback, context$6) {
|
|
16276
16683
|
if (callback) {
|
|
16277
16684
|
const wrappedCallback = (error) => {
|
|
@@ -16343,15 +16750,29 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16343
16750
|
else if (args.length > 1 && typeof args[1] !== "function") config.values = [args[1]];
|
|
16344
16751
|
return config;
|
|
16345
16752
|
}
|
|
16346
|
-
if (typeof firstArg === "object" && firstArg.sql)
|
|
16347
|
-
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16753
|
+
if (typeof firstArg === "object" && firstArg.sql) {
|
|
16754
|
+
let values = firstArg.values;
|
|
16755
|
+
let callback = firstArg.callback;
|
|
16756
|
+
if (typeof args[1] === "function") callback = args[1];
|
|
16757
|
+
else {
|
|
16758
|
+
if (args[1] !== void 0) values = Array.isArray(args[1]) ? args[1] : [args[1]];
|
|
16759
|
+
if (typeof args[2] === "function") callback = args[2];
|
|
16760
|
+
}
|
|
16761
|
+
return {
|
|
16762
|
+
sql: firstArg.sql,
|
|
16763
|
+
values,
|
|
16764
|
+
callback
|
|
16765
|
+
};
|
|
16766
|
+
}
|
|
16351
16767
|
return null;
|
|
16352
16768
|
}
|
|
16353
16769
|
_handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, context$6) {
|
|
16354
|
-
|
|
16770
|
+
const hasCallback = !!queryConfig.callback;
|
|
16771
|
+
const invokeOriginal = (invokeArgs) => {
|
|
16772
|
+
return context$6 ? originalQuery.apply(context$6, invokeArgs) : originalQuery(...invokeArgs);
|
|
16773
|
+
};
|
|
16774
|
+
if (hasCallback) {
|
|
16775
|
+
const parentContext = import_src$22.context.active();
|
|
16355
16776
|
const originalCallback = queryConfig.callback;
|
|
16356
16777
|
const wrappedCallback = (error, results, fields) => {
|
|
16357
16778
|
if (error) {
|
|
@@ -16373,7 +16794,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16373
16794
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error$1);
|
|
16374
16795
|
}
|
|
16375
16796
|
}
|
|
16376
|
-
return originalCallback(error, results, fields);
|
|
16797
|
+
return import_src$22.context.with(parentContext, () => originalCallback(error, results, fields));
|
|
16377
16798
|
};
|
|
16378
16799
|
try {
|
|
16379
16800
|
const firstArg = args[0];
|
|
@@ -16388,9 +16809,9 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16388
16809
|
} catch (error) {
|
|
16389
16810
|
logger.error(`[Mysql2Instrumentation] error replacing callback:`, error, args);
|
|
16390
16811
|
}
|
|
16391
|
-
return
|
|
16812
|
+
return invokeOriginal(args);
|
|
16392
16813
|
} else {
|
|
16393
|
-
const result =
|
|
16814
|
+
const result = invokeOriginal(args);
|
|
16394
16815
|
if (result && typeof result.on === "function") {
|
|
16395
16816
|
const streamResults = [];
|
|
16396
16817
|
let streamFields = null;
|
|
@@ -16596,6 +17017,34 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16596
17017
|
if (event === "error" && !this._isConnectOrErrorEmitted) return this;
|
|
16597
17018
|
return super.on(event, listener);
|
|
16598
17019
|
}
|
|
17020
|
+
once(event, listener) {
|
|
17021
|
+
if (!this._connectEventMock) return super.once(event, listener);
|
|
17022
|
+
if (event === "connect" && !this._isConnectOrErrorEmitted) {
|
|
17023
|
+
this._connectEventMock.getReplayedConnectionEvent(inputValue).then(({ output }) => {
|
|
17024
|
+
if (output !== void 0) process.nextTick(() => {
|
|
17025
|
+
listener.call(this, output);
|
|
17026
|
+
this._isConnectOrErrorEmitted = true;
|
|
17027
|
+
});
|
|
17028
|
+
}).catch((err) => {
|
|
17029
|
+
logger.error(`[Mysql2Instrumentation] Error replaying connection event:`, err);
|
|
17030
|
+
});
|
|
17031
|
+
return this;
|
|
17032
|
+
}
|
|
17033
|
+
if (event === "error" && !this._isConnectOrErrorEmitted) return this;
|
|
17034
|
+
return super.once(event, listener);
|
|
17035
|
+
}
|
|
17036
|
+
connect(callback) {
|
|
17037
|
+
if (!callback) return;
|
|
17038
|
+
this._connectEventMock.getReplayedConnectionEvent(inputValue).then(({ output }) => {
|
|
17039
|
+
if (output !== void 0) process.nextTick(() => {
|
|
17040
|
+
this._isConnectOrErrorEmitted = true;
|
|
17041
|
+
callback(null);
|
|
17042
|
+
});
|
|
17043
|
+
}).catch((err) => {
|
|
17044
|
+
logger.error(`[Mysql2Instrumentation] Error replaying connection event in connect():`, err);
|
|
17045
|
+
process.nextTick(() => callback(err));
|
|
17046
|
+
});
|
|
17047
|
+
}
|
|
16599
17048
|
}
|
|
16600
17049
|
const mockConnection = new MockConnection(...args);
|
|
16601
17050
|
mockConnection.addListener("error", (_err) => {});
|
|
@@ -16623,9 +17072,13 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16623
17072
|
fields: fields || []
|
|
16624
17073
|
};
|
|
16625
17074
|
else if (result.affectedRows !== void 0) outputValue = {
|
|
17075
|
+
fieldCount: result.fieldCount,
|
|
16626
17076
|
affectedRows: result.affectedRows,
|
|
16627
17077
|
insertId: result.insertId,
|
|
16628
|
-
|
|
17078
|
+
info: result.info ?? "",
|
|
17079
|
+
serverStatus: result.serverStatus ?? 0,
|
|
17080
|
+
warningStatus: result.warningStatus ?? 0,
|
|
17081
|
+
changedRows: result.changedRows ?? 0
|
|
16629
17082
|
};
|
|
16630
17083
|
else outputValue = result;
|
|
16631
17084
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
@@ -18853,16 +19306,28 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18853
19306
|
/**
|
|
18854
19307
|
* Helper method to parse optional unary response arguments
|
|
18855
19308
|
*
|
|
18856
|
-
* Handles the following cases:
|
|
18857
|
-
* 1. (
|
|
18858
|
-
* 2. (metadata: Metadata,
|
|
19309
|
+
* Handles the following cases (matching grpc-node's checkOptionalUnaryResponseArguments):
|
|
19310
|
+
* 1. (callback: Function) - callback only, no metadata or options
|
|
19311
|
+
* 2. (metadata: Metadata, callback: Function) - metadata + callback, no options
|
|
19312
|
+
* 3. (options: Object, callback: Function) - options + callback, no metadata
|
|
19313
|
+
* 4. (metadata: Metadata, options: Object, callback: Function) - full signature
|
|
18859
19314
|
*/
|
|
18860
19315
|
parseUnaryCallArguments(MetadataConstructor, arg1, arg2, arg3) {
|
|
19316
|
+
if (typeof arg1 === "function") return {
|
|
19317
|
+
metadata: new MetadataConstructor(),
|
|
19318
|
+
options: {},
|
|
19319
|
+
callback: arg1
|
|
19320
|
+
};
|
|
18861
19321
|
if (arg1 instanceof MetadataConstructor && typeof arg2 === "function") return {
|
|
18862
19322
|
metadata: arg1,
|
|
18863
19323
|
options: {},
|
|
18864
19324
|
callback: arg2
|
|
18865
19325
|
};
|
|
19326
|
+
if (!(arg1 instanceof MetadataConstructor) && typeof arg1 === "object" && arg1 !== null && typeof arg2 === "function") return {
|
|
19327
|
+
metadata: new MetadataConstructor(),
|
|
19328
|
+
options: arg1,
|
|
19329
|
+
callback: arg2
|
|
19330
|
+
};
|
|
18866
19331
|
if (arg1 instanceof MetadataConstructor && arg2 instanceof Object && typeof arg3 === "function") return {
|
|
18867
19332
|
metadata: arg1,
|
|
18868
19333
|
options: arg2,
|
|
@@ -25207,7 +25672,6 @@ var SpanTransformer = class SpanTransformer {
|
|
|
25207
25672
|
} catch (error) {
|
|
25208
25673
|
logger.warn("[SpanTransformer] Failed to parse transform metadata", error);
|
|
25209
25674
|
}
|
|
25210
|
-
const originalDate = OriginalGlobalUtils.getOriginalDate();
|
|
25211
25675
|
return {
|
|
25212
25676
|
traceId: span.spanContext().traceId,
|
|
25213
25677
|
spanId: span.spanContext().spanId,
|
|
@@ -25233,8 +25697,8 @@ var SpanTransformer = class SpanTransformer {
|
|
|
25233
25697
|
},
|
|
25234
25698
|
isPreAppStart: attributes[TdSpanAttributes.IS_PRE_APP_START] === true,
|
|
25235
25699
|
timestamp: {
|
|
25236
|
-
seconds:
|
|
25237
|
-
nanos:
|
|
25700
|
+
seconds: span.startTime[0],
|
|
25701
|
+
nanos: span.startTime[1]
|
|
25238
25702
|
},
|
|
25239
25703
|
duration: {
|
|
25240
25704
|
seconds: span.duration[0],
|
|
@@ -25804,15 +26268,13 @@ var TdSpanExporter = class {
|
|
|
25804
26268
|
logger.debug("All adapters cleared");
|
|
25805
26269
|
}
|
|
25806
26270
|
/**
|
|
25807
|
-
* Set the mode for determining which adapters to run
|
|
25808
|
-
*/
|
|
25809
|
-
setMode(mode) {
|
|
25810
|
-
this.mode = mode;
|
|
25811
|
-
}
|
|
25812
|
-
/**
|
|
25813
26271
|
* Export spans using all configured adapters
|
|
25814
26272
|
*/
|
|
25815
26273
|
export(spans, resultCallback) {
|
|
26274
|
+
if (this.mode !== TuskDriftMode.RECORD) {
|
|
26275
|
+
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
26276
|
+
return;
|
|
26277
|
+
}
|
|
25816
26278
|
logger.debug(`TdSpanExporter.export() called with ${spans.length} span(s)`);
|
|
25817
26279
|
const traceBlockingManager = TraceBlockingManager.getInstance();
|
|
25818
26280
|
const filteredSpansBasedOnLibraryName = spans.filter((span) => {
|
|
@@ -25851,21 +26313,16 @@ var TdSpanExporter = class {
|
|
|
25851
26313
|
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
25852
26314
|
return;
|
|
25853
26315
|
}
|
|
25854
|
-
|
|
25855
|
-
if (activeAdapters.length === 0) {
|
|
26316
|
+
if (this.adapters.length === 0) {
|
|
25856
26317
|
logger.debug(`No active adapters for mode: ${this.mode}`);
|
|
25857
26318
|
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
25858
26319
|
return;
|
|
25859
26320
|
}
|
|
25860
|
-
Promise.all(
|
|
26321
|
+
Promise.all(this.adapters.map((adapter) => adapter.exportSpans(cleanSpans))).then(() => resultCallback({ code: import_src$5.ExportResultCode.SUCCESS })).catch((error) => resultCallback({
|
|
25861
26322
|
code: import_src$5.ExportResultCode.FAILED,
|
|
25862
26323
|
error
|
|
25863
26324
|
}));
|
|
25864
26325
|
}
|
|
25865
|
-
getActiveAdapters() {
|
|
25866
|
-
if (this.mode !== TuskDriftMode.RECORD) return this.adapters.filter((adapter) => adapter.name === "in-memory" || adapter.name === "callback");
|
|
25867
|
-
return this.adapters;
|
|
25868
|
-
}
|
|
25869
26326
|
/**
|
|
25870
26327
|
* Shutdown all adapters
|
|
25871
26328
|
*/
|
|
@@ -32996,7 +33453,7 @@ var require_src = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/sdk-
|
|
|
32996
33453
|
//#endregion
|
|
32997
33454
|
//#region package.json
|
|
32998
33455
|
var import_src$1 = /* @__PURE__ */ __toESM(require_src(), 1);
|
|
32999
|
-
var version = "0.1.
|
|
33456
|
+
var version = "0.1.23";
|
|
33000
33457
|
|
|
33001
33458
|
//#endregion
|
|
33002
33459
|
//#region src/version.ts
|