@use-tusk/drift-node-sdk 0.1.20 → 0.1.22
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 +946 -473
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +946 -473
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -162,7 +162,8 @@ function warn(suppress, message) {
|
|
|
162
162
|
*
|
|
163
163
|
* This function automatically configures Next.js to work with Tusk Drift by:
|
|
164
164
|
* - Enabling the Next.js instrumentation hook (for Next.js < 15.0.0-rc.1)
|
|
165
|
-
* - Configuring
|
|
165
|
+
* - Configuring server external packages to prevent bundling of core instrumentation packages
|
|
166
|
+
* - Supporting both webpack and Turbopack bundlers
|
|
166
167
|
* - Preserving your existing Next.js configuration and webpack customizations
|
|
167
168
|
*
|
|
168
169
|
* @param nextConfig - Your existing Next.js configuration object (optional)
|
|
@@ -197,9 +198,12 @@ function warn(suppress, message) {
|
|
|
197
198
|
* ```
|
|
198
199
|
*
|
|
199
200
|
* @remarks
|
|
200
|
-
* The following
|
|
201
|
+
* The following packages are added as server externals for both webpack and Turbopack:
|
|
201
202
|
* - `require-in-the-middle` - Required for CommonJS module interception
|
|
202
203
|
* - `jsonpath` - Required for schema manipulation
|
|
204
|
+
* - Additional packages when TUSK_DRIFT_MODE is RECORD or REPLAY (e.g., database clients, etc.)
|
|
205
|
+
*
|
|
206
|
+
* Works with both webpack (default) and Turbopack (`next dev --turbo`).
|
|
203
207
|
*/
|
|
204
208
|
function withTuskDrift(nextConfig = {}, options = {}) {
|
|
205
209
|
const config = nextConfig;
|
|
@@ -209,33 +213,34 @@ function withTuskDrift(nextConfig = {}, options = {}) {
|
|
|
209
213
|
if (nextjsVersion) debugLog(debug, `Detected Next.js version: ${nextjsVersion}`);
|
|
210
214
|
else warn(suppressAllWarnings || false, "Could not detect Next.js version. Some features may not work correctly. If you encounter issues, please ensure Next.js is properly installed.");
|
|
211
215
|
const needsInstrumentationHook = !options.disableInstrumentationHook && shouldSetInstrumentationHook(nextjsVersion);
|
|
216
|
+
const mode = process.env.TUSK_DRIFT_MODE?.toUpperCase();
|
|
217
|
+
const coreExternals = [
|
|
218
|
+
"require-in-the-middle",
|
|
219
|
+
"jsonpath",
|
|
220
|
+
...mode === "RECORD" || mode === "REPLAY" ? [
|
|
221
|
+
"@upstash/redis",
|
|
222
|
+
"ioredis",
|
|
223
|
+
"pg",
|
|
224
|
+
"postgres",
|
|
225
|
+
"mysql2",
|
|
226
|
+
"@prisma/client",
|
|
227
|
+
"@google-cloud/firestore",
|
|
228
|
+
"@grpc/grpc-js",
|
|
229
|
+
"graphql",
|
|
230
|
+
"jsonwebtoken",
|
|
231
|
+
"jwks-rsa"
|
|
232
|
+
] : []
|
|
233
|
+
];
|
|
212
234
|
const wrappedConfig = {
|
|
213
235
|
...config,
|
|
214
236
|
...needsInstrumentationHook ? { experimental: {
|
|
215
237
|
...config.experimental,
|
|
216
238
|
instrumentationHook: true
|
|
217
239
|
} } : { experimental: config.experimental },
|
|
240
|
+
serverExternalPackages: [...config.serverExternalPackages || [], ...coreExternals],
|
|
218
241
|
webpack: (webpackConfig, webpackOptions) => {
|
|
219
242
|
if (webpackOptions.isServer) {
|
|
220
243
|
const originalExternals = webpackConfig.externals;
|
|
221
|
-
const mode = process.env.TUSK_DRIFT_MODE?.toUpperCase();
|
|
222
|
-
const coreExternals = [
|
|
223
|
-
"require-in-the-middle",
|
|
224
|
-
"jsonpath",
|
|
225
|
-
...mode === "RECORD" || mode === "REPLAY" ? [
|
|
226
|
-
"@upstash/redis",
|
|
227
|
-
"ioredis",
|
|
228
|
-
"pg",
|
|
229
|
-
"postgres",
|
|
230
|
-
"mysql2",
|
|
231
|
-
"@prisma/client",
|
|
232
|
-
"@google-cloud/firestore",
|
|
233
|
-
"@grpc/grpc-js",
|
|
234
|
-
"graphql",
|
|
235
|
-
"jsonwebtoken",
|
|
236
|
-
"jwks-rsa"
|
|
237
|
-
] : []
|
|
238
|
-
];
|
|
239
244
|
const externalsMapping = {};
|
|
240
245
|
for (const pkg of coreExternals) {
|
|
241
246
|
externalsMapping[pkg] = `commonjs ${pkg}`;
|
|
@@ -4989,31 +4994,31 @@ var require_SamplingResult = /* @__PURE__ */ __commonJS({ "node_modules/@opentel
|
|
|
4989
4994
|
var require_span_kind = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/api/build/src/trace/span_kind.js": ((exports) => {
|
|
4990
4995
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4991
4996
|
exports.SpanKind = void 0;
|
|
4992
|
-
(function(SpanKind$
|
|
4997
|
+
(function(SpanKind$27) {
|
|
4993
4998
|
/** Default value. Indicates that the span is used internally. */
|
|
4994
|
-
SpanKind$
|
|
4999
|
+
SpanKind$27[SpanKind$27["INTERNAL"] = 0] = "INTERNAL";
|
|
4995
5000
|
/**
|
|
4996
5001
|
* Indicates that the span covers server-side handling of an RPC or other
|
|
4997
5002
|
* remote request.
|
|
4998
5003
|
*/
|
|
4999
|
-
SpanKind$
|
|
5004
|
+
SpanKind$27[SpanKind$27["SERVER"] = 1] = "SERVER";
|
|
5000
5005
|
/**
|
|
5001
5006
|
* Indicates that the span covers the client-side wrapper around an RPC or
|
|
5002
5007
|
* other remote request.
|
|
5003
5008
|
*/
|
|
5004
|
-
SpanKind$
|
|
5009
|
+
SpanKind$27[SpanKind$27["CLIENT"] = 2] = "CLIENT";
|
|
5005
5010
|
/**
|
|
5006
5011
|
* Indicates that the span describes producer sending a message to a
|
|
5007
5012
|
* broker. Unlike client and server, there is no direct critical path latency
|
|
5008
5013
|
* relationship between producer and consumer spans.
|
|
5009
5014
|
*/
|
|
5010
|
-
SpanKind$
|
|
5015
|
+
SpanKind$27[SpanKind$27["PRODUCER"] = 3] = "PRODUCER";
|
|
5011
5016
|
/**
|
|
5012
5017
|
* Indicates that the span describes consumer receiving a message from a
|
|
5013
5018
|
* broker. Unlike client and server, there is no direct critical path latency
|
|
5014
5019
|
* relationship between producer and consumer spans.
|
|
5015
5020
|
*/
|
|
5016
|
-
SpanKind$
|
|
5021
|
+
SpanKind$27[SpanKind$27["CONSUMER"] = 4] = "CONSUMER";
|
|
5017
5022
|
})(exports.SpanKind || (exports.SpanKind = {}));
|
|
5018
5023
|
}) });
|
|
5019
5024
|
|
|
@@ -5022,20 +5027,20 @@ var require_span_kind = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetr
|
|
|
5022
5027
|
var require_status = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/api/build/src/trace/status.js": ((exports) => {
|
|
5023
5028
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5024
5029
|
exports.SpanStatusCode = void 0;
|
|
5025
|
-
(function(SpanStatusCode$
|
|
5030
|
+
(function(SpanStatusCode$16) {
|
|
5026
5031
|
/**
|
|
5027
5032
|
* The default status.
|
|
5028
5033
|
*/
|
|
5029
|
-
SpanStatusCode$
|
|
5034
|
+
SpanStatusCode$16[SpanStatusCode$16["UNSET"] = 0] = "UNSET";
|
|
5030
5035
|
/**
|
|
5031
5036
|
* The operation has been validated by an Application developer or
|
|
5032
5037
|
* Operator to have completed successfully.
|
|
5033
5038
|
*/
|
|
5034
|
-
SpanStatusCode$
|
|
5039
|
+
SpanStatusCode$16[SpanStatusCode$16["OK"] = 1] = "OK";
|
|
5035
5040
|
/**
|
|
5036
5041
|
* The operation contains an error.
|
|
5037
5042
|
*/
|
|
5038
|
-
SpanStatusCode$
|
|
5043
|
+
SpanStatusCode$16[SpanStatusCode$16["ERROR"] = 2] = "ERROR";
|
|
5039
5044
|
})(exports.SpanStatusCode || (exports.SpanStatusCode = {}));
|
|
5040
5045
|
}) });
|
|
5041
5046
|
|
|
@@ -5684,7 +5689,7 @@ var require_src$7 = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/ap
|
|
|
5684
5689
|
|
|
5685
5690
|
//#endregion
|
|
5686
5691
|
//#region node_modules/@use-tusk/drift-schemas/dist/duration-B3fwb4jB.js
|
|
5687
|
-
var import_src$
|
|
5692
|
+
var import_src$37 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
5688
5693
|
var import_commonjs$9 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
|
|
5689
5694
|
var Duration$Type = class extends import_commonjs$9.MessageType {
|
|
5690
5695
|
constructor() {
|
|
@@ -6295,7 +6300,7 @@ let PackageType = /* @__PURE__ */ function(PackageType$1) {
|
|
|
6295
6300
|
*
|
|
6296
6301
|
* @generated from protobuf enum tusk.drift.core.v1.SpanKind
|
|
6297
6302
|
*/
|
|
6298
|
-
let SpanKind$
|
|
6303
|
+
let SpanKind$2 = /* @__PURE__ */ function(SpanKind$1$1) {
|
|
6299
6304
|
/**
|
|
6300
6305
|
* @generated from protobuf enum value: SPAN_KIND_UNSPECIFIED = 0;
|
|
6301
6306
|
*/
|
|
@@ -6465,7 +6470,7 @@ var Span$Type = class extends import_commonjs$6.MessageType {
|
|
|
6465
6470
|
kind: "enum",
|
|
6466
6471
|
T: () => [
|
|
6467
6472
|
"tusk.drift.core.v1.SpanKind",
|
|
6468
|
-
SpanKind$
|
|
6473
|
+
SpanKind$2,
|
|
6469
6474
|
"SPAN_KIND_"
|
|
6470
6475
|
]
|
|
6471
6476
|
},
|
|
@@ -7008,12 +7013,12 @@ const Trace = new Trace$Type();
|
|
|
7008
7013
|
const toStruct = (obj) => obj ? objectToProtobufStruct(obj) : void 0;
|
|
7009
7014
|
const mapOtToPb = (k) => {
|
|
7010
7015
|
switch (k) {
|
|
7011
|
-
case import_src$
|
|
7012
|
-
case import_src$
|
|
7013
|
-
case import_src$
|
|
7014
|
-
case import_src$
|
|
7015
|
-
case import_src$
|
|
7016
|
-
default: return SpanKind$
|
|
7016
|
+
case import_src$37.SpanKind.INTERNAL: return SpanKind$2.INTERNAL;
|
|
7017
|
+
case import_src$37.SpanKind.SERVER: return SpanKind$2.SERVER;
|
|
7018
|
+
case import_src$37.SpanKind.CLIENT: return SpanKind$2.CLIENT;
|
|
7019
|
+
case import_src$37.SpanKind.PRODUCER: return SpanKind$2.PRODUCER;
|
|
7020
|
+
case import_src$37.SpanKind.CONSUMER: return SpanKind$2.CONSUMER;
|
|
7021
|
+
default: return SpanKind$2.UNSPECIFIED;
|
|
7017
7022
|
}
|
|
7018
7023
|
};
|
|
7019
7024
|
/**
|
|
@@ -7416,13 +7421,13 @@ var TdInstrumentationNodeModule = class {
|
|
|
7416
7421
|
|
|
7417
7422
|
//#endregion
|
|
7418
7423
|
//#region src/core/types.ts
|
|
7419
|
-
var import_src$
|
|
7424
|
+
var import_src$36 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
7420
7425
|
const TD_INSTRUMENTATION_LIBRARY_NAME = "tusk-drift-sdk";
|
|
7421
|
-
const REPLAY_TRACE_ID_CONTEXT_KEY = (0, import_src$
|
|
7422
|
-
const SPAN_KIND_CONTEXT_KEY = (0, import_src$
|
|
7423
|
-
const IS_PRE_APP_START_CONTEXT_KEY = (0, import_src$
|
|
7424
|
-
const STOP_RECORDING_CHILD_SPANS_CONTEXT_KEY = (0, import_src$
|
|
7425
|
-
const CALLING_LIBRARY_CONTEXT_KEY = (0, import_src$
|
|
7426
|
+
const REPLAY_TRACE_ID_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.replayTraceId");
|
|
7427
|
+
const SPAN_KIND_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.spanKind");
|
|
7428
|
+
const IS_PRE_APP_START_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.isPreAppStart");
|
|
7429
|
+
const STOP_RECORDING_CHILD_SPANS_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.stopRecordingChildSpans");
|
|
7430
|
+
const CALLING_LIBRARY_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.callingLibrary");
|
|
7426
7431
|
let TdSpanAttributes = /* @__PURE__ */ function(TdSpanAttributes$1) {
|
|
7427
7432
|
/**
|
|
7428
7433
|
* Presentational information:
|
|
@@ -7534,7 +7539,7 @@ TraceBlockingManager.instance = null;
|
|
|
7534
7539
|
|
|
7535
7540
|
//#endregion
|
|
7536
7541
|
//#region src/core/tracing/SpanUtils.ts
|
|
7537
|
-
var import_src$
|
|
7542
|
+
var import_src$35 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
7538
7543
|
var SpanUtils = class SpanUtils {
|
|
7539
7544
|
/**
|
|
7540
7545
|
* Creates a new span and returns span info including trace ID and span ID
|
|
@@ -7542,8 +7547,8 @@ var SpanUtils = class SpanUtils {
|
|
|
7542
7547
|
static createSpan(options) {
|
|
7543
7548
|
try {
|
|
7544
7549
|
const tracer = TuskDriftCore.getInstance().getTracer();
|
|
7545
|
-
const parentContext = options.parentContext || import_src$
|
|
7546
|
-
const activeSpan = import_src$
|
|
7550
|
+
const parentContext = options.parentContext || import_src$35.context.active();
|
|
7551
|
+
const activeSpan = import_src$35.trace.getSpan(parentContext);
|
|
7547
7552
|
if (activeSpan) {
|
|
7548
7553
|
const parentTraceId = activeSpan.spanContext().traceId;
|
|
7549
7554
|
if (TraceBlockingManager.getInstance().isTraceBlocked(parentTraceId)) {
|
|
@@ -7552,11 +7557,11 @@ var SpanUtils = class SpanUtils {
|
|
|
7552
7557
|
}
|
|
7553
7558
|
}
|
|
7554
7559
|
const span = tracer.startSpan(options.name, {
|
|
7555
|
-
kind: options.kind || import_src$
|
|
7560
|
+
kind: options.kind || import_src$35.SpanKind.CLIENT,
|
|
7556
7561
|
attributes: options.attributes || {}
|
|
7557
7562
|
}, parentContext);
|
|
7558
7563
|
const spanContext = span.spanContext();
|
|
7559
|
-
const newContext = import_src$
|
|
7564
|
+
const newContext = import_src$35.trace.setSpan(parentContext, span).setValue(SPAN_KIND_CONTEXT_KEY, options.kind).setValue(IS_PRE_APP_START_CONTEXT_KEY, options.isPreAppStart);
|
|
7560
7565
|
return {
|
|
7561
7566
|
traceId: spanContext.traceId,
|
|
7562
7567
|
spanId: spanContext.spanId,
|
|
@@ -7573,7 +7578,7 @@ var SpanUtils = class SpanUtils {
|
|
|
7573
7578
|
* Executes a function within a span context
|
|
7574
7579
|
*/
|
|
7575
7580
|
static withSpan(spanInfo, fn) {
|
|
7576
|
-
return import_src$
|
|
7581
|
+
return import_src$35.context.with(spanInfo.context, fn);
|
|
7577
7582
|
}
|
|
7578
7583
|
/**
|
|
7579
7584
|
* Execute a function within a properly configured span
|
|
@@ -7590,9 +7595,9 @@ var SpanUtils = class SpanUtils {
|
|
|
7590
7595
|
* @returns The result of the function execution
|
|
7591
7596
|
*/
|
|
7592
7597
|
static createAndExecuteSpan(mode, originalFunctionCall, options, fn) {
|
|
7593
|
-
const spanContext = import_src$
|
|
7598
|
+
const spanContext = import_src$35.trace.getActiveSpan()?.spanContext();
|
|
7594
7599
|
if (spanContext) {
|
|
7595
|
-
if (import_src$
|
|
7600
|
+
if (import_src$35.context.active().getValue(STOP_RECORDING_CHILD_SPANS_CONTEXT_KEY)) {
|
|
7596
7601
|
logger.debug(`[SpanUtils] Stopping recording of child spans for span ${spanContext.spanId}, packageName: ${options.packageName}, instrumentationName: ${options.instrumentationName}`);
|
|
7597
7602
|
return originalFunctionCall();
|
|
7598
7603
|
}
|
|
@@ -7631,15 +7636,15 @@ var SpanUtils = class SpanUtils {
|
|
|
7631
7636
|
*/
|
|
7632
7637
|
static getCurrentSpanInfo() {
|
|
7633
7638
|
try {
|
|
7634
|
-
const activeSpan = import_src$
|
|
7639
|
+
const activeSpan = import_src$35.trace.getActiveSpan();
|
|
7635
7640
|
if (!activeSpan) return null;
|
|
7636
7641
|
const spanContext = activeSpan.spanContext();
|
|
7637
7642
|
return {
|
|
7638
7643
|
traceId: spanContext.traceId,
|
|
7639
7644
|
spanId: spanContext.spanId,
|
|
7640
7645
|
span: activeSpan,
|
|
7641
|
-
context: import_src$
|
|
7642
|
-
isPreAppStart: import_src$
|
|
7646
|
+
context: import_src$35.context.active(),
|
|
7647
|
+
isPreAppStart: import_src$35.context.active().getValue(IS_PRE_APP_START_CONTEXT_KEY)
|
|
7643
7648
|
};
|
|
7644
7649
|
} catch (error) {
|
|
7645
7650
|
logger.error("SpanUtils error getting current span info:", error);
|
|
@@ -7703,7 +7708,7 @@ var SpanUtils = class SpanUtils {
|
|
|
7703
7708
|
}
|
|
7704
7709
|
static setCurrentReplayTraceId(replayTraceId) {
|
|
7705
7710
|
try {
|
|
7706
|
-
return import_src$
|
|
7711
|
+
return import_src$35.context.active().setValue(REPLAY_TRACE_ID_CONTEXT_KEY, replayTraceId);
|
|
7707
7712
|
} catch (error) {
|
|
7708
7713
|
logger.error("SpanUtils error setting current replay trace id:", error);
|
|
7709
7714
|
return null;
|
|
@@ -7714,7 +7719,7 @@ var SpanUtils = class SpanUtils {
|
|
|
7714
7719
|
*/
|
|
7715
7720
|
static getCurrentReplayTraceId() {
|
|
7716
7721
|
try {
|
|
7717
|
-
return import_src$
|
|
7722
|
+
return import_src$35.context.active().getValue(REPLAY_TRACE_ID_CONTEXT_KEY);
|
|
7718
7723
|
} catch (error) {
|
|
7719
7724
|
logger.error("SpanUtils error getting current replay trace id:", error);
|
|
7720
7725
|
return null;
|
|
@@ -8363,7 +8368,7 @@ function findMockResponseSync({ mockRequestData, tuskDrift, inputValueSchemaMerg
|
|
|
8363
8368
|
|
|
8364
8369
|
//#endregion
|
|
8365
8370
|
//#region src/instrumentation/libraries/http/mocks/TdMockClientRequest.ts
|
|
8366
|
-
var import_src$
|
|
8371
|
+
var import_src$34 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
8367
8372
|
let ClientRequest;
|
|
8368
8373
|
/**
|
|
8369
8374
|
* Mock ClientRequest implementation for Tusk Drift HTTP replay
|
|
@@ -8534,7 +8539,7 @@ var TdMockClientRequest = class TdMockClientRequest extends events.EventEmitter
|
|
|
8534
8539
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
8535
8540
|
submoduleName: rawInputValue.method,
|
|
8536
8541
|
inputValue,
|
|
8537
|
-
kind: import_src$
|
|
8542
|
+
kind: import_src$34.SpanKind.CLIENT,
|
|
8538
8543
|
stackTrace: this.stackTrace
|
|
8539
8544
|
},
|
|
8540
8545
|
tuskDrift: this.tuskDrift,
|
|
@@ -8704,7 +8709,7 @@ var HttpReplayHooks = class {
|
|
|
8704
8709
|
|
|
8705
8710
|
//#endregion
|
|
8706
8711
|
//#region src/instrumentation/core/utils/modeUtils.ts
|
|
8707
|
-
var import_src$
|
|
8712
|
+
var import_src$33 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
8708
8713
|
/**
|
|
8709
8714
|
* Utility function that abstracts the common record mode pattern of checking for current span context
|
|
8710
8715
|
* and deciding whether to execute record mode logic or just call the original function.
|
|
@@ -8725,7 +8730,7 @@ function handleRecordMode({ originalFunctionCall, recordModeHandler, spanKind })
|
|
|
8725
8730
|
return originalFunctionCall();
|
|
8726
8731
|
}
|
|
8727
8732
|
if (!isAppReady) return recordModeHandler({ isPreAppStart: true });
|
|
8728
|
-
if (!currentSpanInfo && spanKind !== import_src$
|
|
8733
|
+
if (!currentSpanInfo && spanKind !== import_src$33.SpanKind.SERVER || currentSpanInfo?.isPreAppStart) return originalFunctionCall();
|
|
8729
8734
|
else return recordModeHandler({ isPreAppStart: false });
|
|
8730
8735
|
}
|
|
8731
8736
|
/**
|
|
@@ -10205,7 +10210,7 @@ function captureStackTrace(excludeClassNames = []) {
|
|
|
10205
10210
|
|
|
10206
10211
|
//#endregion
|
|
10207
10212
|
//#region src/instrumentation/libraries/http/HttpTransformEngine.ts
|
|
10208
|
-
var import_src$
|
|
10213
|
+
var import_src$32 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
10209
10214
|
/**
|
|
10210
10215
|
* Creates an empty HttpClientInputValue object for dropped spans
|
|
10211
10216
|
*/
|
|
@@ -10258,7 +10263,7 @@ var HttpTransformEngine = class {
|
|
|
10258
10263
|
const testSpan = {
|
|
10259
10264
|
traceId: "",
|
|
10260
10265
|
spanId: "",
|
|
10261
|
-
kind: import_src$
|
|
10266
|
+
kind: import_src$32.SpanKind.SERVER,
|
|
10262
10267
|
protocol: "http",
|
|
10263
10268
|
inputValue: {
|
|
10264
10269
|
method,
|
|
@@ -10281,7 +10286,7 @@ var HttpTransformEngine = class {
|
|
|
10281
10286
|
const testSpan = {
|
|
10282
10287
|
traceId: "",
|
|
10283
10288
|
spanId: "",
|
|
10284
|
-
kind: import_src$
|
|
10289
|
+
kind: import_src$32.SpanKind.CLIENT,
|
|
10285
10290
|
protocol: inputValue.protocol || "http",
|
|
10286
10291
|
inputValue: clonedInputValue
|
|
10287
10292
|
};
|
|
@@ -10308,8 +10313,8 @@ var HttpTransformEngine = class {
|
|
|
10308
10313
|
const matcherFunction = this.compileMatcher(matcher);
|
|
10309
10314
|
if (action.type === "drop") return (span) => {
|
|
10310
10315
|
if (!matcherFunction(span)) return;
|
|
10311
|
-
if (span.inputValue) span.inputValue = span.kind === import_src$
|
|
10312
|
-
if (span.outputValue) span.outputValue = span.kind === import_src$
|
|
10316
|
+
if (span.inputValue) span.inputValue = span.kind === import_src$32.SpanKind.CLIENT ? createEmptyClientInputValue(span.protocol) : createEmptyServerInputValue();
|
|
10317
|
+
if (span.outputValue) span.outputValue = span.kind === import_src$32.SpanKind.CLIENT ? createEmptyClientOutputValue() : createEmptyServerOutputValue();
|
|
10313
10318
|
return {
|
|
10314
10319
|
type: "drop",
|
|
10315
10320
|
field: "entire_span",
|
|
@@ -10339,8 +10344,8 @@ var HttpTransformEngine = class {
|
|
|
10339
10344
|
}
|
|
10340
10345
|
compileMatcher(matcher) {
|
|
10341
10346
|
const checks = [];
|
|
10342
|
-
if (matcher.direction === "outbound") checks.push((span) => span.kind === import_src$
|
|
10343
|
-
else if (matcher.direction === "inbound") checks.push((span) => span.kind === import_src$
|
|
10347
|
+
if (matcher.direction === "outbound") checks.push((span) => span.kind === import_src$32.SpanKind.CLIENT);
|
|
10348
|
+
else if (matcher.direction === "inbound") checks.push((span) => span.kind === import_src$32.SpanKind.SERVER);
|
|
10344
10349
|
if (matcher.method) if (matcher.method.length === 0) {} else {
|
|
10345
10350
|
const methods = matcher.method.map((method) => method.toUpperCase());
|
|
10346
10351
|
checks.push((span) => {
|
|
@@ -10568,7 +10573,7 @@ var HttpTransformEngine = class {
|
|
|
10568
10573
|
|
|
10569
10574
|
//#endregion
|
|
10570
10575
|
//#region src/instrumentation/libraries/http/Instrumentation.ts
|
|
10571
|
-
var import_src$
|
|
10576
|
+
var import_src$31 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
10572
10577
|
var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
10573
10578
|
constructor(config) {
|
|
10574
10579
|
super("http", config);
|
|
@@ -10655,10 +10660,10 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10655
10660
|
logger.debug(`[HttpInstrumentation] Setting replay trace id`, replayTraceId);
|
|
10656
10661
|
const ctxWithReplayTraceId = SpanUtils.setCurrentReplayTraceId(replayTraceId);
|
|
10657
10662
|
if (!ctxWithReplayTraceId) throw new Error("Error setting current replay trace id");
|
|
10658
|
-
return import_src$
|
|
10663
|
+
return import_src$31.context.with(ctxWithReplayTraceId, () => {
|
|
10659
10664
|
return SpanUtils.createAndExecuteSpan(this.mode, () => originalHandler.call(this), {
|
|
10660
10665
|
name: `${target}`,
|
|
10661
|
-
kind: import_src$
|
|
10666
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10662
10667
|
packageName: spanProtocol,
|
|
10663
10668
|
submodule: method,
|
|
10664
10669
|
packageType: PackageType.HTTP,
|
|
@@ -10703,7 +10708,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10703
10708
|
logger.debug(`[HttpInstrumentation] Http inbound request arriving, inputValue: ${JSON.stringify(inputValue)}`);
|
|
10704
10709
|
return SpanUtils.createAndExecuteSpan(this.mode, () => originalHandler.call(this), {
|
|
10705
10710
|
name: `${target}`,
|
|
10706
|
-
kind: import_src$
|
|
10711
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10707
10712
|
packageName: spanProtocol,
|
|
10708
10713
|
packageType: PackageType.HTTP,
|
|
10709
10714
|
submodule: method,
|
|
@@ -10723,7 +10728,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10723
10728
|
});
|
|
10724
10729
|
});
|
|
10725
10730
|
},
|
|
10726
|
-
spanKind: import_src$
|
|
10731
|
+
spanKind: import_src$31.SpanKind.SERVER
|
|
10727
10732
|
});
|
|
10728
10733
|
} else return originalHandler.call(this);
|
|
10729
10734
|
}
|
|
@@ -10740,8 +10745,8 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10740
10745
|
_handleInboundRequestInSpan({ req, res, originalHandler, spanInfo, inputValue, schemaMerges, protocol }) {
|
|
10741
10746
|
const self = this;
|
|
10742
10747
|
const spanProtocol = this._normalizeProtocol(protocol, "http");
|
|
10743
|
-
import_src$
|
|
10744
|
-
import_src$
|
|
10748
|
+
import_src$31.context.bind(spanInfo.context, req);
|
|
10749
|
+
import_src$31.context.bind(spanInfo.context, res);
|
|
10745
10750
|
let completeInputValue = inputValue;
|
|
10746
10751
|
this._captureServerRequestBody(req, spanInfo, inputValue, schemaMerges, (updatedInputValue) => {
|
|
10747
10752
|
completeInputValue = updatedInputValue;
|
|
@@ -10779,7 +10784,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10779
10784
|
const spanData = {
|
|
10780
10785
|
traceId: spanInfo.traceId,
|
|
10781
10786
|
spanId: spanInfo.spanId,
|
|
10782
|
-
kind: import_src$
|
|
10787
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10783
10788
|
protocol: spanProtocol,
|
|
10784
10789
|
inputValue: completeInputValue,
|
|
10785
10790
|
outputValue
|
|
@@ -10798,9 +10803,9 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10798
10803
|
...spanData.transformMetadata && { transformMetadata: spanData.transformMetadata }
|
|
10799
10804
|
});
|
|
10800
10805
|
const status = statusCode >= 300 ? {
|
|
10801
|
-
code: import_src$
|
|
10806
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
10802
10807
|
message: `HTTP ${statusCode}`
|
|
10803
|
-
} : { code: import_src$
|
|
10808
|
+
} : { code: import_src$31.SpanStatusCode.OK };
|
|
10804
10809
|
SpanUtils.setStatus(spanInfo.span, status);
|
|
10805
10810
|
const decodedType = getDecodedType(outputValue.headers?.["content-type"] || "");
|
|
10806
10811
|
if (decodedType && !ACCEPTABLE_CONTENT_TYPES.has(decodedType)) {
|
|
@@ -10850,7 +10855,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10850
10855
|
outputSchemaHash: JsonSchemaHelper.generateDeterministicHash(outputSchema),
|
|
10851
10856
|
inputValueHash,
|
|
10852
10857
|
outputValueHash,
|
|
10853
|
-
kind: import_src$
|
|
10858
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10854
10859
|
packageType: PackageType.HTTP,
|
|
10855
10860
|
status: {
|
|
10856
10861
|
code: statusCode >= 300 ? StatusCode.ERROR : StatusCode.OK,
|
|
@@ -10879,7 +10884,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10879
10884
|
try {
|
|
10880
10885
|
logger.debug(`[HttpInstrumentation] Server request error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
10881
10886
|
SpanUtils.endSpan(spanInfo.span, {
|
|
10882
|
-
code: import_src$
|
|
10887
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
10883
10888
|
message: error.message
|
|
10884
10889
|
});
|
|
10885
10890
|
} catch (error$1) {
|
|
@@ -10890,7 +10895,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10890
10895
|
try {
|
|
10891
10896
|
logger.debug(`[HttpInstrumentation] Server response error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
10892
10897
|
SpanUtils.endSpan(spanInfo.span, {
|
|
10893
|
-
code: import_src$
|
|
10898
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
10894
10899
|
message: error.message
|
|
10895
10900
|
});
|
|
10896
10901
|
} catch (error$1) {
|
|
@@ -11095,7 +11100,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11095
11100
|
inputValue: completeInputValue
|
|
11096
11101
|
});
|
|
11097
11102
|
SpanUtils.endSpan(spanInfo.span, {
|
|
11098
|
-
code: import_src$
|
|
11103
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
11099
11104
|
message: error.message
|
|
11100
11105
|
});
|
|
11101
11106
|
} catch (error$1) {
|
|
@@ -11112,7 +11117,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11112
11117
|
const spanData = {
|
|
11113
11118
|
traceId: spanInfo.traceId,
|
|
11114
11119
|
spanId: spanInfo.spanId,
|
|
11115
|
-
kind: import_src$
|
|
11120
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11116
11121
|
protocol: normalizedProtocol,
|
|
11117
11122
|
inputValue,
|
|
11118
11123
|
outputValue
|
|
@@ -11125,9 +11130,9 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11125
11130
|
transformMetadata: spanData.transformMetadata ? spanData.transformMetadata : void 0
|
|
11126
11131
|
});
|
|
11127
11132
|
const status = statusCode >= 300 ? {
|
|
11128
|
-
code: import_src$
|
|
11133
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
11129
11134
|
message: `HTTP ${statusCode}`
|
|
11130
|
-
} : { code: import_src$
|
|
11135
|
+
} : { code: import_src$31.SpanStatusCode.OK };
|
|
11131
11136
|
SpanUtils.endSpan(spanInfo.span, status);
|
|
11132
11137
|
}
|
|
11133
11138
|
_captureHeadersFromRawHeaders(rawHeaders) {
|
|
@@ -11145,13 +11150,23 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11145
11150
|
let requestOptions;
|
|
11146
11151
|
if (typeof args[0] === "string") {
|
|
11147
11152
|
const url = new URL(args[0]);
|
|
11153
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11148
11154
|
requestOptions = {
|
|
11149
11155
|
protocol: url.protocol,
|
|
11150
11156
|
hostname: url.hostname,
|
|
11151
11157
|
port: url.port ? parseInt(url.port) : void 0,
|
|
11152
11158
|
path: url.pathname + url.search,
|
|
11153
|
-
method:
|
|
11154
|
-
headers:
|
|
11159
|
+
method: additionalOptions?.method || "GET",
|
|
11160
|
+
headers: additionalOptions?.headers || {}
|
|
11161
|
+
};
|
|
11162
|
+
} else if (self._isURLObject(args[0])) {
|
|
11163
|
+
const url = args[0];
|
|
11164
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11165
|
+
requestOptions = {
|
|
11166
|
+
...self._urlToRequestOptions(url),
|
|
11167
|
+
method: additionalOptions?.method || "GET",
|
|
11168
|
+
headers: additionalOptions?.headers || {},
|
|
11169
|
+
...additionalOptions
|
|
11155
11170
|
};
|
|
11156
11171
|
} else requestOptions = args[0] || {};
|
|
11157
11172
|
const method = requestOptions.method || "GET";
|
|
@@ -11181,7 +11196,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11181
11196
|
};
|
|
11182
11197
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRequest.apply(this, args), {
|
|
11183
11198
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11184
|
-
kind: import_src$
|
|
11199
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11185
11200
|
packageName: requestProtocol,
|
|
11186
11201
|
packageType: PackageType.HTTP,
|
|
11187
11202
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11216,7 +11231,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11216
11231
|
};
|
|
11217
11232
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRequest.apply(this, args), {
|
|
11218
11233
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11219
|
-
kind: import_src$
|
|
11234
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11220
11235
|
packageName: requestProtocol,
|
|
11221
11236
|
packageType: PackageType.HTTP,
|
|
11222
11237
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11228,7 +11243,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11228
11243
|
return self._handleOutboundRequestInSpan(originalRequest, args, spanInfo, inputValue, { headers: { matchImportance: 0 } });
|
|
11229
11244
|
});
|
|
11230
11245
|
},
|
|
11231
|
-
spanKind: import_src$
|
|
11246
|
+
spanKind: import_src$31.SpanKind.CLIENT
|
|
11232
11247
|
});
|
|
11233
11248
|
else return originalRequest.apply(this, args);
|
|
11234
11249
|
};
|
|
@@ -11241,12 +11256,21 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11241
11256
|
let requestOptions;
|
|
11242
11257
|
if (typeof args[0] === "string") {
|
|
11243
11258
|
const url = new URL(args[0]);
|
|
11259
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11244
11260
|
requestOptions = {
|
|
11245
11261
|
protocol: url.protocol,
|
|
11246
11262
|
hostname: url.hostname,
|
|
11247
11263
|
port: url.port ? parseInt(url.port) : void 0,
|
|
11248
11264
|
path: url.pathname + url.search,
|
|
11249
|
-
headers:
|
|
11265
|
+
headers: additionalOptions?.headers || {}
|
|
11266
|
+
};
|
|
11267
|
+
} else if (self._isURLObject(args[0])) {
|
|
11268
|
+
const url = args[0];
|
|
11269
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11270
|
+
requestOptions = {
|
|
11271
|
+
...self._urlToRequestOptions(url),
|
|
11272
|
+
headers: additionalOptions?.headers || {},
|
|
11273
|
+
...additionalOptions
|
|
11250
11274
|
};
|
|
11251
11275
|
} else requestOptions = args[0] || {};
|
|
11252
11276
|
const method = "GET";
|
|
@@ -11274,7 +11298,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11274
11298
|
};
|
|
11275
11299
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.apply(this, args), {
|
|
11276
11300
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11277
|
-
kind: import_src$
|
|
11301
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11278
11302
|
packageName: requestProtocol,
|
|
11279
11303
|
packageType: PackageType.HTTP,
|
|
11280
11304
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11308,7 +11332,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11308
11332
|
};
|
|
11309
11333
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.apply(this, args), {
|
|
11310
11334
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11311
|
-
kind: import_src$
|
|
11335
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11312
11336
|
packageName: requestProtocol,
|
|
11313
11337
|
packageType: PackageType.HTTP,
|
|
11314
11338
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11320,7 +11344,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11320
11344
|
return self._handleOutboundRequestInSpan(originalGet, args, spanInfo, inputValue, { headers: { matchImportance: 0 } });
|
|
11321
11345
|
});
|
|
11322
11346
|
},
|
|
11323
|
-
spanKind: import_src$
|
|
11347
|
+
spanKind: import_src$31.SpanKind.CLIENT
|
|
11324
11348
|
});
|
|
11325
11349
|
else return originalGet.apply(this, args);
|
|
11326
11350
|
};
|
|
@@ -11352,6 +11376,25 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11352
11376
|
};
|
|
11353
11377
|
};
|
|
11354
11378
|
}
|
|
11379
|
+
/**
|
|
11380
|
+
* Check if the input is a URL object (WHATWG URL API)
|
|
11381
|
+
* This is used to detect when a URL object is passed to http.get/request
|
|
11382
|
+
*/
|
|
11383
|
+
_isURLObject(input) {
|
|
11384
|
+
return input instanceof URL || input && typeof input.href === "string" && typeof input.pathname === "string";
|
|
11385
|
+
}
|
|
11386
|
+
/**
|
|
11387
|
+
* Convert a URL object to RequestOptions
|
|
11388
|
+
* Similar to Node.js's internal urlToHttpOptions function
|
|
11389
|
+
*/
|
|
11390
|
+
_urlToRequestOptions(url) {
|
|
11391
|
+
return {
|
|
11392
|
+
protocol: url.protocol,
|
|
11393
|
+
hostname: url.hostname,
|
|
11394
|
+
port: url.port ? parseInt(url.port) : void 0,
|
|
11395
|
+
path: url.pathname + (url.search || "")
|
|
11396
|
+
};
|
|
11397
|
+
}
|
|
11355
11398
|
_normalizeProtocol(protocol, fallback) {
|
|
11356
11399
|
if (!protocol) return fallback;
|
|
11357
11400
|
const normalized = protocol.toLowerCase().replace(/:$/, "");
|
|
@@ -11365,7 +11408,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11365
11408
|
|
|
11366
11409
|
//#endregion
|
|
11367
11410
|
//#region src/instrumentation/libraries/date/Instrumentation.ts
|
|
11368
|
-
var import_src$
|
|
11411
|
+
var import_src$30 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
11369
11412
|
/**
|
|
11370
11413
|
* Date instrumentation that provides consistent dates in replay mode.
|
|
11371
11414
|
* In replay mode, new Date() calls return the latest mock response timestamp.
|
|
@@ -11404,7 +11447,7 @@ var DateInstrumentation = class DateInstrumentation extends TdInstrumentationBas
|
|
|
11404
11447
|
if (this.mode !== TuskDriftMode.REPLAY) return this._callOriginalDate(args, isConstructorCall);
|
|
11405
11448
|
const currentSpanInfo = SpanUtils.getCurrentSpanInfo();
|
|
11406
11449
|
if (!currentSpanInfo) return this._callOriginalDate(args, isConstructorCall);
|
|
11407
|
-
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) !== import_src$
|
|
11450
|
+
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) !== import_src$30.SpanKind.SERVER) return this._callOriginalDate(args, isConstructorCall);
|
|
11408
11451
|
this.isInPatchedCall = true;
|
|
11409
11452
|
try {
|
|
11410
11453
|
return this._handleReplayDate(args, isConstructorCall);
|
|
@@ -11650,7 +11693,7 @@ var TdPgClientMock = class extends events.EventEmitter {
|
|
|
11650
11693
|
|
|
11651
11694
|
//#endregion
|
|
11652
11695
|
//#region src/instrumentation/libraries/pg/Instrumentation.ts
|
|
11653
|
-
var import_src$
|
|
11696
|
+
var import_src$29 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
11654
11697
|
var PgInstrumentation = class extends TdInstrumentationBase {
|
|
11655
11698
|
constructor(config = {}) {
|
|
11656
11699
|
super("pg", config);
|
|
@@ -11723,12 +11766,13 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11723
11766
|
const spanName = inputValue.clientType === "pool" ? "pg-pool.query" : "pg.query";
|
|
11724
11767
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
11725
11768
|
name: spanName,
|
|
11726
|
-
kind: import_src$
|
|
11769
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11727
11770
|
submodule: "query",
|
|
11728
11771
|
packageType: PackageType.PG,
|
|
11729
11772
|
packageName,
|
|
11730
11773
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
11731
11774
|
inputValue,
|
|
11775
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
11732
11776
|
isPreAppStart: false
|
|
11733
11777
|
}, (spanInfo) => {
|
|
11734
11778
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, stackTrace);
|
|
@@ -11742,18 +11786,19 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11742
11786
|
const spanName = inputValue.clientType === "pool" ? "pg-pool.query" : "pg.query";
|
|
11743
11787
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
11744
11788
|
name: spanName,
|
|
11745
|
-
kind: import_src$
|
|
11789
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11746
11790
|
submodule: "query",
|
|
11747
11791
|
packageType: PackageType.PG,
|
|
11748
11792
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
11749
11793
|
packageName,
|
|
11750
11794
|
inputValue,
|
|
11795
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
11751
11796
|
isPreAppStart
|
|
11752
11797
|
}, (spanInfo) => {
|
|
11753
11798
|
return self._handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, this);
|
|
11754
11799
|
});
|
|
11755
11800
|
},
|
|
11756
|
-
spanKind: import_src$
|
|
11801
|
+
spanKind: import_src$29.SpanKind.CLIENT
|
|
11757
11802
|
});
|
|
11758
11803
|
else return originalQuery.apply(this, args);
|
|
11759
11804
|
};
|
|
@@ -11775,7 +11820,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11775
11820
|
replayModeHandler: () => {
|
|
11776
11821
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
11777
11822
|
name: `pg.connect`,
|
|
11778
|
-
kind: import_src$
|
|
11823
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11779
11824
|
submodule: "connect",
|
|
11780
11825
|
packageName: "pg",
|
|
11781
11826
|
packageType: PackageType.PG,
|
|
@@ -11792,7 +11837,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11792
11837
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
11793
11838
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
11794
11839
|
name: `pg.connect`,
|
|
11795
|
-
kind: import_src$
|
|
11840
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11796
11841
|
submodule: "connect",
|
|
11797
11842
|
packageName: "pg",
|
|
11798
11843
|
packageType: PackageType.PG,
|
|
@@ -11803,7 +11848,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11803
11848
|
return self._handleRecordConnectInSpan(spanInfo, originalConnect, callback, this);
|
|
11804
11849
|
});
|
|
11805
11850
|
},
|
|
11806
|
-
spanKind: import_src$
|
|
11851
|
+
spanKind: import_src$29.SpanKind.CLIENT
|
|
11807
11852
|
});
|
|
11808
11853
|
else return originalConnect.apply(this, [callback]);
|
|
11809
11854
|
};
|
|
@@ -11843,7 +11888,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11843
11888
|
logger.debug(`[PgInstrumentation] PG query error (hasCallback): ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
11844
11889
|
try {
|
|
11845
11890
|
SpanUtils.endSpan(spanInfo.span, {
|
|
11846
|
-
code: import_src$
|
|
11891
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
11847
11892
|
message: error.message
|
|
11848
11893
|
});
|
|
11849
11894
|
} catch (error$1) {
|
|
@@ -11853,7 +11898,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11853
11898
|
logger.debug(`[PgInstrumentation] PG query completed successfully (hasCallback) (${SpanUtils.getTraceInfo()})`);
|
|
11854
11899
|
try {
|
|
11855
11900
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
11856
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
11901
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
11857
11902
|
} catch (error$1) {
|
|
11858
11903
|
logger.error(`[PgInstrumentation] error processing response:`, error$1);
|
|
11859
11904
|
}
|
|
@@ -11880,7 +11925,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11880
11925
|
logger.debug(`[PgInstrumentation] PG query completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
11881
11926
|
try {
|
|
11882
11927
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
11883
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
11928
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
11884
11929
|
} catch (error) {
|
|
11885
11930
|
logger.error(`[PgInstrumentation] error processing response:`, error);
|
|
11886
11931
|
}
|
|
@@ -11889,7 +11934,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11889
11934
|
logger.debug(`[PgInstrumentation] PG query error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
11890
11935
|
try {
|
|
11891
11936
|
SpanUtils.endSpan(spanInfo.span, {
|
|
11892
|
-
code: import_src$
|
|
11937
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
11893
11938
|
message: error.message
|
|
11894
11939
|
});
|
|
11895
11940
|
} catch (error$1) {
|
|
@@ -11921,10 +11966,11 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11921
11966
|
packageName,
|
|
11922
11967
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
11923
11968
|
submoduleName: "query",
|
|
11924
|
-
kind: import_src$
|
|
11969
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11925
11970
|
stackTrace
|
|
11926
11971
|
},
|
|
11927
|
-
tuskDrift: this.tuskDrift
|
|
11972
|
+
tuskDrift: this.tuskDrift,
|
|
11973
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
11928
11974
|
});
|
|
11929
11975
|
if (!mockData) {
|
|
11930
11976
|
const queryText = queryConfig.text || inputValue.text || "UNKNOWN_QUERY";
|
|
@@ -12007,7 +12053,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12007
12053
|
logger.debug(`[PgInstrumentation] PG connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
12008
12054
|
try {
|
|
12009
12055
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12010
|
-
code: import_src$
|
|
12056
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12011
12057
|
message: error.message
|
|
12012
12058
|
});
|
|
12013
12059
|
} catch (error$1) {
|
|
@@ -12017,7 +12063,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12017
12063
|
logger.debug(`[PgInstrumentation] PG connect completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
12018
12064
|
try {
|
|
12019
12065
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
12020
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12066
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12021
12067
|
} catch (error$1) {
|
|
12022
12068
|
logger.error(`[PgInstrumentation] error processing connect response:`, error$1);
|
|
12023
12069
|
}
|
|
@@ -12029,7 +12075,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12029
12075
|
logger.debug(`[PgInstrumentation] PG connect completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
12030
12076
|
try {
|
|
12031
12077
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
12032
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12078
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12033
12079
|
} catch (error) {
|
|
12034
12080
|
logger.error(`[PgInstrumentation] error processing connect response:`, error);
|
|
12035
12081
|
}
|
|
@@ -12038,7 +12084,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12038
12084
|
logger.debug(`[PgInstrumentation] PG connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
12039
12085
|
try {
|
|
12040
12086
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12041
|
-
code: import_src$
|
|
12087
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12042
12088
|
message: error.message
|
|
12043
12089
|
});
|
|
12044
12090
|
} catch (error$1) {
|
|
@@ -12110,7 +12156,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12110
12156
|
replayModeHandler: () => {
|
|
12111
12157
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
12112
12158
|
name: `pg-pool.connect`,
|
|
12113
|
-
kind: import_src$
|
|
12159
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
12114
12160
|
submodule: "connect",
|
|
12115
12161
|
packageName: "pg-pool",
|
|
12116
12162
|
packageType: PackageType.PG,
|
|
@@ -12127,7 +12173,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12127
12173
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12128
12174
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
12129
12175
|
name: `pg-pool.connect`,
|
|
12130
|
-
kind: import_src$
|
|
12176
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
12131
12177
|
submodule: "connect",
|
|
12132
12178
|
packageName: "pg-pool",
|
|
12133
12179
|
packageType: PackageType.PG,
|
|
@@ -12138,7 +12184,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12138
12184
|
return self._handleRecordPoolConnectInSpan(spanInfo, originalConnect, callback, this);
|
|
12139
12185
|
});
|
|
12140
12186
|
},
|
|
12141
|
-
spanKind: import_src$
|
|
12187
|
+
spanKind: import_src$29.SpanKind.CLIENT
|
|
12142
12188
|
});
|
|
12143
12189
|
else return originalConnect.apply(this, [callback]);
|
|
12144
12190
|
};
|
|
@@ -12151,7 +12197,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12151
12197
|
logger.debug(`[PgInstrumentation] PG Pool connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
12152
12198
|
try {
|
|
12153
12199
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12154
|
-
code: import_src$
|
|
12200
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12155
12201
|
message: error.message
|
|
12156
12202
|
});
|
|
12157
12203
|
} catch (error$1) {
|
|
@@ -12164,7 +12210,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12164
12210
|
connected: true,
|
|
12165
12211
|
hasClient: !!client
|
|
12166
12212
|
} });
|
|
12167
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12213
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12168
12214
|
} catch (error$1) {
|
|
12169
12215
|
logger.error(`[PgInstrumentation] error processing pool connect response:`, error$1);
|
|
12170
12216
|
}
|
|
@@ -12179,7 +12225,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12179
12225
|
connected: true,
|
|
12180
12226
|
hasClient: !!client
|
|
12181
12227
|
} });
|
|
12182
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12228
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12183
12229
|
} catch (error) {
|
|
12184
12230
|
logger.error(`[PgInstrumentation] error processing pool connect response:`, error);
|
|
12185
12231
|
}
|
|
@@ -12188,7 +12234,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12188
12234
|
logger.debug(`[PgInstrumentation] PG Pool connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
12189
12235
|
try {
|
|
12190
12236
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12191
|
-
code: import_src$
|
|
12237
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12192
12238
|
message: error.message
|
|
12193
12239
|
});
|
|
12194
12240
|
} catch (error$1) {
|
|
@@ -12313,7 +12359,7 @@ function reconstructQueryString(strings, values) {
|
|
|
12313
12359
|
|
|
12314
12360
|
//#endregion
|
|
12315
12361
|
//#region src/instrumentation/libraries/postgres/handlers/ConnectionHandler.ts
|
|
12316
|
-
var import_src$
|
|
12362
|
+
var import_src$28 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
12317
12363
|
var ConnectionHandler = class {
|
|
12318
12364
|
constructor(mode, instrumentationName, isAppReady, wrapSqlInstance) {
|
|
12319
12365
|
this.mode = mode;
|
|
@@ -12357,7 +12403,7 @@ var ConnectionHandler = class {
|
|
|
12357
12403
|
return this.wrapSqlInstance(sqlInstance);
|
|
12358
12404
|
}, {
|
|
12359
12405
|
name: "postgres.connect",
|
|
12360
|
-
kind: import_src$
|
|
12406
|
+
kind: import_src$28.SpanKind.CLIENT,
|
|
12361
12407
|
submodule: "connect",
|
|
12362
12408
|
packageType: PackageType.PG,
|
|
12363
12409
|
packageName: "postgres",
|
|
@@ -12380,7 +12426,7 @@ var ConnectionHandler = class {
|
|
|
12380
12426
|
return this.wrapSqlInstance(sqlInstance);
|
|
12381
12427
|
}, {
|
|
12382
12428
|
name: "postgres.connect",
|
|
12383
|
-
kind: import_src$
|
|
12429
|
+
kind: import_src$28.SpanKind.CLIENT,
|
|
12384
12430
|
submodule: "connect",
|
|
12385
12431
|
packageType: PackageType.PG,
|
|
12386
12432
|
packageName: "postgres",
|
|
@@ -12391,7 +12437,7 @@ var ConnectionHandler = class {
|
|
|
12391
12437
|
return this.handleRecordConnect(spanInfo, originalFunction, args);
|
|
12392
12438
|
});
|
|
12393
12439
|
},
|
|
12394
|
-
spanKind: import_src$
|
|
12440
|
+
spanKind: import_src$28.SpanKind.CLIENT
|
|
12395
12441
|
});
|
|
12396
12442
|
else return originalFunction(...args);
|
|
12397
12443
|
}
|
|
@@ -12401,7 +12447,7 @@ var ConnectionHandler = class {
|
|
|
12401
12447
|
try {
|
|
12402
12448
|
logger.debug(`[PostgresInstrumentation] Postgres connection created successfully (${SpanUtils.getTraceInfo()})`);
|
|
12403
12449
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
12404
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12450
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$28.SpanStatusCode.OK });
|
|
12405
12451
|
} catch (error) {
|
|
12406
12452
|
logger.error(`[PostgresInstrumentation] error adding span attributes:`, error);
|
|
12407
12453
|
}
|
|
@@ -12421,7 +12467,7 @@ var ConnectionHandler = class {
|
|
|
12421
12467
|
|
|
12422
12468
|
//#endregion
|
|
12423
12469
|
//#region src/instrumentation/libraries/postgres/Instrumentation.ts
|
|
12424
|
-
var import_src$
|
|
12470
|
+
var import_src$27 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
12425
12471
|
var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
12426
12472
|
constructor(config = {}) {
|
|
12427
12473
|
super("postgres", config);
|
|
@@ -12592,7 +12638,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12592
12638
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12593
12639
|
return SpanUtils.createAndExecuteSpan(this.mode, () => originalListen.call(sqlInstance, channelName, callback, onlisten), {
|
|
12594
12640
|
name: "postgres.listen",
|
|
12595
|
-
kind: import_src$
|
|
12641
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12596
12642
|
submodule: "listen",
|
|
12597
12643
|
packageType: PackageType.PG,
|
|
12598
12644
|
packageName: "postgres",
|
|
@@ -12619,7 +12665,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12619
12665
|
state: result.state,
|
|
12620
12666
|
payloads: receivedPayloads
|
|
12621
12667
|
} });
|
|
12622
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12668
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12623
12669
|
} catch (error) {
|
|
12624
12670
|
logger.error(`[PostgresInstrumentation] error adding span attributes:`, error);
|
|
12625
12671
|
}
|
|
@@ -12633,7 +12679,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12633
12679
|
logger.error(`[PostgresInstrumentation] RECORD listen error: ${error.message}`);
|
|
12634
12680
|
try {
|
|
12635
12681
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12636
|
-
code: import_src$
|
|
12682
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12637
12683
|
message: error.message
|
|
12638
12684
|
});
|
|
12639
12685
|
} catch (error$1) {
|
|
@@ -12643,7 +12689,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12643
12689
|
}
|
|
12644
12690
|
});
|
|
12645
12691
|
},
|
|
12646
|
-
spanKind: import_src$
|
|
12692
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
12647
12693
|
});
|
|
12648
12694
|
}
|
|
12649
12695
|
async _handleReplayListen(channelName, callback, onlisten, inputValue) {
|
|
@@ -12661,7 +12707,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12661
12707
|
unlisten: async () => {}
|
|
12662
12708
|
}), {
|
|
12663
12709
|
name: "postgres.listen",
|
|
12664
|
-
kind: import_src$
|
|
12710
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12665
12711
|
submodule: "listen",
|
|
12666
12712
|
packageType: PackageType.PG,
|
|
12667
12713
|
packageName: "postgres",
|
|
@@ -12689,7 +12735,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12689
12735
|
logger.debug(`[PostgresInstrumentation] REPLAY: Invoking callback with recorded payload: ${payload}`);
|
|
12690
12736
|
callback(payload);
|
|
12691
12737
|
}
|
|
12692
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12738
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12693
12739
|
return {
|
|
12694
12740
|
state: recordedState,
|
|
12695
12741
|
unlisten: async () => {
|
|
@@ -12699,7 +12745,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12699
12745
|
} catch (error) {
|
|
12700
12746
|
logger.error(`[PostgresInstrumentation] REPLAY listen error: ${error.message}`);
|
|
12701
12747
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12702
|
-
code: import_src$
|
|
12748
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12703
12749
|
message: error.message
|
|
12704
12750
|
});
|
|
12705
12751
|
throw error;
|
|
@@ -12718,7 +12764,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12718
12764
|
}
|
|
12719
12765
|
_handleSqlQuery(originalSql, strings, values) {
|
|
12720
12766
|
if (!strings || !Array.isArray(strings.raw)) return originalSql.call(this, strings, ...values);
|
|
12721
|
-
const creationContext = import_src$
|
|
12767
|
+
const creationContext = import_src$27.context.active();
|
|
12722
12768
|
const query = originalSql.call(this, strings, ...values);
|
|
12723
12769
|
const inputValue = {
|
|
12724
12770
|
query: reconstructQueryString(strings, values).trim(),
|
|
@@ -12741,7 +12787,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12741
12787
|
else if (parameters !== void 0) return originalUnsafe.call(sqlInstance, query, parameters);
|
|
12742
12788
|
else return originalUnsafe.call(sqlInstance, query);
|
|
12743
12789
|
})();
|
|
12744
|
-
const creationContext = import_src$
|
|
12790
|
+
const creationContext = import_src$27.context.active();
|
|
12745
12791
|
const originalThen = unsafeQuery.then.bind(unsafeQuery);
|
|
12746
12792
|
const inputValue = {
|
|
12747
12793
|
query: query.trim(),
|
|
@@ -12764,7 +12810,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12764
12810
|
else if (parameters !== void 0) return originalFile.call(sqlInstance, path$5, parameters);
|
|
12765
12811
|
else return originalFile.call(sqlInstance, path$5);
|
|
12766
12812
|
})();
|
|
12767
|
-
const creationContext = import_src$
|
|
12813
|
+
const creationContext = import_src$27.context.active();
|
|
12768
12814
|
const originalThen = fileQuery.then.bind(fileQuery);
|
|
12769
12815
|
const self = this;
|
|
12770
12816
|
const inputValue = {
|
|
@@ -12775,25 +12821,26 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12775
12821
|
fileQuery.then = function(onFulfilled, onRejected) {
|
|
12776
12822
|
if (fileQuery._tuskRecorded) return originalThen(onFulfilled, onRejected);
|
|
12777
12823
|
fileQuery._tuskRecorded = true;
|
|
12778
|
-
return import_src$
|
|
12824
|
+
return import_src$27.context.with(creationContext, () => {
|
|
12779
12825
|
if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
12780
12826
|
originalFunctionCall: () => originalThen(onFulfilled, onRejected),
|
|
12781
12827
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12782
12828
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
12783
12829
|
name: "postgres.file",
|
|
12784
|
-
kind: import_src$
|
|
12830
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12785
12831
|
submodule: "file",
|
|
12786
12832
|
packageType: PackageType.PG,
|
|
12787
12833
|
packageName: "postgres",
|
|
12788
12834
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
12789
12835
|
inputValue,
|
|
12836
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
12790
12837
|
isPreAppStart
|
|
12791
12838
|
}, (spanInfo) => {
|
|
12792
12839
|
const wrappedOnFulfilled = (result) => {
|
|
12793
12840
|
try {
|
|
12794
12841
|
logger.debug(`[PostgresInstrumentation] Postgres file query completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
12795
12842
|
addOutputAttributesToSpan(spanInfo, result);
|
|
12796
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12843
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12797
12844
|
} catch (error) {
|
|
12798
12845
|
logger.error(`[PostgresInstrumentation] error processing file query response:`, error);
|
|
12799
12846
|
}
|
|
@@ -12803,7 +12850,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12803
12850
|
try {
|
|
12804
12851
|
logger.debug(`[PostgresInstrumentation] Postgres file query error: ${error.message}`);
|
|
12805
12852
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12806
|
-
code: import_src$
|
|
12853
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12807
12854
|
message: error.message
|
|
12808
12855
|
});
|
|
12809
12856
|
} catch (spanError) {
|
|
@@ -12815,7 +12862,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12815
12862
|
return originalThen(wrappedOnFulfilled, wrappedOnRejected);
|
|
12816
12863
|
});
|
|
12817
12864
|
},
|
|
12818
|
-
spanKind: import_src$
|
|
12865
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
12819
12866
|
});
|
|
12820
12867
|
else if (self.mode === TuskDriftMode.REPLAY) {
|
|
12821
12868
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
@@ -12828,12 +12875,13 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12828
12875
|
replayModeHandler: () => {
|
|
12829
12876
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
12830
12877
|
name: "postgres.file",
|
|
12831
|
-
kind: import_src$
|
|
12878
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12832
12879
|
submodule: "file",
|
|
12833
12880
|
packageType: PackageType.PG,
|
|
12834
12881
|
packageName: "postgres",
|
|
12835
12882
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
12836
12883
|
inputValue,
|
|
12884
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
12837
12885
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
12838
12886
|
}, async (spanInfo) => {
|
|
12839
12887
|
const mockedResult = await self._handleReplayQueryOperation({
|
|
@@ -12901,7 +12949,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12901
12949
|
replayModeHandler: () => {
|
|
12902
12950
|
return SpanUtils.createAndExecuteSpan(this.mode, () => executeBegin(), {
|
|
12903
12951
|
name: "postgres.begin",
|
|
12904
|
-
kind: import_src$
|
|
12952
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12905
12953
|
submodule: "transaction",
|
|
12906
12954
|
packageType: PackageType.PG,
|
|
12907
12955
|
packageName: "postgres",
|
|
@@ -12918,7 +12966,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12918
12966
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12919
12967
|
return SpanUtils.createAndExecuteSpan(this.mode, executeBegin, {
|
|
12920
12968
|
name: "postgres.begin",
|
|
12921
|
-
kind: import_src$
|
|
12969
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12922
12970
|
submodule: "transaction",
|
|
12923
12971
|
packageType: PackageType.PG,
|
|
12924
12972
|
packageName: "postgres",
|
|
@@ -12929,7 +12977,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12929
12977
|
return this._handleRecordBeginTransaction(spanInfo, executeBegin);
|
|
12930
12978
|
});
|
|
12931
12979
|
},
|
|
12932
|
-
spanKind: import_src$
|
|
12980
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
12933
12981
|
});
|
|
12934
12982
|
else return executeBegin();
|
|
12935
12983
|
}
|
|
@@ -12941,7 +12989,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12941
12989
|
status: "committed",
|
|
12942
12990
|
result
|
|
12943
12991
|
} });
|
|
12944
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12992
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12945
12993
|
} catch (error) {
|
|
12946
12994
|
logger.error(`[PostgresInstrumentation] error processing transaction response:`, error);
|
|
12947
12995
|
}
|
|
@@ -12954,7 +13002,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12954
13002
|
error: error.message
|
|
12955
13003
|
} });
|
|
12956
13004
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12957
|
-
code: import_src$
|
|
13005
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12958
13006
|
message: error.message
|
|
12959
13007
|
});
|
|
12960
13008
|
} catch (spanError) {
|
|
@@ -13033,10 +13081,11 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13033
13081
|
packageName: "postgres",
|
|
13034
13082
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
13035
13083
|
submoduleName,
|
|
13036
|
-
kind: import_src$
|
|
13084
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13037
13085
|
stackTrace
|
|
13038
13086
|
},
|
|
13039
|
-
tuskDrift: this.tuskDrift
|
|
13087
|
+
tuskDrift: this.tuskDrift,
|
|
13088
|
+
inputValueSchemaMerges: { parameters: { matchImportance: 0 } }
|
|
13040
13089
|
});
|
|
13041
13090
|
}
|
|
13042
13091
|
/**
|
|
@@ -13050,7 +13099,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13050
13099
|
state: result?.state,
|
|
13051
13100
|
statement: result?.statement
|
|
13052
13101
|
}));
|
|
13053
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13102
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13054
13103
|
logger.debug(`[PostgresInstrumentation] ${operation} completed, recorded ${allRows.length} rows`);
|
|
13055
13104
|
}
|
|
13056
13105
|
/**
|
|
@@ -13078,18 +13127,19 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13078
13127
|
}
|
|
13079
13128
|
_handleCursorCallbackRecord({ originalCursor, rows, inputValue, creationContext, userCallback }) {
|
|
13080
13129
|
const self = this;
|
|
13081
|
-
return import_src$
|
|
13130
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13082
13131
|
return handleRecordMode({
|
|
13083
13132
|
originalFunctionCall: () => originalCursor(rows, userCallback),
|
|
13084
13133
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
13085
13134
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCursor(rows, userCallback), {
|
|
13086
13135
|
name: "postgres.cursor",
|
|
13087
|
-
kind: import_src$
|
|
13136
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13088
13137
|
submodule: "cursor",
|
|
13089
13138
|
packageType: PackageType.PG,
|
|
13090
13139
|
packageName: "postgres",
|
|
13091
13140
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13092
13141
|
inputValue,
|
|
13142
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13093
13143
|
isPreAppStart
|
|
13094
13144
|
}, (spanInfo) => {
|
|
13095
13145
|
return self._executeAndRecordCursorCallback({
|
|
@@ -13100,7 +13150,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13100
13150
|
});
|
|
13101
13151
|
});
|
|
13102
13152
|
},
|
|
13103
|
-
spanKind: import_src$
|
|
13153
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
13104
13154
|
});
|
|
13105
13155
|
});
|
|
13106
13156
|
}
|
|
@@ -13123,7 +13173,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13123
13173
|
logger.debug(`[PostgresInstrumentation] Cursor callback error: ${error.message}`);
|
|
13124
13174
|
if (spanInfo) try {
|
|
13125
13175
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13126
|
-
code: import_src$
|
|
13176
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13127
13177
|
message: error.message
|
|
13128
13178
|
});
|
|
13129
13179
|
} catch (error$1) {
|
|
@@ -13135,19 +13185,20 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13135
13185
|
_handleCursorCallbackReplay({ inputValue, creationContext, cursorBatchSize, userCallback }) {
|
|
13136
13186
|
const self = this;
|
|
13137
13187
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
13138
|
-
return import_src$
|
|
13188
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13139
13189
|
return handleReplayMode({
|
|
13140
13190
|
noOpRequestHandler: () => Promise.resolve(),
|
|
13141
13191
|
isServerRequest: false,
|
|
13142
13192
|
replayModeHandler: () => {
|
|
13143
13193
|
return SpanUtils.createAndExecuteSpan(self.mode, () => Promise.resolve(), {
|
|
13144
13194
|
name: "postgres.cursor",
|
|
13145
|
-
kind: import_src$
|
|
13195
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13146
13196
|
submodule: "cursor",
|
|
13147
13197
|
packageType: PackageType.PG,
|
|
13148
13198
|
packageName: "postgres",
|
|
13149
13199
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13150
13200
|
inputValue,
|
|
13201
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13151
13202
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13152
13203
|
}, async (spanInfo) => {
|
|
13153
13204
|
try {
|
|
@@ -13167,11 +13218,11 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13167
13218
|
logger.debug(`[PostgresInstrumentation] Cursor replay calling callback with batch of ${batch.length} rows`);
|
|
13168
13219
|
await userCallback(batch);
|
|
13169
13220
|
}
|
|
13170
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13221
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13171
13222
|
} catch (error) {
|
|
13172
13223
|
logger.debug(`[PostgresInstrumentation] Cursor callback replay error: ${error.message}`);
|
|
13173
13224
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13174
|
-
code: import_src$
|
|
13225
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13175
13226
|
message: error.message
|
|
13176
13227
|
});
|
|
13177
13228
|
throw error;
|
|
@@ -13191,7 +13242,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13191
13242
|
let spanStarted = false;
|
|
13192
13243
|
return {
|
|
13193
13244
|
async next() {
|
|
13194
|
-
return import_src$
|
|
13245
|
+
return import_src$27.context.with(creationContext, async () => {
|
|
13195
13246
|
if (!spanStarted) {
|
|
13196
13247
|
spanStarted = true;
|
|
13197
13248
|
let spanInputValue;
|
|
@@ -13203,7 +13254,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13203
13254
|
}
|
|
13204
13255
|
spanInfo = SpanUtils.createSpan({
|
|
13205
13256
|
name: "postgres.cursor",
|
|
13206
|
-
kind: import_src$
|
|
13257
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13207
13258
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true,
|
|
13208
13259
|
attributes: {
|
|
13209
13260
|
[TdSpanAttributes.NAME]: "postgres.cursor",
|
|
@@ -13238,7 +13289,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13238
13289
|
} catch (error) {
|
|
13239
13290
|
if (spanInfo) try {
|
|
13240
13291
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13241
|
-
code: import_src$
|
|
13292
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13242
13293
|
message: error.message
|
|
13243
13294
|
});
|
|
13244
13295
|
} catch (error$1) {
|
|
@@ -13273,12 +13324,12 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13273
13324
|
let dataFetched = false;
|
|
13274
13325
|
return {
|
|
13275
13326
|
async next() {
|
|
13276
|
-
return import_src$
|
|
13327
|
+
return import_src$27.context.with(creationContext, async () => {
|
|
13277
13328
|
if (!dataFetched) {
|
|
13278
13329
|
dataFetched = true;
|
|
13279
13330
|
spanInfo = SpanUtils.createSpan({
|
|
13280
13331
|
name: "postgres.cursor",
|
|
13281
|
-
kind: import_src$
|
|
13332
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13282
13333
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true,
|
|
13283
13334
|
attributes: {
|
|
13284
13335
|
[TdSpanAttributes.NAME]: "postgres.cursor",
|
|
@@ -13300,7 +13351,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13300
13351
|
});
|
|
13301
13352
|
if (!mockData) {
|
|
13302
13353
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13303
|
-
code: import_src$
|
|
13354
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13304
13355
|
message: "No mock data found"
|
|
13305
13356
|
});
|
|
13306
13357
|
throw new Error(`[PostgresInstrumentation] No matching mock found for cursor query: ${inputValue.query}`);
|
|
@@ -13310,7 +13361,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13310
13361
|
mockedData = Array.isArray(processedResult) ? processedResult : [];
|
|
13311
13362
|
}
|
|
13312
13363
|
if (currentIndex >= mockedData.length) {
|
|
13313
|
-
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13364
|
+
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13314
13365
|
return {
|
|
13315
13366
|
done: true,
|
|
13316
13367
|
value: void 0
|
|
@@ -13326,7 +13377,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13326
13377
|
});
|
|
13327
13378
|
},
|
|
13328
13379
|
async return() {
|
|
13329
|
-
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13380
|
+
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13330
13381
|
return {
|
|
13331
13382
|
done: true,
|
|
13332
13383
|
value: void 0
|
|
@@ -13337,18 +13388,19 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13337
13388
|
}
|
|
13338
13389
|
_handleForEachRecord({ originalForEach, inputValue, creationContext, userCallback }) {
|
|
13339
13390
|
const self = this;
|
|
13340
|
-
return import_src$
|
|
13391
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13341
13392
|
return handleRecordMode({
|
|
13342
13393
|
originalFunctionCall: () => originalForEach(userCallback),
|
|
13343
13394
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
13344
13395
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalForEach(userCallback), {
|
|
13345
13396
|
name: "postgres.query",
|
|
13346
|
-
kind: import_src$
|
|
13397
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13347
13398
|
submodule: "query",
|
|
13348
13399
|
packageType: PackageType.PG,
|
|
13349
13400
|
packageName: "postgres",
|
|
13350
13401
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13351
13402
|
inputValue,
|
|
13403
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13352
13404
|
isPreAppStart
|
|
13353
13405
|
}, async (spanInfo) => {
|
|
13354
13406
|
const allRows = [];
|
|
@@ -13367,7 +13419,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13367
13419
|
} catch (error) {
|
|
13368
13420
|
try {
|
|
13369
13421
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13370
|
-
code: import_src$
|
|
13422
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13371
13423
|
message: error.message
|
|
13372
13424
|
});
|
|
13373
13425
|
} catch (error$1) {
|
|
@@ -13377,14 +13429,14 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13377
13429
|
}
|
|
13378
13430
|
});
|
|
13379
13431
|
},
|
|
13380
|
-
spanKind: import_src$
|
|
13432
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
13381
13433
|
});
|
|
13382
13434
|
});
|
|
13383
13435
|
}
|
|
13384
13436
|
_handleForEachReplay({ inputValue, creationContext, userCallback }) {
|
|
13385
13437
|
const self = this;
|
|
13386
13438
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
13387
|
-
return import_src$
|
|
13439
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13388
13440
|
return handleReplayMode({
|
|
13389
13441
|
noOpRequestHandler: () => Promise.resolve(Object.assign([], {
|
|
13390
13442
|
count: 0,
|
|
@@ -13397,12 +13449,13 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13397
13449
|
command: null
|
|
13398
13450
|
})), {
|
|
13399
13451
|
name: "postgres.query",
|
|
13400
|
-
kind: import_src$
|
|
13452
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13401
13453
|
submodule: "query",
|
|
13402
13454
|
packageType: PackageType.PG,
|
|
13403
13455
|
packageName: "postgres",
|
|
13404
13456
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13405
13457
|
inputValue,
|
|
13458
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13406
13459
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13407
13460
|
}, async (spanInfo) => {
|
|
13408
13461
|
try {
|
|
@@ -13417,7 +13470,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13417
13470
|
const mockedRows = Array.isArray(mockedResult) ? mockedResult : [];
|
|
13418
13471
|
logger.debug(`[PostgresInstrumentation] forEach replay: calling callback with ${mockedRows.length} mocked rows`);
|
|
13419
13472
|
for (const row of mockedRows) userCallback(row, mockedResult);
|
|
13420
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13473
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13421
13474
|
return Object.assign([], {
|
|
13422
13475
|
count: mockedRows.length,
|
|
13423
13476
|
command: null
|
|
@@ -13425,7 +13478,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13425
13478
|
} catch (error) {
|
|
13426
13479
|
logger.debug(`[PostgresInstrumentation] forEach replay error: ${error.message}`);
|
|
13427
13480
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13428
|
-
code: import_src$
|
|
13481
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13429
13482
|
message: error.message
|
|
13430
13483
|
});
|
|
13431
13484
|
throw error;
|
|
@@ -13445,25 +13498,26 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13445
13498
|
if (query._forEachCalled) return originalThen(onFulfilled, onRejected);
|
|
13446
13499
|
if (query._tuskRecorded) return originalThen(onFulfilled, onRejected);
|
|
13447
13500
|
query._tuskRecorded = true;
|
|
13448
|
-
return import_src$
|
|
13501
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13449
13502
|
if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
13450
13503
|
originalFunctionCall: () => originalThen(onFulfilled, onRejected),
|
|
13451
13504
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
13452
13505
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
13453
13506
|
name: spanConfig.name,
|
|
13454
|
-
kind: import_src$
|
|
13507
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13455
13508
|
submodule: spanConfig.submodule,
|
|
13456
13509
|
packageType: PackageType.PG,
|
|
13457
13510
|
packageName: "postgres",
|
|
13458
13511
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13459
13512
|
inputValue,
|
|
13513
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13460
13514
|
isPreAppStart
|
|
13461
13515
|
}, (spanInfo) => {
|
|
13462
13516
|
const wrappedOnFulfilled = (result) => {
|
|
13463
13517
|
try {
|
|
13464
13518
|
logger.debug(`[PostgresInstrumentation] Postgres ${spanConfig.operationType} query completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
13465
13519
|
addOutputAttributesToSpan(spanInfo, result);
|
|
13466
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13520
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13467
13521
|
} catch (error) {
|
|
13468
13522
|
logger.error(`[PostgresInstrumentation] error processing ${spanConfig.operationType} query response:`, error);
|
|
13469
13523
|
}
|
|
@@ -13473,7 +13527,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13473
13527
|
try {
|
|
13474
13528
|
logger.debug(`[PostgresInstrumentation] Postgres ${spanConfig.operationType} query error: ${error.message}`);
|
|
13475
13529
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13476
|
-
code: import_src$
|
|
13530
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13477
13531
|
message: error.message
|
|
13478
13532
|
});
|
|
13479
13533
|
} catch (spanError) {
|
|
@@ -13485,7 +13539,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13485
13539
|
return originalThen(wrappedOnFulfilled, wrappedOnRejected);
|
|
13486
13540
|
});
|
|
13487
13541
|
},
|
|
13488
|
-
spanKind: import_src$
|
|
13542
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
13489
13543
|
});
|
|
13490
13544
|
else if (self.mode === TuskDriftMode.REPLAY) {
|
|
13491
13545
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
@@ -13498,12 +13552,13 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13498
13552
|
replayModeHandler: () => {
|
|
13499
13553
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
13500
13554
|
name: spanConfig.name,
|
|
13501
|
-
kind: import_src$
|
|
13555
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13502
13556
|
submodule: spanConfig.submodule,
|
|
13503
13557
|
packageType: PackageType.PG,
|
|
13504
13558
|
packageName: "postgres",
|
|
13505
13559
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13506
13560
|
inputValue,
|
|
13561
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13507
13562
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13508
13563
|
}, async (spanInfo) => {
|
|
13509
13564
|
const mockedResult = await self._handleReplayQueryOperation({
|
|
@@ -13779,7 +13834,7 @@ var TdMysqlConnectionMock = class extends events.EventEmitter {
|
|
|
13779
13834
|
|
|
13780
13835
|
//#endregion
|
|
13781
13836
|
//#region src/instrumentation/libraries/mysql/mocks/TdMysqlQueryMock.ts
|
|
13782
|
-
var import_src$
|
|
13837
|
+
var import_src$26 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
13783
13838
|
/**
|
|
13784
13839
|
* Handles replay mode for MySQL query operations
|
|
13785
13840
|
* Returns EventEmitters synchronously to support both callback and streaming modes
|
|
@@ -13900,17 +13955,18 @@ var TdMysqlQueryMock = class {
|
|
|
13900
13955
|
packageName: "mysql",
|
|
13901
13956
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
13902
13957
|
submoduleName: "query",
|
|
13903
|
-
kind: import_src$
|
|
13958
|
+
kind: import_src$26.SpanKind.CLIENT,
|
|
13904
13959
|
stackTrace
|
|
13905
13960
|
},
|
|
13906
|
-
tuskDrift: this.tuskDrift
|
|
13961
|
+
tuskDrift: this.tuskDrift,
|
|
13962
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
13907
13963
|
});
|
|
13908
13964
|
}
|
|
13909
13965
|
};
|
|
13910
13966
|
|
|
13911
13967
|
//#endregion
|
|
13912
13968
|
//#region src/instrumentation/libraries/mysql/Instrumentation.ts
|
|
13913
|
-
var import_src$
|
|
13969
|
+
var import_src$25 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
13914
13970
|
var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
13915
13971
|
constructor(config = {}) {
|
|
13916
13972
|
super("mysql", config);
|
|
@@ -14153,12 +14209,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14153
14209
|
replayModeHandler: () => {
|
|
14154
14210
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
14155
14211
|
name: "mysql.query",
|
|
14156
|
-
kind: import_src$
|
|
14212
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14157
14213
|
submodule: "query",
|
|
14158
14214
|
packageType: PackageType.MYSQL,
|
|
14159
14215
|
packageName: "mysql",
|
|
14160
14216
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14161
14217
|
inputValue,
|
|
14218
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14162
14219
|
isPreAppStart: false
|
|
14163
14220
|
}, (spanInfo) => {
|
|
14164
14221
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -14179,18 +14236,19 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14179
14236
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14180
14237
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
14181
14238
|
name: "mysql.query",
|
|
14182
|
-
kind: import_src$
|
|
14239
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14183
14240
|
submodule: "query",
|
|
14184
14241
|
packageType: PackageType.MYSQL,
|
|
14185
14242
|
packageName: "mysql",
|
|
14186
14243
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14187
14244
|
inputValue,
|
|
14245
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14188
14246
|
isPreAppStart
|
|
14189
14247
|
}, (spanInfo) => {
|
|
14190
14248
|
return self._handleRecordQuery(spanInfo, originalQuery, this, args, callback, isEventEmitterMode);
|
|
14191
14249
|
});
|
|
14192
14250
|
},
|
|
14193
|
-
spanKind: import_src$
|
|
14251
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14194
14252
|
});
|
|
14195
14253
|
else return originalQuery.apply(this, args);
|
|
14196
14254
|
};
|
|
@@ -14221,7 +14279,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14221
14279
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14222
14280
|
return originalConnect.apply(this, arguments);
|
|
14223
14281
|
},
|
|
14224
|
-
spanKind: import_src$
|
|
14282
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14225
14283
|
});
|
|
14226
14284
|
else return originalConnect.apply(this, arguments);
|
|
14227
14285
|
};
|
|
@@ -14246,7 +14304,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14246
14304
|
replayModeHandler: () => {
|
|
14247
14305
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(this, arguments), {
|
|
14248
14306
|
name: "mysql.beginTransaction",
|
|
14249
|
-
kind: import_src$
|
|
14307
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14250
14308
|
submodule: "transaction",
|
|
14251
14309
|
packageType: PackageType.MYSQL,
|
|
14252
14310
|
packageName: "mysql",
|
|
@@ -14263,7 +14321,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14263
14321
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14264
14322
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(this, arguments), {
|
|
14265
14323
|
name: "mysql.beginTransaction",
|
|
14266
|
-
kind: import_src$
|
|
14324
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14267
14325
|
submodule: "transaction",
|
|
14268
14326
|
packageType: PackageType.MYSQL,
|
|
14269
14327
|
packageName: "mysql",
|
|
@@ -14274,7 +14332,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14274
14332
|
return self._handleRecordTransaction(spanInfo, originalBeginTransaction, this, arguments, actualCallback);
|
|
14275
14333
|
});
|
|
14276
14334
|
},
|
|
14277
|
-
spanKind: import_src$
|
|
14335
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14278
14336
|
});
|
|
14279
14337
|
else return originalBeginTransaction.apply(this, arguments);
|
|
14280
14338
|
};
|
|
@@ -14299,7 +14357,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14299
14357
|
replayModeHandler: () => {
|
|
14300
14358
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(this, arguments), {
|
|
14301
14359
|
name: "mysql.commit",
|
|
14302
|
-
kind: import_src$
|
|
14360
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14303
14361
|
submodule: "transaction",
|
|
14304
14362
|
packageType: PackageType.MYSQL,
|
|
14305
14363
|
packageName: "mysql",
|
|
@@ -14316,7 +14374,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14316
14374
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14317
14375
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(this, arguments), {
|
|
14318
14376
|
name: "mysql.commit",
|
|
14319
|
-
kind: import_src$
|
|
14377
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14320
14378
|
submodule: "transaction",
|
|
14321
14379
|
packageType: PackageType.MYSQL,
|
|
14322
14380
|
packageName: "mysql",
|
|
@@ -14327,7 +14385,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14327
14385
|
return self._handleRecordTransaction(spanInfo, originalCommit, this, arguments, actualCallback);
|
|
14328
14386
|
});
|
|
14329
14387
|
},
|
|
14330
|
-
spanKind: import_src$
|
|
14388
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14331
14389
|
});
|
|
14332
14390
|
else return originalCommit.apply(this, arguments);
|
|
14333
14391
|
};
|
|
@@ -14352,7 +14410,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14352
14410
|
replayModeHandler: () => {
|
|
14353
14411
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(this, arguments), {
|
|
14354
14412
|
name: "mysql.rollback",
|
|
14355
|
-
kind: import_src$
|
|
14413
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14356
14414
|
submodule: "transaction",
|
|
14357
14415
|
packageType: PackageType.MYSQL,
|
|
14358
14416
|
packageName: "mysql",
|
|
@@ -14369,7 +14427,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14369
14427
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14370
14428
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(this, arguments), {
|
|
14371
14429
|
name: "mysql.rollback",
|
|
14372
|
-
kind: import_src$
|
|
14430
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14373
14431
|
submodule: "transaction",
|
|
14374
14432
|
packageType: PackageType.MYSQL,
|
|
14375
14433
|
packageName: "mysql",
|
|
@@ -14380,7 +14438,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14380
14438
|
return self._handleRecordTransaction(spanInfo, originalRollback, this, arguments, actualCallback);
|
|
14381
14439
|
});
|
|
14382
14440
|
},
|
|
14383
|
-
spanKind: import_src$
|
|
14441
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14384
14442
|
});
|
|
14385
14443
|
else return originalRollback.apply(this, arguments);
|
|
14386
14444
|
};
|
|
@@ -14407,7 +14465,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14407
14465
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14408
14466
|
return originalPing.apply(this, arguments);
|
|
14409
14467
|
},
|
|
14410
|
-
spanKind: import_src$
|
|
14468
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14411
14469
|
});
|
|
14412
14470
|
else return originalPing.apply(this, arguments);
|
|
14413
14471
|
};
|
|
@@ -14436,7 +14494,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14436
14494
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14437
14495
|
return originalEnd.apply(this, arguments);
|
|
14438
14496
|
},
|
|
14439
|
-
spanKind: import_src$
|
|
14497
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14440
14498
|
});
|
|
14441
14499
|
else return originalEnd.apply(this, arguments);
|
|
14442
14500
|
};
|
|
@@ -14465,7 +14523,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14465
14523
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14466
14524
|
return originalChangeUser.apply(this, arguments);
|
|
14467
14525
|
},
|
|
14468
|
-
spanKind: import_src$
|
|
14526
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14469
14527
|
});
|
|
14470
14528
|
else return originalChangeUser.apply(this, arguments);
|
|
14471
14529
|
};
|
|
@@ -14531,7 +14589,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14531
14589
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14532
14590
|
return originalEnd.apply(this, arguments);
|
|
14533
14591
|
},
|
|
14534
|
-
spanKind: import_src$
|
|
14592
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14535
14593
|
});
|
|
14536
14594
|
else return originalEnd.apply(this, arguments);
|
|
14537
14595
|
};
|
|
@@ -14554,7 +14612,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14554
14612
|
replayModeHandler: () => {
|
|
14555
14613
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
14556
14614
|
name: `mysql.pool.getConnection`,
|
|
14557
|
-
kind: import_src$
|
|
14615
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14558
14616
|
submodule: "getConnection",
|
|
14559
14617
|
packageName: "mysql",
|
|
14560
14618
|
packageType: PackageType.MYSQL,
|
|
@@ -14571,7 +14629,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14571
14629
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14572
14630
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
14573
14631
|
name: `mysql.pool.getConnection`,
|
|
14574
|
-
kind: import_src$
|
|
14632
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14575
14633
|
submodule: "getConnection",
|
|
14576
14634
|
packageName: "mysql",
|
|
14577
14635
|
packageType: PackageType.MYSQL,
|
|
@@ -14582,7 +14640,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14582
14640
|
return self._handleRecordPoolGetConnectionInSpan(spanInfo, originalGetConnection, callback, this);
|
|
14583
14641
|
});
|
|
14584
14642
|
},
|
|
14585
|
-
spanKind: import_src$
|
|
14643
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14586
14644
|
});
|
|
14587
14645
|
else return originalGetConnection.apply(this, [callback]);
|
|
14588
14646
|
};
|
|
@@ -14626,12 +14684,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14626
14684
|
replayModeHandler: () => {
|
|
14627
14685
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(connection, args), {
|
|
14628
14686
|
name: "mysql.query",
|
|
14629
|
-
kind: import_src$
|
|
14687
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14630
14688
|
submodule: "query",
|
|
14631
14689
|
packageType: PackageType.MYSQL,
|
|
14632
14690
|
packageName: "mysql",
|
|
14633
14691
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14634
14692
|
inputValue,
|
|
14693
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14635
14694
|
isPreAppStart: false
|
|
14636
14695
|
}, (spanInfo) => {
|
|
14637
14696
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -14652,18 +14711,19 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14652
14711
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14653
14712
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(connection, args), {
|
|
14654
14713
|
name: "mysql.query",
|
|
14655
|
-
kind: import_src$
|
|
14714
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14656
14715
|
submodule: "query",
|
|
14657
14716
|
packageType: PackageType.MYSQL,
|
|
14658
14717
|
packageName: "mysql",
|
|
14659
14718
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14660
14719
|
inputValue,
|
|
14720
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14661
14721
|
isPreAppStart
|
|
14662
14722
|
}, (spanInfo) => {
|
|
14663
14723
|
return self._handleRecordQuery(spanInfo, originalQuery, connection, args, callback, isEventEmitterMode);
|
|
14664
14724
|
});
|
|
14665
14725
|
},
|
|
14666
|
-
spanKind: import_src$
|
|
14726
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14667
14727
|
});
|
|
14668
14728
|
else return originalQuery.apply(connection, args);
|
|
14669
14729
|
};
|
|
@@ -14701,7 +14761,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14701
14761
|
};
|
|
14702
14762
|
if (error) try {
|
|
14703
14763
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14704
|
-
code: import_src$
|
|
14764
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14705
14765
|
message: error.message
|
|
14706
14766
|
});
|
|
14707
14767
|
} catch (error$1) {
|
|
@@ -14709,7 +14769,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14709
14769
|
}
|
|
14710
14770
|
else try {
|
|
14711
14771
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
14712
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
14772
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14713
14773
|
} catch (error$1) {
|
|
14714
14774
|
logger.error(`[MysqlInstrumentation] error ending span:`, error$1);
|
|
14715
14775
|
}
|
|
@@ -14723,7 +14783,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14723
14783
|
queryObject._callback = function(err, results, fields) {
|
|
14724
14784
|
if (err) try {
|
|
14725
14785
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14726
|
-
code: import_src$
|
|
14786
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14727
14787
|
message: err.message
|
|
14728
14788
|
});
|
|
14729
14789
|
} catch (error) {
|
|
@@ -14735,7 +14795,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14735
14795
|
fields
|
|
14736
14796
|
};
|
|
14737
14797
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
14738
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
14798
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14739
14799
|
} catch (error) {
|
|
14740
14800
|
logger.error(`[MysqlInstrumentation] error ending span:`, error);
|
|
14741
14801
|
}
|
|
@@ -14749,7 +14809,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14749
14809
|
args[callbackIndex] = function(err, results, fields) {
|
|
14750
14810
|
if (err) try {
|
|
14751
14811
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14752
|
-
code: import_src$
|
|
14812
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14753
14813
|
message: err.message
|
|
14754
14814
|
});
|
|
14755
14815
|
} catch (error) {
|
|
@@ -14761,7 +14821,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14761
14821
|
fields
|
|
14762
14822
|
};
|
|
14763
14823
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
14764
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
14824
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14765
14825
|
} catch (error) {
|
|
14766
14826
|
logger.error(`[MysqlInstrumentation] error ending span:`, error);
|
|
14767
14827
|
}
|
|
@@ -14789,7 +14849,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14789
14849
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14790
14850
|
return originalConnect.apply(connection, arguments);
|
|
14791
14851
|
},
|
|
14792
|
-
spanKind: import_src$
|
|
14852
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14793
14853
|
});
|
|
14794
14854
|
else return originalConnect.apply(connection, arguments);
|
|
14795
14855
|
};
|
|
@@ -14811,7 +14871,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14811
14871
|
replayModeHandler: () => {
|
|
14812
14872
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(connection, arguments), {
|
|
14813
14873
|
name: "mysql.beginTransaction",
|
|
14814
|
-
kind: import_src$
|
|
14874
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14815
14875
|
submodule: "transaction",
|
|
14816
14876
|
packageType: PackageType.MYSQL,
|
|
14817
14877
|
packageName: "mysql",
|
|
@@ -14828,7 +14888,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14828
14888
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14829
14889
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(connection, arguments), {
|
|
14830
14890
|
name: "mysql.beginTransaction",
|
|
14831
|
-
kind: import_src$
|
|
14891
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14832
14892
|
submodule: "transaction",
|
|
14833
14893
|
packageType: PackageType.MYSQL,
|
|
14834
14894
|
packageName: "mysql",
|
|
@@ -14839,7 +14899,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14839
14899
|
return self._handleRecordTransaction(spanInfo, originalBeginTransaction, connection, arguments, actualCallback);
|
|
14840
14900
|
});
|
|
14841
14901
|
},
|
|
14842
|
-
spanKind: import_src$
|
|
14902
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14843
14903
|
});
|
|
14844
14904
|
else return originalBeginTransaction.apply(connection, arguments);
|
|
14845
14905
|
};
|
|
@@ -14861,7 +14921,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14861
14921
|
replayModeHandler: () => {
|
|
14862
14922
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(connection, arguments), {
|
|
14863
14923
|
name: "mysql.commit",
|
|
14864
|
-
kind: import_src$
|
|
14924
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14865
14925
|
submodule: "transaction",
|
|
14866
14926
|
packageType: PackageType.MYSQL,
|
|
14867
14927
|
packageName: "mysql",
|
|
@@ -14878,7 +14938,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14878
14938
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14879
14939
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(connection, arguments), {
|
|
14880
14940
|
name: "mysql.commit",
|
|
14881
|
-
kind: import_src$
|
|
14941
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14882
14942
|
submodule: "transaction",
|
|
14883
14943
|
packageType: PackageType.MYSQL,
|
|
14884
14944
|
packageName: "mysql",
|
|
@@ -14889,7 +14949,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14889
14949
|
return self._handleRecordTransaction(spanInfo, originalCommit, connection, arguments, actualCallback);
|
|
14890
14950
|
});
|
|
14891
14951
|
},
|
|
14892
|
-
spanKind: import_src$
|
|
14952
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14893
14953
|
});
|
|
14894
14954
|
else return originalCommit.apply(connection, arguments);
|
|
14895
14955
|
};
|
|
@@ -14911,7 +14971,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14911
14971
|
replayModeHandler: () => {
|
|
14912
14972
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(connection, arguments), {
|
|
14913
14973
|
name: "mysql.rollback",
|
|
14914
|
-
kind: import_src$
|
|
14974
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14915
14975
|
submodule: "transaction",
|
|
14916
14976
|
packageType: PackageType.MYSQL,
|
|
14917
14977
|
packageName: "mysql",
|
|
@@ -14928,7 +14988,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14928
14988
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14929
14989
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(connection, arguments), {
|
|
14930
14990
|
name: "mysql.rollback",
|
|
14931
|
-
kind: import_src$
|
|
14991
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14932
14992
|
submodule: "transaction",
|
|
14933
14993
|
packageType: PackageType.MYSQL,
|
|
14934
14994
|
packageName: "mysql",
|
|
@@ -14939,7 +14999,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14939
14999
|
return self._handleRecordTransaction(spanInfo, originalRollback, connection, arguments, actualCallback);
|
|
14940
15000
|
});
|
|
14941
15001
|
},
|
|
14942
|
-
spanKind: import_src$
|
|
15002
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14943
15003
|
});
|
|
14944
15004
|
else return originalRollback.apply(connection, arguments);
|
|
14945
15005
|
};
|
|
@@ -14950,7 +15010,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14950
15010
|
const result = originalFunction.apply(connection, args);
|
|
14951
15011
|
try {
|
|
14952
15012
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { status: "success" } });
|
|
14953
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15013
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14954
15014
|
} catch (error) {
|
|
14955
15015
|
logger.error(`[MysqlInstrumentation] error adding span attributes:`, error);
|
|
14956
15016
|
}
|
|
@@ -14958,7 +15018,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14958
15018
|
} catch (error) {
|
|
14959
15019
|
try {
|
|
14960
15020
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14961
|
-
code: import_src$
|
|
15021
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14962
15022
|
message: error.message
|
|
14963
15023
|
});
|
|
14964
15024
|
} catch (error$1) {
|
|
@@ -14973,7 +15033,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14973
15033
|
argsArray[callbackIndex] = function(err) {
|
|
14974
15034
|
if (err) try {
|
|
14975
15035
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14976
|
-
code: import_src$
|
|
15036
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14977
15037
|
message: err.message
|
|
14978
15038
|
});
|
|
14979
15039
|
} catch (error) {
|
|
@@ -14981,14 +15041,14 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14981
15041
|
}
|
|
14982
15042
|
else try {
|
|
14983
15043
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { status: "success" } });
|
|
14984
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15044
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14985
15045
|
} catch (error) {
|
|
14986
15046
|
logger.error(`[MysqlInstrumentation] error ending span:`, error);
|
|
14987
15047
|
}
|
|
14988
15048
|
logger.debug(`[MysqlInstrumentation] Transaction completed`);
|
|
14989
15049
|
return originalCallback.apply(this, arguments);
|
|
14990
15050
|
};
|
|
14991
|
-
argsArray[callbackIndex] = import_src$
|
|
15051
|
+
argsArray[callbackIndex] = import_src$25.context.bind(spanInfo.context, argsArray[callbackIndex]);
|
|
14992
15052
|
}
|
|
14993
15053
|
return originalFunction.apply(connection, argsArray);
|
|
14994
15054
|
}
|
|
@@ -15005,7 +15065,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15005
15065
|
if (error) {
|
|
15006
15066
|
logger.debug(`[MysqlInstrumentation] MySQL Pool getConnection error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
15007
15067
|
SpanUtils.endSpan(spanInfo.span, {
|
|
15008
|
-
code: import_src$
|
|
15068
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
15009
15069
|
message: error.message
|
|
15010
15070
|
});
|
|
15011
15071
|
} else {
|
|
@@ -15021,9 +15081,9 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15021
15081
|
connected: true,
|
|
15022
15082
|
hasConnection: !!connection
|
|
15023
15083
|
} });
|
|
15024
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15084
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
15025
15085
|
}
|
|
15026
|
-
return import_src$
|
|
15086
|
+
return import_src$25.context.bind(spanInfo.context, callback)(error, connection);
|
|
15027
15087
|
};
|
|
15028
15088
|
return originalGetConnection.call(poolContext, wrappedCallback);
|
|
15029
15089
|
} else try {
|
|
@@ -15032,11 +15092,11 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15032
15092
|
connected: true,
|
|
15033
15093
|
hasConnection: true
|
|
15034
15094
|
} });
|
|
15035
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15095
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
15036
15096
|
return result;
|
|
15037
15097
|
} catch (error) {
|
|
15038
15098
|
SpanUtils.endSpan(spanInfo.span, {
|
|
15039
|
-
code: import_src$
|
|
15099
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
15040
15100
|
message: error.message
|
|
15041
15101
|
});
|
|
15042
15102
|
throw error;
|
|
@@ -15113,12 +15173,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15113
15173
|
replayModeHandler: () => {
|
|
15114
15174
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalStream.apply(queryInstance, arguments), {
|
|
15115
15175
|
name: "mysql.stream",
|
|
15116
|
-
kind: import_src$
|
|
15176
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15117
15177
|
submodule: "stream",
|
|
15118
15178
|
packageType: PackageType.MYSQL,
|
|
15119
15179
|
packageName: "mysql",
|
|
15120
15180
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15121
15181
|
inputValue,
|
|
15182
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15122
15183
|
isPreAppStart: false
|
|
15123
15184
|
}, (spanInfo) => {
|
|
15124
15185
|
return self._handleReplayStream(inputValue, spanInfo, stackTrace, queryInstance);
|
|
@@ -15130,18 +15191,19 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15130
15191
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
15131
15192
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalStream.apply(queryInstance, arguments), {
|
|
15132
15193
|
name: "mysql.stream",
|
|
15133
|
-
kind: import_src$
|
|
15194
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15134
15195
|
submodule: "stream",
|
|
15135
15196
|
packageType: PackageType.MYSQL,
|
|
15136
15197
|
packageName: "mysql",
|
|
15137
15198
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15138
15199
|
inputValue,
|
|
15200
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15139
15201
|
isPreAppStart
|
|
15140
15202
|
}, (spanInfo) => {
|
|
15141
15203
|
return self._handleRecordStream(spanInfo, originalStream, queryInstance, streamOptions);
|
|
15142
15204
|
});
|
|
15143
15205
|
},
|
|
15144
|
-
spanKind: import_src$
|
|
15206
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
15145
15207
|
});
|
|
15146
15208
|
else return originalStream.apply(queryInstance, arguments);
|
|
15147
15209
|
};
|
|
@@ -15214,7 +15276,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15214
15276
|
const isMultiStatementQuery = queryCount > 1;
|
|
15215
15277
|
if (error) try {
|
|
15216
15278
|
SpanUtils.endSpan(spanInfo.span, {
|
|
15217
|
-
code: import_src$
|
|
15279
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
15218
15280
|
message: error.message
|
|
15219
15281
|
});
|
|
15220
15282
|
} catch (err) {
|
|
@@ -15232,7 +15294,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15232
15294
|
queryCount
|
|
15233
15295
|
};
|
|
15234
15296
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
15235
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15297
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
15236
15298
|
} catch (err) {
|
|
15237
15299
|
logger.error(`[MysqlInstrumentation] error ending span:`, err);
|
|
15238
15300
|
}
|
|
@@ -15341,12 +15403,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15341
15403
|
replayModeHandler: () => {
|
|
15342
15404
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
15343
15405
|
name: "mysql.query",
|
|
15344
|
-
kind: import_src$
|
|
15406
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15345
15407
|
submodule: "query",
|
|
15346
15408
|
packageType: PackageType.MYSQL,
|
|
15347
15409
|
packageName: "mysql",
|
|
15348
15410
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15349
15411
|
inputValue,
|
|
15412
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15350
15413
|
isPreAppStart: false
|
|
15351
15414
|
}, (spanInfo) => {
|
|
15352
15415
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -15390,7 +15453,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15390
15453
|
replayModeHandler: () => {
|
|
15391
15454
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(namespace, [callback]), {
|
|
15392
15455
|
name: `mysql.poolNamespace.getConnection`,
|
|
15393
|
-
kind: import_src$
|
|
15456
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15394
15457
|
submodule: "getConnection",
|
|
15395
15458
|
packageName: "mysql",
|
|
15396
15459
|
packageType: PackageType.MYSQL,
|
|
@@ -15542,6 +15605,27 @@ var TdMysql2ConnectionMock = class extends events.EventEmitter {
|
|
|
15542
15605
|
}
|
|
15543
15606
|
return Promise.resolve();
|
|
15544
15607
|
}
|
|
15608
|
+
prepare(sql, callback) {
|
|
15609
|
+
const sqlStr = typeof sql === "string" ? sql : sql.sql;
|
|
15610
|
+
const self = this;
|
|
15611
|
+
const mockStatement = {
|
|
15612
|
+
query: sqlStr,
|
|
15613
|
+
id: 1,
|
|
15614
|
+
columns: [],
|
|
15615
|
+
parameters: [],
|
|
15616
|
+
execute: (...args) => {
|
|
15617
|
+
const values = Array.isArray(args[0]) ? args[0] : [];
|
|
15618
|
+
const execCallback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
15619
|
+
return self.mysql2Instrumentation.handleNoOpReplayQuery({
|
|
15620
|
+
sql: sqlStr,
|
|
15621
|
+
values,
|
|
15622
|
+
callback: execCallback
|
|
15623
|
+
});
|
|
15624
|
+
},
|
|
15625
|
+
close: () => {}
|
|
15626
|
+
};
|
|
15627
|
+
if (callback) process.nextTick(() => callback(null, mockStatement));
|
|
15628
|
+
}
|
|
15545
15629
|
pause() {}
|
|
15546
15630
|
resume() {}
|
|
15547
15631
|
escape(value) {
|
|
@@ -15567,7 +15651,7 @@ var TdMysql2ConnectionMock = class extends events.EventEmitter {
|
|
|
15567
15651
|
|
|
15568
15652
|
//#endregion
|
|
15569
15653
|
//#region src/instrumentation/libraries/mysql2/mocks/TdMysql2QueryMock.ts
|
|
15570
|
-
var import_src$
|
|
15654
|
+
var import_src$24 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
15571
15655
|
/**
|
|
15572
15656
|
* Handles replay mode for MySQL2 query operations
|
|
15573
15657
|
*/
|
|
@@ -15598,6 +15682,10 @@ var TdMysql2QueryMock = class {
|
|
|
15598
15682
|
});
|
|
15599
15683
|
}).then(onResolve, onReject);
|
|
15600
15684
|
};
|
|
15685
|
+
const self = this;
|
|
15686
|
+
emitter.stream = function(streamOptions) {
|
|
15687
|
+
return self._createReplayStreamForQuery(emitter, streamOptions);
|
|
15688
|
+
};
|
|
15601
15689
|
process.nextTick(() => {
|
|
15602
15690
|
const callback = queryConfig.callback;
|
|
15603
15691
|
if (callback) callback(null, [], []);
|
|
@@ -15624,6 +15712,10 @@ var TdMysql2QueryMock = class {
|
|
|
15624
15712
|
});
|
|
15625
15713
|
}).then(onResolve, onReject);
|
|
15626
15714
|
};
|
|
15715
|
+
const self = this;
|
|
15716
|
+
emitter.stream = function(streamOptions) {
|
|
15717
|
+
return self._createReplayStreamForQuery(emitter, streamOptions);
|
|
15718
|
+
};
|
|
15627
15719
|
(async () => {
|
|
15628
15720
|
try {
|
|
15629
15721
|
const mockData = await this._fetchMockData(inputValue, spanInfo, spanName, submoduleName, stackTrace);
|
|
@@ -15664,13 +15756,51 @@ var TdMysql2QueryMock = class {
|
|
|
15664
15756
|
packageName: "mysql2",
|
|
15665
15757
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
15666
15758
|
submoduleName,
|
|
15667
|
-
kind: import_src$
|
|
15759
|
+
kind: import_src$24.SpanKind.CLIENT,
|
|
15668
15760
|
stackTrace
|
|
15669
15761
|
},
|
|
15670
|
-
tuskDrift: this.tuskDrift
|
|
15762
|
+
tuskDrift: this.tuskDrift,
|
|
15763
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
15671
15764
|
});
|
|
15672
15765
|
}
|
|
15673
15766
|
/**
|
|
15767
|
+
* Create a replay stream for query.stream() calls
|
|
15768
|
+
* This is called when user calls query.stream() on a query object
|
|
15769
|
+
*/
|
|
15770
|
+
_createReplayStreamForQuery(queryEmitter, streamOptions) {
|
|
15771
|
+
logger.debug(`[Mysql2Instrumentation] Creating replay stream for query.stream()`);
|
|
15772
|
+
const readableStream = new stream.Readable({
|
|
15773
|
+
objectMode: true,
|
|
15774
|
+
read() {}
|
|
15775
|
+
});
|
|
15776
|
+
queryEmitter.on("result", (row) => {
|
|
15777
|
+
readableStream.push(row);
|
|
15778
|
+
});
|
|
15779
|
+
queryEmitter.on("error", (err) => {
|
|
15780
|
+
readableStream.destroy(err);
|
|
15781
|
+
});
|
|
15782
|
+
queryEmitter.on("end", () => {
|
|
15783
|
+
readableStream.push(null);
|
|
15784
|
+
});
|
|
15785
|
+
return readableStream;
|
|
15786
|
+
}
|
|
15787
|
+
/**
|
|
15788
|
+
* Recursively restore Buffer objects from their JSON serialized form.
|
|
15789
|
+
* JSON.stringify converts Buffer to {"type":"Buffer","data":[...]}
|
|
15790
|
+
* This function converts them back to actual Buffer instances.
|
|
15791
|
+
*/
|
|
15792
|
+
_restoreBuffers(obj) {
|
|
15793
|
+
if (obj === null || obj === void 0) return obj;
|
|
15794
|
+
if (typeof obj === "object" && obj.type === "Buffer" && Array.isArray(obj.data)) return Buffer.from(obj.data);
|
|
15795
|
+
if (Array.isArray(obj)) return obj.map((item) => this._restoreBuffers(item));
|
|
15796
|
+
if (typeof obj === "object") {
|
|
15797
|
+
const result = {};
|
|
15798
|
+
for (const key of Object.keys(obj)) result[key] = this._restoreBuffers(obj[key]);
|
|
15799
|
+
return result;
|
|
15800
|
+
}
|
|
15801
|
+
return obj;
|
|
15802
|
+
}
|
|
15803
|
+
/**
|
|
15674
15804
|
* Convert stored MySQL2 values back to appropriate JavaScript types
|
|
15675
15805
|
*/
|
|
15676
15806
|
_convertMysql2Types(result) {
|
|
@@ -15678,12 +15808,17 @@ var TdMysql2QueryMock = class {
|
|
|
15678
15808
|
rows: [],
|
|
15679
15809
|
fields: []
|
|
15680
15810
|
};
|
|
15681
|
-
|
|
15682
|
-
|
|
15683
|
-
|
|
15811
|
+
const restoredResult = this._restoreBuffers(result);
|
|
15812
|
+
if (restoredResult.rows !== void 0 && restoredResult.fields !== void 0) return {
|
|
15813
|
+
rows: restoredResult.rows,
|
|
15814
|
+
fields: restoredResult.fields
|
|
15815
|
+
};
|
|
15816
|
+
if (restoredResult.affectedRows !== void 0) return {
|
|
15817
|
+
rows: restoredResult,
|
|
15818
|
+
fields: []
|
|
15684
15819
|
};
|
|
15685
15820
|
return {
|
|
15686
|
-
rows:
|
|
15821
|
+
rows: restoredResult,
|
|
15687
15822
|
fields: []
|
|
15688
15823
|
};
|
|
15689
15824
|
}
|
|
@@ -15691,7 +15826,7 @@ var TdMysql2QueryMock = class {
|
|
|
15691
15826
|
|
|
15692
15827
|
//#endregion
|
|
15693
15828
|
//#region src/instrumentation/libraries/mysql2/mocks/TdMysql2ConnectionEventMock.ts
|
|
15694
|
-
var import_src$
|
|
15829
|
+
var import_src$23 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
15695
15830
|
/**
|
|
15696
15831
|
* Mock for MySQL2 connection events (connect/error)
|
|
15697
15832
|
* Handles replay of recorded connection establishment events in REPLAY mode
|
|
@@ -15720,7 +15855,7 @@ var TdMysql2ConnectionEventMock = class {
|
|
|
15720
15855
|
packageName: "mysql2",
|
|
15721
15856
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
15722
15857
|
submoduleName: "connectEvent",
|
|
15723
|
-
kind: import_src$
|
|
15858
|
+
kind: import_src$23.SpanKind.CLIENT
|
|
15724
15859
|
},
|
|
15725
15860
|
tuskDrift: this.tuskDrift
|
|
15726
15861
|
});
|
|
@@ -15738,7 +15873,7 @@ var TdMysql2ConnectionEventMock = class {
|
|
|
15738
15873
|
|
|
15739
15874
|
//#endregion
|
|
15740
15875
|
//#region src/instrumentation/libraries/mysql2/Instrumentation.ts
|
|
15741
|
-
var import_src$
|
|
15876
|
+
var import_src$22 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
15742
15877
|
const COMPLETE_SUPPORTED_VERSIONS = ">=2.3.3 <4.0.0";
|
|
15743
15878
|
const V2_3_3_TO_3_11_4 = ">=2.3.3 <3.11.5";
|
|
15744
15879
|
const V3_11_5_TO_4_0 = ">=3.11.5 <4.0.0";
|
|
@@ -15828,6 +15963,18 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15828
15963
|
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.end`);
|
|
15829
15964
|
}
|
|
15830
15965
|
}
|
|
15966
|
+
if (BaseConnectionClass.prototype && BaseConnectionClass.prototype.prepare) {
|
|
15967
|
+
if (!isWrapped$1(BaseConnectionClass.prototype.prepare)) {
|
|
15968
|
+
this._wrap(BaseConnectionClass.prototype, "prepare", this._getPreparePatchFn("connection"));
|
|
15969
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.prepare`);
|
|
15970
|
+
}
|
|
15971
|
+
}
|
|
15972
|
+
if (BaseConnectionClass.prototype && BaseConnectionClass.prototype.changeUser) {
|
|
15973
|
+
if (!isWrapped$1(BaseConnectionClass.prototype.changeUser)) {
|
|
15974
|
+
this._wrap(BaseConnectionClass.prototype, "changeUser", this._getChangeUserPatchFn("connection"));
|
|
15975
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.changeUser`);
|
|
15976
|
+
}
|
|
15977
|
+
}
|
|
15831
15978
|
this.markModuleAsPatched(BaseConnectionClass);
|
|
15832
15979
|
logger.debug(`[Mysql2Instrumentation] BaseConnection class patching complete`);
|
|
15833
15980
|
return BaseConnectionClass;
|
|
@@ -15879,6 +16026,18 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15879
16026
|
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.end`);
|
|
15880
16027
|
}
|
|
15881
16028
|
}
|
|
16029
|
+
if (ConnectionClass.prototype && ConnectionClass.prototype.prepare) {
|
|
16030
|
+
if (!isWrapped$1(ConnectionClass.prototype.prepare)) {
|
|
16031
|
+
this._wrap(ConnectionClass.prototype, "prepare", this._getPreparePatchFn("connection"));
|
|
16032
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.prepare`);
|
|
16033
|
+
}
|
|
16034
|
+
}
|
|
16035
|
+
if (ConnectionClass.prototype && ConnectionClass.prototype.changeUser) {
|
|
16036
|
+
if (!isWrapped$1(ConnectionClass.prototype.changeUser)) {
|
|
16037
|
+
this._wrap(ConnectionClass.prototype, "changeUser", this._getChangeUserPatchFn("connection"));
|
|
16038
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.changeUser`);
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
15882
16041
|
}
|
|
15883
16042
|
_patchPoolV2(PoolClass) {
|
|
15884
16043
|
logger.debug(`[Mysql2Instrumentation] Patching Pool class (v2)`);
|
|
@@ -15966,12 +16125,13 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15966
16125
|
const spanName = `mysql2.${clientType}.query`;
|
|
15967
16126
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
15968
16127
|
name: spanName,
|
|
15969
|
-
kind: import_src$
|
|
16128
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
15970
16129
|
submodule: "query",
|
|
15971
16130
|
packageType: PackageType.MYSQL,
|
|
15972
16131
|
packageName: "mysql2",
|
|
15973
16132
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15974
16133
|
inputValue,
|
|
16134
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15975
16135
|
isPreAppStart: false
|
|
15976
16136
|
}, (spanInfo) => {
|
|
15977
16137
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "query", stackTrace);
|
|
@@ -15984,18 +16144,19 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15984
16144
|
const spanName = `mysql2.${clientType}.query`;
|
|
15985
16145
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
15986
16146
|
name: spanName,
|
|
15987
|
-
kind: import_src$
|
|
16147
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
15988
16148
|
submodule: "query",
|
|
15989
16149
|
packageType: PackageType.MYSQL,
|
|
15990
16150
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15991
16151
|
packageName: "mysql2",
|
|
15992
16152
|
inputValue,
|
|
16153
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15993
16154
|
isPreAppStart
|
|
15994
16155
|
}, (spanInfo) => {
|
|
15995
16156
|
return self._handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, this);
|
|
15996
16157
|
});
|
|
15997
16158
|
},
|
|
15998
|
-
spanKind: import_src$
|
|
16159
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
15999
16160
|
});
|
|
16000
16161
|
else return originalQuery.apply(this, args);
|
|
16001
16162
|
};
|
|
@@ -16031,12 +16192,13 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16031
16192
|
const spanName = `mysql2.${clientType}.execute`;
|
|
16032
16193
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute.apply(this, args), {
|
|
16033
16194
|
name: spanName,
|
|
16034
|
-
kind: import_src$
|
|
16195
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16035
16196
|
submodule: "execute",
|
|
16036
16197
|
packageType: PackageType.MYSQL,
|
|
16037
16198
|
packageName: "mysql2",
|
|
16038
16199
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16039
16200
|
inputValue,
|
|
16201
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16040
16202
|
isPreAppStart: false
|
|
16041
16203
|
}, (spanInfo) => {
|
|
16042
16204
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "execute", stackTrace);
|
|
@@ -16049,18 +16211,19 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16049
16211
|
const spanName = `mysql2.${clientType}.execute`;
|
|
16050
16212
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute.apply(this, args), {
|
|
16051
16213
|
name: spanName,
|
|
16052
|
-
kind: import_src$
|
|
16214
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16053
16215
|
submodule: "execute",
|
|
16054
16216
|
packageType: PackageType.MYSQL,
|
|
16055
16217
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16056
16218
|
packageName: "mysql2",
|
|
16057
16219
|
inputValue,
|
|
16220
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16058
16221
|
isPreAppStart
|
|
16059
16222
|
}, (spanInfo) => {
|
|
16060
16223
|
return self._handleRecordQueryInSpan(spanInfo, originalExecute, queryConfig, args, this);
|
|
16061
16224
|
});
|
|
16062
16225
|
},
|
|
16063
|
-
spanKind: import_src$
|
|
16226
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16064
16227
|
});
|
|
16065
16228
|
else return originalExecute.apply(this, args);
|
|
16066
16229
|
};
|
|
@@ -16079,7 +16242,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16079
16242
|
replayModeHandler: () => {
|
|
16080
16243
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
16081
16244
|
name: `mysql2.pool.getConnection`,
|
|
16082
|
-
kind: import_src$
|
|
16245
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16083
16246
|
submodule: "getConnection",
|
|
16084
16247
|
packageName: "mysql2",
|
|
16085
16248
|
packageType: PackageType.MYSQL,
|
|
@@ -16096,7 +16259,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16096
16259
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16097
16260
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
16098
16261
|
name: `mysql2.pool.getConnection`,
|
|
16099
|
-
kind: import_src$
|
|
16262
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16100
16263
|
submodule: "getConnection",
|
|
16101
16264
|
packageName: "mysql2",
|
|
16102
16265
|
packageType: PackageType.MYSQL,
|
|
@@ -16107,7 +16270,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16107
16270
|
return self._handleRecordPoolGetConnectionInSpan(spanInfo, originalGetConnection, callback, this);
|
|
16108
16271
|
});
|
|
16109
16272
|
},
|
|
16110
|
-
spanKind: import_src$
|
|
16273
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16111
16274
|
});
|
|
16112
16275
|
else return originalGetConnection.apply(this, [callback]);
|
|
16113
16276
|
};
|
|
@@ -16130,7 +16293,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16130
16293
|
replayModeHandler: () => {
|
|
16131
16294
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
16132
16295
|
name: `mysql2.${clientType}.connect`,
|
|
16133
|
-
kind: import_src$
|
|
16296
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16134
16297
|
submodule: "connect",
|
|
16135
16298
|
packageName: "mysql2",
|
|
16136
16299
|
packageType: PackageType.MYSQL,
|
|
@@ -16151,7 +16314,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16151
16314
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16152
16315
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
16153
16316
|
name: `mysql2.${clientType}.connect`,
|
|
16154
|
-
kind: import_src$
|
|
16317
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16155
16318
|
submodule: "connect",
|
|
16156
16319
|
packageName: "mysql2",
|
|
16157
16320
|
packageType: PackageType.MYSQL,
|
|
@@ -16162,7 +16325,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16162
16325
|
return self._handleSimpleCallbackMethod(spanInfo, originalConnect, callback, this);
|
|
16163
16326
|
});
|
|
16164
16327
|
},
|
|
16165
|
-
spanKind: import_src$
|
|
16328
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16166
16329
|
});
|
|
16167
16330
|
else return originalConnect.apply(this, [callback]);
|
|
16168
16331
|
};
|
|
@@ -16185,7 +16348,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16185
16348
|
replayModeHandler: () => {
|
|
16186
16349
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalPing.apply(this, [callback]), {
|
|
16187
16350
|
name: `mysql2.${clientType}.ping`,
|
|
16188
|
-
kind: import_src$
|
|
16351
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16189
16352
|
submodule: "ping",
|
|
16190
16353
|
packageName: "mysql2",
|
|
16191
16354
|
packageType: PackageType.MYSQL,
|
|
@@ -16206,7 +16369,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16206
16369
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16207
16370
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalPing.apply(this, [callback]), {
|
|
16208
16371
|
name: `mysql2.${clientType}.ping`,
|
|
16209
|
-
kind: import_src$
|
|
16372
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16210
16373
|
submodule: "ping",
|
|
16211
16374
|
packageName: "mysql2",
|
|
16212
16375
|
packageType: PackageType.MYSQL,
|
|
@@ -16217,7 +16380,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16217
16380
|
return self._handleSimpleCallbackMethod(spanInfo, originalPing, callback, this);
|
|
16218
16381
|
});
|
|
16219
16382
|
},
|
|
16220
|
-
spanKind: import_src$
|
|
16383
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16221
16384
|
});
|
|
16222
16385
|
else return originalPing.apply(this, [callback]);
|
|
16223
16386
|
};
|
|
@@ -16240,7 +16403,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16240
16403
|
replayModeHandler: () => {
|
|
16241
16404
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalEnd.apply(this, [callback]), {
|
|
16242
16405
|
name: `mysql2.${clientType}.end`,
|
|
16243
|
-
kind: import_src$
|
|
16406
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16244
16407
|
submodule: "end",
|
|
16245
16408
|
packageName: "mysql2",
|
|
16246
16409
|
packageType: PackageType.MYSQL,
|
|
@@ -16261,7 +16424,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16261
16424
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16262
16425
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalEnd.apply(this, [callback]), {
|
|
16263
16426
|
name: `mysql2.${clientType}.end`,
|
|
16264
|
-
kind: import_src$
|
|
16427
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16265
16428
|
submodule: "end",
|
|
16266
16429
|
packageName: "mysql2",
|
|
16267
16430
|
packageType: PackageType.MYSQL,
|
|
@@ -16272,12 +16435,257 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16272
16435
|
return self._handleSimpleCallbackMethod(spanInfo, originalEnd, callback, this);
|
|
16273
16436
|
});
|
|
16274
16437
|
},
|
|
16275
|
-
spanKind: import_src$
|
|
16438
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16276
16439
|
});
|
|
16277
16440
|
else return originalEnd.apply(this, [callback]);
|
|
16278
16441
|
};
|
|
16279
16442
|
};
|
|
16280
16443
|
}
|
|
16444
|
+
_getChangeUserPatchFn(clientType) {
|
|
16445
|
+
const self = this;
|
|
16446
|
+
return (originalChangeUser) => {
|
|
16447
|
+
return function changeUser(options, callback) {
|
|
16448
|
+
if (typeof options === "function") {
|
|
16449
|
+
callback = options;
|
|
16450
|
+
options = {};
|
|
16451
|
+
}
|
|
16452
|
+
const inputValue = { clientType };
|
|
16453
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16454
|
+
noOpRequestHandler: () => {
|
|
16455
|
+
if (callback) {
|
|
16456
|
+
process.nextTick(() => callback(null));
|
|
16457
|
+
return;
|
|
16458
|
+
}
|
|
16459
|
+
return Promise.resolve();
|
|
16460
|
+
},
|
|
16461
|
+
isServerRequest: false,
|
|
16462
|
+
replayModeHandler: () => {
|
|
16463
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalChangeUser.apply(this, [options, callback]), {
|
|
16464
|
+
name: `mysql2.${clientType}.changeUser`,
|
|
16465
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16466
|
+
submodule: "changeUser",
|
|
16467
|
+
packageName: "mysql2",
|
|
16468
|
+
packageType: PackageType.MYSQL,
|
|
16469
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16470
|
+
inputValue,
|
|
16471
|
+
isPreAppStart: false
|
|
16472
|
+
}, (spanInfo) => {
|
|
16473
|
+
if (callback) {
|
|
16474
|
+
process.nextTick(() => callback(null));
|
|
16475
|
+
return;
|
|
16476
|
+
}
|
|
16477
|
+
return Promise.resolve();
|
|
16478
|
+
});
|
|
16479
|
+
}
|
|
16480
|
+
});
|
|
16481
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16482
|
+
originalFunctionCall: () => originalChangeUser.apply(this, [options, callback]),
|
|
16483
|
+
recordModeHandler: ({ isPreAppStart }) => {
|
|
16484
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalChangeUser.apply(this, [options, callback]), {
|
|
16485
|
+
name: `mysql2.${clientType}.changeUser`,
|
|
16486
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16487
|
+
submodule: "changeUser",
|
|
16488
|
+
packageName: "mysql2",
|
|
16489
|
+
packageType: PackageType.MYSQL,
|
|
16490
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16491
|
+
inputValue,
|
|
16492
|
+
isPreAppStart
|
|
16493
|
+
}, (spanInfo) => {
|
|
16494
|
+
return self._handleSimpleCallbackMethod(spanInfo, originalChangeUser.bind(this, options), callback, this);
|
|
16495
|
+
});
|
|
16496
|
+
},
|
|
16497
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16498
|
+
});
|
|
16499
|
+
else return originalChangeUser.apply(this, [options, callback]);
|
|
16500
|
+
};
|
|
16501
|
+
};
|
|
16502
|
+
}
|
|
16503
|
+
_getPreparePatchFn(clientType) {
|
|
16504
|
+
const self = this;
|
|
16505
|
+
return (originalPrepare) => {
|
|
16506
|
+
return function prepare(...args) {
|
|
16507
|
+
const firstArg = args[0];
|
|
16508
|
+
const sql = typeof firstArg === "string" ? firstArg : firstArg?.sql;
|
|
16509
|
+
const originalCallback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
16510
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16511
|
+
noOpRequestHandler: () => self._handleNoOpReplayPrepare(sql, originalCallback),
|
|
16512
|
+
isServerRequest: false,
|
|
16513
|
+
replayModeHandler: () => self._handleReplayPrepare(sql, originalCallback, clientType)
|
|
16514
|
+
});
|
|
16515
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16516
|
+
originalFunctionCall: () => originalPrepare.apply(this, args),
|
|
16517
|
+
recordModeHandler: ({ isPreAppStart }) => self._handleRecordPrepare(originalPrepare, args, sql, originalCallback, this, clientType, isPreAppStart),
|
|
16518
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16519
|
+
});
|
|
16520
|
+
return originalPrepare.apply(this, args);
|
|
16521
|
+
};
|
|
16522
|
+
};
|
|
16523
|
+
}
|
|
16524
|
+
_handleRecordPrepare(originalPrepare, args, sql, originalCallback, context$6, clientType, isPreAppStart) {
|
|
16525
|
+
const self = this;
|
|
16526
|
+
return SpanUtils.createAndExecuteSpan(this.mode, () => originalPrepare.apply(context$6, args), {
|
|
16527
|
+
name: `mysql2.${clientType}.prepare`,
|
|
16528
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16529
|
+
submodule: "prepare",
|
|
16530
|
+
packageType: PackageType.MYSQL,
|
|
16531
|
+
packageName: "mysql2",
|
|
16532
|
+
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
16533
|
+
inputValue: {
|
|
16534
|
+
sql,
|
|
16535
|
+
clientType
|
|
16536
|
+
},
|
|
16537
|
+
isPreAppStart
|
|
16538
|
+
}, (spanInfo) => {
|
|
16539
|
+
const wrappedCallback = (err, statement) => {
|
|
16540
|
+
if (err) {
|
|
16541
|
+
logger.debug(`[Mysql2Instrumentation] MySQL2 prepare error: ${err.message} (${SpanUtils.getTraceInfo()})`);
|
|
16542
|
+
try {
|
|
16543
|
+
SpanUtils.endSpan(spanInfo.span, {
|
|
16544
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16545
|
+
message: err.message
|
|
16546
|
+
});
|
|
16547
|
+
} catch (error) {
|
|
16548
|
+
logger.error(`[Mysql2Instrumentation] error ending span:`, error);
|
|
16549
|
+
}
|
|
16550
|
+
} else {
|
|
16551
|
+
logger.debug(`[Mysql2Instrumentation] MySQL2 prepare completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16552
|
+
try {
|
|
16553
|
+
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: {
|
|
16554
|
+
prepared: true,
|
|
16555
|
+
statementId: statement?.id
|
|
16556
|
+
} });
|
|
16557
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16558
|
+
} catch (error) {
|
|
16559
|
+
logger.error(`[Mysql2Instrumentation] error processing prepare response:`, error);
|
|
16560
|
+
}
|
|
16561
|
+
if (statement && statement.execute) {
|
|
16562
|
+
const originalExecute = statement.execute.bind(statement);
|
|
16563
|
+
statement.execute = self._getPreparedStatementExecuteWrapper(originalExecute, sql, clientType);
|
|
16564
|
+
}
|
|
16565
|
+
}
|
|
16566
|
+
if (originalCallback) originalCallback(err, statement);
|
|
16567
|
+
};
|
|
16568
|
+
const newArgs = [...args];
|
|
16569
|
+
const callbackIndex = newArgs.findIndex((a) => typeof a === "function");
|
|
16570
|
+
if (callbackIndex >= 0) newArgs[callbackIndex] = wrappedCallback;
|
|
16571
|
+
else newArgs.push(wrappedCallback);
|
|
16572
|
+
return originalPrepare.apply(context$6, newArgs);
|
|
16573
|
+
});
|
|
16574
|
+
}
|
|
16575
|
+
_getPreparedStatementExecuteWrapper(originalExecute, sql, clientType) {
|
|
16576
|
+
const self = this;
|
|
16577
|
+
return function execute(...args) {
|
|
16578
|
+
let values = [];
|
|
16579
|
+
let callback;
|
|
16580
|
+
for (const arg of args) if (typeof arg === "function") callback = arg;
|
|
16581
|
+
else if (Array.isArray(arg)) values = arg;
|
|
16582
|
+
else if (arg !== void 0) values = [arg];
|
|
16583
|
+
const inputValue = {
|
|
16584
|
+
sql,
|
|
16585
|
+
values,
|
|
16586
|
+
clientType
|
|
16587
|
+
};
|
|
16588
|
+
const queryConfig = {
|
|
16589
|
+
sql,
|
|
16590
|
+
values,
|
|
16591
|
+
callback
|
|
16592
|
+
};
|
|
16593
|
+
const stackTrace = captureStackTrace(["Mysql2Instrumentation"]);
|
|
16594
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16595
|
+
noOpRequestHandler: () => self.queryMock.handleNoOpReplayQuery(queryConfig),
|
|
16596
|
+
isServerRequest: false,
|
|
16597
|
+
replayModeHandler: () => {
|
|
16598
|
+
const spanName = `mysql2.${clientType}.preparedExecute`;
|
|
16599
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute(...args), {
|
|
16600
|
+
name: spanName,
|
|
16601
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16602
|
+
submodule: "preparedExecute",
|
|
16603
|
+
packageType: PackageType.MYSQL,
|
|
16604
|
+
packageName: "mysql2",
|
|
16605
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16606
|
+
inputValue,
|
|
16607
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16608
|
+
isPreAppStart: false
|
|
16609
|
+
}, (spanInfo) => {
|
|
16610
|
+
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "preparedExecute", stackTrace);
|
|
16611
|
+
});
|
|
16612
|
+
}
|
|
16613
|
+
});
|
|
16614
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16615
|
+
originalFunctionCall: () => originalExecute(...args),
|
|
16616
|
+
recordModeHandler: ({ isPreAppStart }) => {
|
|
16617
|
+
const spanName = `mysql2.${clientType}.preparedExecute`;
|
|
16618
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute(...args), {
|
|
16619
|
+
name: spanName,
|
|
16620
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16621
|
+
submodule: "preparedExecute",
|
|
16622
|
+
packageType: PackageType.MYSQL,
|
|
16623
|
+
packageName: "mysql2",
|
|
16624
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16625
|
+
inputValue,
|
|
16626
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16627
|
+
isPreAppStart
|
|
16628
|
+
}, (spanInfo) => {
|
|
16629
|
+
return self._handleRecordQueryInSpan(spanInfo, originalExecute, queryConfig, args, void 0);
|
|
16630
|
+
});
|
|
16631
|
+
},
|
|
16632
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16633
|
+
});
|
|
16634
|
+
return originalExecute(...args);
|
|
16635
|
+
};
|
|
16636
|
+
}
|
|
16637
|
+
_handleReplayPrepare(sql, originalCallback, clientType) {
|
|
16638
|
+
const self = this;
|
|
16639
|
+
return SpanUtils.createAndExecuteSpan(this.mode, () => {}, {
|
|
16640
|
+
name: `mysql2.${clientType}.prepare`,
|
|
16641
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16642
|
+
submodule: "prepare",
|
|
16643
|
+
packageType: PackageType.MYSQL,
|
|
16644
|
+
packageName: "mysql2",
|
|
16645
|
+
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
16646
|
+
inputValue: {
|
|
16647
|
+
sql,
|
|
16648
|
+
clientType
|
|
16649
|
+
},
|
|
16650
|
+
isPreAppStart: false
|
|
16651
|
+
}, (spanInfo) => {
|
|
16652
|
+
const mockStatement = {
|
|
16653
|
+
query: sql,
|
|
16654
|
+
id: 1,
|
|
16655
|
+
columns: [],
|
|
16656
|
+
parameters: [],
|
|
16657
|
+
execute: self._getPreparedStatementExecuteWrapper(() => {}, sql, clientType),
|
|
16658
|
+
close: () => {}
|
|
16659
|
+
};
|
|
16660
|
+
try {
|
|
16661
|
+
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { prepared: true } });
|
|
16662
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16663
|
+
} catch (error) {
|
|
16664
|
+
logger.error(`[Mysql2Instrumentation] error ending prepare span:`, error);
|
|
16665
|
+
}
|
|
16666
|
+
if (originalCallback) process.nextTick(() => originalCallback(null, mockStatement));
|
|
16667
|
+
});
|
|
16668
|
+
}
|
|
16669
|
+
_handleNoOpReplayPrepare(sql, originalCallback) {
|
|
16670
|
+
const self = this;
|
|
16671
|
+
const mockStatement = {
|
|
16672
|
+
query: sql,
|
|
16673
|
+
id: 1,
|
|
16674
|
+
columns: [],
|
|
16675
|
+
parameters: [],
|
|
16676
|
+
execute: (...args) => {
|
|
16677
|
+
const values = Array.isArray(args[0]) ? args[0] : [];
|
|
16678
|
+
const callback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
16679
|
+
return self.queryMock.handleNoOpReplayQuery({
|
|
16680
|
+
sql,
|
|
16681
|
+
values,
|
|
16682
|
+
callback
|
|
16683
|
+
});
|
|
16684
|
+
},
|
|
16685
|
+
close: () => {}
|
|
16686
|
+
};
|
|
16687
|
+
if (originalCallback) process.nextTick(() => originalCallback(null, mockStatement));
|
|
16688
|
+
}
|
|
16281
16689
|
_handleSimpleCallbackMethod(spanInfo, originalMethod, callback, context$6) {
|
|
16282
16690
|
if (callback) {
|
|
16283
16691
|
const wrappedCallback = (error) => {
|
|
@@ -16285,7 +16693,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16285
16693
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16286
16694
|
try {
|
|
16287
16695
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16288
|
-
code: import_src$
|
|
16696
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16289
16697
|
message: error.message
|
|
16290
16698
|
});
|
|
16291
16699
|
} catch (error$1) {
|
|
@@ -16295,7 +16703,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16295
16703
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16296
16704
|
try {
|
|
16297
16705
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { success: true } });
|
|
16298
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16706
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16299
16707
|
} catch (error$1) {
|
|
16300
16708
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error$1);
|
|
16301
16709
|
}
|
|
@@ -16309,7 +16717,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16309
16717
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16310
16718
|
try {
|
|
16311
16719
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { success: true } });
|
|
16312
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16720
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16313
16721
|
} catch (error) {
|
|
16314
16722
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error);
|
|
16315
16723
|
}
|
|
@@ -16317,7 +16725,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16317
16725
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16318
16726
|
try {
|
|
16319
16727
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16320
|
-
code: import_src$
|
|
16728
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16321
16729
|
message: error.message
|
|
16322
16730
|
});
|
|
16323
16731
|
} catch (error$1) {
|
|
@@ -16329,7 +16737,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16329
16737
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method completed (non-promise) (${SpanUtils.getTraceInfo()})`);
|
|
16330
16738
|
try {
|
|
16331
16739
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { success: true } });
|
|
16332
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16740
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16333
16741
|
} catch (error) {
|
|
16334
16742
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error);
|
|
16335
16743
|
}
|
|
@@ -16349,22 +16757,36 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16349
16757
|
else if (args.length > 1 && typeof args[1] !== "function") config.values = [args[1]];
|
|
16350
16758
|
return config;
|
|
16351
16759
|
}
|
|
16352
|
-
if (typeof firstArg === "object" && firstArg.sql)
|
|
16353
|
-
|
|
16354
|
-
|
|
16355
|
-
|
|
16356
|
-
|
|
16760
|
+
if (typeof firstArg === "object" && firstArg.sql) {
|
|
16761
|
+
let values = firstArg.values;
|
|
16762
|
+
let callback = firstArg.callback;
|
|
16763
|
+
if (typeof args[1] === "function") callback = args[1];
|
|
16764
|
+
else {
|
|
16765
|
+
if (args[1] !== void 0) values = Array.isArray(args[1]) ? args[1] : [args[1]];
|
|
16766
|
+
if (typeof args[2] === "function") callback = args[2];
|
|
16767
|
+
}
|
|
16768
|
+
return {
|
|
16769
|
+
sql: firstArg.sql,
|
|
16770
|
+
values,
|
|
16771
|
+
callback
|
|
16772
|
+
};
|
|
16773
|
+
}
|
|
16357
16774
|
return null;
|
|
16358
16775
|
}
|
|
16359
16776
|
_handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, context$6) {
|
|
16360
|
-
|
|
16777
|
+
const hasCallback = !!queryConfig.callback;
|
|
16778
|
+
const invokeOriginal = (invokeArgs) => {
|
|
16779
|
+
return context$6 ? originalQuery.apply(context$6, invokeArgs) : originalQuery(...invokeArgs);
|
|
16780
|
+
};
|
|
16781
|
+
if (hasCallback) {
|
|
16782
|
+
const parentContext = import_src$22.context.active();
|
|
16361
16783
|
const originalCallback = queryConfig.callback;
|
|
16362
16784
|
const wrappedCallback = (error, results, fields) => {
|
|
16363
16785
|
if (error) {
|
|
16364
16786
|
logger.debug(`[Mysql2Instrumentation] MySQL2 query error (hasCallback): ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16365
16787
|
try {
|
|
16366
16788
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16367
|
-
code: import_src$
|
|
16789
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16368
16790
|
message: error.message
|
|
16369
16791
|
});
|
|
16370
16792
|
} catch (error$1) {
|
|
@@ -16374,12 +16796,12 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16374
16796
|
logger.debug(`[Mysql2Instrumentation] MySQL2 query completed successfully (hasCallback) (${SpanUtils.getTraceInfo()})`);
|
|
16375
16797
|
try {
|
|
16376
16798
|
this._addOutputAttributesToSpan(spanInfo, results, fields);
|
|
16377
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16799
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16378
16800
|
} catch (error$1) {
|
|
16379
16801
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error$1);
|
|
16380
16802
|
}
|
|
16381
16803
|
}
|
|
16382
|
-
return originalCallback(error, results, fields);
|
|
16804
|
+
return import_src$22.context.with(parentContext, () => originalCallback(error, results, fields));
|
|
16383
16805
|
};
|
|
16384
16806
|
try {
|
|
16385
16807
|
const firstArg = args[0];
|
|
@@ -16394,9 +16816,9 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16394
16816
|
} catch (error) {
|
|
16395
16817
|
logger.error(`[Mysql2Instrumentation] error replacing callback:`, error, args);
|
|
16396
16818
|
}
|
|
16397
|
-
return
|
|
16819
|
+
return invokeOriginal(args);
|
|
16398
16820
|
} else {
|
|
16399
|
-
const result =
|
|
16821
|
+
const result = invokeOriginal(args);
|
|
16400
16822
|
if (result && typeof result.on === "function") {
|
|
16401
16823
|
const streamResults = [];
|
|
16402
16824
|
let streamFields = null;
|
|
@@ -16404,7 +16826,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16404
16826
|
logger.debug(`[Mysql2Instrumentation] MySQL2 stream query error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16405
16827
|
try {
|
|
16406
16828
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16407
|
-
code: import_src$
|
|
16829
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16408
16830
|
message: error.message
|
|
16409
16831
|
});
|
|
16410
16832
|
} catch (error$1) {
|
|
@@ -16418,7 +16840,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16418
16840
|
logger.debug(`[Mysql2Instrumentation] MySQL2 stream query completed (${SpanUtils.getTraceInfo()})`);
|
|
16419
16841
|
try {
|
|
16420
16842
|
this._addOutputAttributesToSpan(spanInfo, streamResults, streamFields);
|
|
16421
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16843
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16422
16844
|
} catch (error) {
|
|
16423
16845
|
logger.error(`[Mysql2Instrumentation] error ending span:`, error);
|
|
16424
16846
|
}
|
|
@@ -16440,7 +16862,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16440
16862
|
logger.debug(`[Mysql2Instrumentation] MySQL2 Pool getConnection error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16441
16863
|
try {
|
|
16442
16864
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16443
|
-
code: import_src$
|
|
16865
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16444
16866
|
message: error.message
|
|
16445
16867
|
});
|
|
16446
16868
|
} catch (error$1) {
|
|
@@ -16453,7 +16875,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16453
16875
|
connected: true,
|
|
16454
16876
|
hasConnection: !!connection
|
|
16455
16877
|
} });
|
|
16456
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16878
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16457
16879
|
} catch (error$1) {
|
|
16458
16880
|
logger.error(`[Mysql2Instrumentation] error processing getConnection response:`, error$1);
|
|
16459
16881
|
}
|
|
@@ -16468,7 +16890,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16468
16890
|
connected: true,
|
|
16469
16891
|
hasConnection: !!connection
|
|
16470
16892
|
} });
|
|
16471
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16893
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16472
16894
|
} catch (error) {
|
|
16473
16895
|
logger.error(`[Mysql2Instrumentation] error processing getConnection response:`, error);
|
|
16474
16896
|
}
|
|
@@ -16477,7 +16899,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16477
16899
|
logger.debug(`[Mysql2Instrumentation] MySQL2 Pool getConnection error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16478
16900
|
try {
|
|
16479
16901
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16480
|
-
code: import_src$
|
|
16902
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16481
16903
|
message: error.message
|
|
16482
16904
|
});
|
|
16483
16905
|
} catch (error$1) {
|
|
@@ -16520,7 +16942,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16520
16942
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16521
16943
|
return SpanUtils.createAndExecuteSpan(self.mode, () => new OriginalConnection(...args), {
|
|
16522
16944
|
name: `mysql2.connection.create`,
|
|
16523
|
-
kind: import_src$
|
|
16945
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16524
16946
|
submodule: "connectEvent",
|
|
16525
16947
|
packageType: PackageType.MYSQL,
|
|
16526
16948
|
packageName: "mysql2",
|
|
@@ -16535,7 +16957,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16535
16957
|
connected: true,
|
|
16536
16958
|
connectionObj
|
|
16537
16959
|
} });
|
|
16538
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16960
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16539
16961
|
} catch {
|
|
16540
16962
|
logger.error(`[Mysql2Instrumentation] error adding span attributes:`);
|
|
16541
16963
|
}
|
|
@@ -16544,7 +16966,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16544
16966
|
try {
|
|
16545
16967
|
logger.debug(`[Mysql2Instrumentation] Connection error, recording: ${err.message}`);
|
|
16546
16968
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16547
|
-
code: import_src$
|
|
16969
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16548
16970
|
message: err.message
|
|
16549
16971
|
});
|
|
16550
16972
|
} catch {
|
|
@@ -16554,7 +16976,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16554
16976
|
return connection;
|
|
16555
16977
|
});
|
|
16556
16978
|
},
|
|
16557
|
-
spanKind: import_src$
|
|
16979
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16558
16980
|
});
|
|
16559
16981
|
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16560
16982
|
noOpRequestHandler: () => {
|
|
@@ -16564,7 +16986,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16564
16986
|
replayModeHandler: () => {
|
|
16565
16987
|
return SpanUtils.createAndExecuteSpan(self.mode, () => new OriginalConnection(...args), {
|
|
16566
16988
|
name: `mysql2.connection.create`,
|
|
16567
|
-
kind: import_src$
|
|
16989
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16568
16990
|
submodule: "connectEvent",
|
|
16569
16991
|
packageType: PackageType.MYSQL,
|
|
16570
16992
|
packageName: "mysql2",
|
|
@@ -16602,6 +17024,34 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16602
17024
|
if (event === "error" && !this._isConnectOrErrorEmitted) return this;
|
|
16603
17025
|
return super.on(event, listener);
|
|
16604
17026
|
}
|
|
17027
|
+
once(event, listener) {
|
|
17028
|
+
if (!this._connectEventMock) return super.once(event, listener);
|
|
17029
|
+
if (event === "connect" && !this._isConnectOrErrorEmitted) {
|
|
17030
|
+
this._connectEventMock.getReplayedConnectionEvent(inputValue).then(({ output }) => {
|
|
17031
|
+
if (output !== void 0) process.nextTick(() => {
|
|
17032
|
+
listener.call(this, output);
|
|
17033
|
+
this._isConnectOrErrorEmitted = true;
|
|
17034
|
+
});
|
|
17035
|
+
}).catch((err) => {
|
|
17036
|
+
logger.error(`[Mysql2Instrumentation] Error replaying connection event:`, err);
|
|
17037
|
+
});
|
|
17038
|
+
return this;
|
|
17039
|
+
}
|
|
17040
|
+
if (event === "error" && !this._isConnectOrErrorEmitted) return this;
|
|
17041
|
+
return super.once(event, listener);
|
|
17042
|
+
}
|
|
17043
|
+
connect(callback) {
|
|
17044
|
+
if (!callback) return;
|
|
17045
|
+
this._connectEventMock.getReplayedConnectionEvent(inputValue).then(({ output }) => {
|
|
17046
|
+
if (output !== void 0) process.nextTick(() => {
|
|
17047
|
+
this._isConnectOrErrorEmitted = true;
|
|
17048
|
+
callback(null);
|
|
17049
|
+
});
|
|
17050
|
+
}).catch((err) => {
|
|
17051
|
+
logger.error(`[Mysql2Instrumentation] Error replaying connection event in connect():`, err);
|
|
17052
|
+
process.nextTick(() => callback(err));
|
|
17053
|
+
});
|
|
17054
|
+
}
|
|
16605
17055
|
}
|
|
16606
17056
|
const mockConnection = new MockConnection(...args);
|
|
16607
17057
|
mockConnection.addListener("error", (_err) => {});
|
|
@@ -16629,9 +17079,13 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16629
17079
|
fields: fields || []
|
|
16630
17080
|
};
|
|
16631
17081
|
else if (result.affectedRows !== void 0) outputValue = {
|
|
17082
|
+
fieldCount: result.fieldCount,
|
|
16632
17083
|
affectedRows: result.affectedRows,
|
|
16633
17084
|
insertId: result.insertId,
|
|
16634
|
-
|
|
17085
|
+
info: result.info ?? "",
|
|
17086
|
+
serverStatus: result.serverStatus ?? 0,
|
|
17087
|
+
warningStatus: result.warningStatus ?? 0,
|
|
17088
|
+
changedRows: result.changedRows ?? 0
|
|
16635
17089
|
};
|
|
16636
17090
|
else outputValue = result;
|
|
16637
17091
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
@@ -16643,7 +17097,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16643
17097
|
|
|
16644
17098
|
//#endregion
|
|
16645
17099
|
//#region src/instrumentation/libraries/tcp/Instrumentation.ts
|
|
16646
|
-
var import_src$
|
|
17100
|
+
var import_src$21 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
16647
17101
|
/**
|
|
16648
17102
|
* TCP Instrumentation for Tusk Drift
|
|
16649
17103
|
*
|
|
@@ -16730,7 +17184,7 @@ var TcpInstrumentation = class extends TdInstrumentationBase {
|
|
|
16730
17184
|
const currentSpanInfo = SpanUtils.getCurrentSpanInfo();
|
|
16731
17185
|
if (!currentSpanInfo) return originalMethod.apply(socketContext, args);
|
|
16732
17186
|
const callingLibrary = currentSpanInfo.context.getValue(CALLING_LIBRARY_CONTEXT_KEY);
|
|
16733
|
-
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) === import_src$
|
|
17187
|
+
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) === import_src$21.SpanKind.SERVER && callingLibrary !== "ProtobufCommunicator") this._logUnpatchedDependency(methodName, currentSpanInfo, socketContext);
|
|
16734
17188
|
return originalMethod.apply(socketContext, args);
|
|
16735
17189
|
}
|
|
16736
17190
|
_isHttpResponseSocket(socketContext) {
|
|
@@ -16740,7 +17194,7 @@ var TcpInstrumentation = class extends TdInstrumentationBase {
|
|
|
16740
17194
|
|
|
16741
17195
|
//#endregion
|
|
16742
17196
|
//#region src/instrumentation/libraries/jsonwebtoken/Instrumentation.ts
|
|
16743
|
-
var import_src$
|
|
17197
|
+
var import_src$20 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
16744
17198
|
var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
16745
17199
|
constructor(config = {}) {
|
|
16746
17200
|
super("jsonwebtoken", config);
|
|
@@ -16820,7 +17274,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16820
17274
|
replayModeHandler: () => {
|
|
16821
17275
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalVerify.apply(this, args), {
|
|
16822
17276
|
name: "jsonwebtoken.verify",
|
|
16823
|
-
kind: import_src$
|
|
17277
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16824
17278
|
submodule: "verify",
|
|
16825
17279
|
packageName: "jsonwebtoken",
|
|
16826
17280
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16836,7 +17290,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16836
17290
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16837
17291
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalVerify.apply(this, args), {
|
|
16838
17292
|
name: "jsonwebtoken.verify",
|
|
16839
|
-
kind: import_src$
|
|
17293
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16840
17294
|
submodule: "verify",
|
|
16841
17295
|
packageName: "jsonwebtoken",
|
|
16842
17296
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16846,7 +17300,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16846
17300
|
return self._handleRecordVerifyInSpan(spanInfo, originalVerify, verifyConfig, args, this);
|
|
16847
17301
|
});
|
|
16848
17302
|
},
|
|
16849
|
-
spanKind: import_src$
|
|
17303
|
+
spanKind: import_src$20.SpanKind.CLIENT
|
|
16850
17304
|
});
|
|
16851
17305
|
else return originalVerify.apply(this, args);
|
|
16852
17306
|
};
|
|
@@ -16884,7 +17338,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16884
17338
|
replayModeHandler: () => {
|
|
16885
17339
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSign.apply(this, args), {
|
|
16886
17340
|
name: "jsonwebtoken.sign",
|
|
16887
|
-
kind: import_src$
|
|
17341
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16888
17342
|
submodule: "sign",
|
|
16889
17343
|
packageName: "jsonwebtoken",
|
|
16890
17344
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16900,7 +17354,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16900
17354
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16901
17355
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSign.apply(this, args), {
|
|
16902
17356
|
name: "jsonwebtoken.sign",
|
|
16903
|
-
kind: import_src$
|
|
17357
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16904
17358
|
submodule: "sign",
|
|
16905
17359
|
packageName: "jsonwebtoken",
|
|
16906
17360
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16910,7 +17364,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16910
17364
|
return self._handleRecordSignInSpan(spanInfo, originalSign, signConfig, args, this);
|
|
16911
17365
|
});
|
|
16912
17366
|
},
|
|
16913
|
-
spanKind: import_src$
|
|
17367
|
+
spanKind: import_src$20.SpanKind.CLIENT
|
|
16914
17368
|
});
|
|
16915
17369
|
else return originalSign.apply(this, args);
|
|
16916
17370
|
};
|
|
@@ -16949,7 +17403,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16949
17403
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16950
17404
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
16951
17405
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16952
|
-
code: import_src$
|
|
17406
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
16953
17407
|
message: error.message
|
|
16954
17408
|
});
|
|
16955
17409
|
} catch (error$1) {
|
|
@@ -16958,7 +17412,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16958
17412
|
else try {
|
|
16959
17413
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16960
17414
|
this._addOutputAttributesToSpan(spanInfo, decoded);
|
|
16961
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17415
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
16962
17416
|
} catch (error$1) {
|
|
16963
17417
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error$1);
|
|
16964
17418
|
}
|
|
@@ -16976,7 +17430,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16976
17430
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify sync error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16977
17431
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
16978
17432
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16979
|
-
code: import_src$
|
|
17433
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
16980
17434
|
message: error.message
|
|
16981
17435
|
});
|
|
16982
17436
|
} catch (error$1) {
|
|
@@ -16989,7 +17443,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16989
17443
|
try {
|
|
16990
17444
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16991
17445
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
16992
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17446
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
16993
17447
|
} catch (error) {
|
|
16994
17448
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error);
|
|
16995
17449
|
}
|
|
@@ -16999,7 +17453,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16999
17453
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
17000
17454
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
17001
17455
|
SpanUtils.endSpan(spanInfo.span, {
|
|
17002
|
-
code: import_src$
|
|
17456
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
17003
17457
|
message: error.message
|
|
17004
17458
|
});
|
|
17005
17459
|
} catch (error$1) {
|
|
@@ -17016,7 +17470,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17016
17470
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
17017
17471
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
17018
17472
|
SpanUtils.endSpan(spanInfo.span, {
|
|
17019
|
-
code: import_src$
|
|
17473
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
17020
17474
|
message: error.message
|
|
17021
17475
|
});
|
|
17022
17476
|
} catch (error$1) {
|
|
@@ -17025,7 +17479,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17025
17479
|
else try {
|
|
17026
17480
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
17027
17481
|
this._addOutputAttributesToSpan(spanInfo, token);
|
|
17028
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17482
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
17029
17483
|
} catch (error$1) {
|
|
17030
17484
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error$1);
|
|
17031
17485
|
}
|
|
@@ -17042,7 +17496,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17042
17496
|
try {
|
|
17043
17497
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
17044
17498
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
17045
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17499
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
17046
17500
|
} catch (error) {
|
|
17047
17501
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error);
|
|
17048
17502
|
}
|
|
@@ -17052,7 +17506,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17052
17506
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
17053
17507
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
17054
17508
|
SpanUtils.endSpan(spanInfo.span, {
|
|
17055
|
-
code: import_src$
|
|
17509
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
17056
17510
|
message: error.message
|
|
17057
17511
|
});
|
|
17058
17512
|
} catch (error$1) {
|
|
@@ -17061,9 +17515,9 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17061
17515
|
throw error;
|
|
17062
17516
|
}
|
|
17063
17517
|
}
|
|
17064
|
-
|
|
17518
|
+
handleReplayVerify(verifyConfig, inputValue, spanInfo, stackTrace) {
|
|
17065
17519
|
logger.debug(`[JsonwebtokenInstrumentation] Replaying JWT verify`);
|
|
17066
|
-
const mockData =
|
|
17520
|
+
const mockData = findMockResponseSync({
|
|
17067
17521
|
mockRequestData: {
|
|
17068
17522
|
traceId: spanInfo.traceId,
|
|
17069
17523
|
spanId: spanInfo.spanId,
|
|
@@ -17072,7 +17526,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17072
17526
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
17073
17527
|
submoduleName: "verify",
|
|
17074
17528
|
inputValue,
|
|
17075
|
-
kind: import_src$
|
|
17529
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
17076
17530
|
stackTrace
|
|
17077
17531
|
},
|
|
17078
17532
|
tuskDrift: this.tuskDrift
|
|
@@ -17104,9 +17558,9 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17104
17558
|
return;
|
|
17105
17559
|
} else return result;
|
|
17106
17560
|
}
|
|
17107
|
-
|
|
17561
|
+
handleReplaySign(signConfig, inputValue, spanInfo, stackTrace) {
|
|
17108
17562
|
logger.debug(`[JsonwebtokenInstrumentation] Replaying JWT sign`);
|
|
17109
|
-
const mockData =
|
|
17563
|
+
const mockData = findMockResponseSync({
|
|
17110
17564
|
mockRequestData: {
|
|
17111
17565
|
traceId: spanInfo?.traceId,
|
|
17112
17566
|
spanId: spanInfo?.spanId,
|
|
@@ -17115,7 +17569,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17115
17569
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
17116
17570
|
submoduleName: "sign",
|
|
17117
17571
|
inputValue,
|
|
17118
|
-
kind: import_src$
|
|
17572
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
17119
17573
|
stackTrace
|
|
17120
17574
|
},
|
|
17121
17575
|
tuskDrift: this.tuskDrift
|
|
@@ -17217,7 +17671,7 @@ var JwksRsaInstrumentation = class extends TdInstrumentationBase {
|
|
|
17217
17671
|
|
|
17218
17672
|
//#endregion
|
|
17219
17673
|
//#region src/instrumentation/libraries/fetch/FetchTransformEngine.ts
|
|
17220
|
-
var import_src$
|
|
17674
|
+
var import_src$19 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
17221
17675
|
/**
|
|
17222
17676
|
* Creates an empty FetchInputValue object for dropped spans
|
|
17223
17677
|
*/
|
|
@@ -17292,7 +17746,7 @@ var FetchTransformEngine = class {
|
|
|
17292
17746
|
}
|
|
17293
17747
|
compileMatcher(matcher) {
|
|
17294
17748
|
const checks = [];
|
|
17295
|
-
checks.push((span) => span.kind === import_src$
|
|
17749
|
+
checks.push((span) => span.kind === import_src$19.SpanKind.CLIENT);
|
|
17296
17750
|
if (matcher.method) if (matcher.method.length === 0) {} else {
|
|
17297
17751
|
const methods = matcher.method.map((method) => method.toUpperCase());
|
|
17298
17752
|
checks.push((span) => {
|
|
@@ -17488,7 +17942,7 @@ var FetchTransformEngine = class {
|
|
|
17488
17942
|
|
|
17489
17943
|
//#endregion
|
|
17490
17944
|
//#region src/instrumentation/libraries/fetch/Instrumentation.ts
|
|
17491
|
-
var import_src$
|
|
17945
|
+
var import_src$18 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
17492
17946
|
/**
|
|
17493
17947
|
* Fetch API instrumentation for capturing requests made via fetch()
|
|
17494
17948
|
* This covers libraries like @octokit/rest, axios (when using fetch adapter), etc.
|
|
@@ -17550,7 +18004,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17550
18004
|
replayModeHandler: () => {
|
|
17551
18005
|
return SpanUtils.createAndExecuteSpan(this.mode, () => this.originalFetch(input, init), {
|
|
17552
18006
|
name: url,
|
|
17553
|
-
kind: import_src$
|
|
18007
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17554
18008
|
packageName: "fetch",
|
|
17555
18009
|
packageType: PackageType.HTTP,
|
|
17556
18010
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
@@ -17565,14 +18019,14 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17565
18019
|
else if (this.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
17566
18020
|
originalFunctionCall: () => this.originalFetch(input, init),
|
|
17567
18021
|
recordModeHandler: ({ isPreAppStart }) => this._handleRecordFetch(input, inputValue, isPreAppStart, init),
|
|
17568
|
-
spanKind: import_src$
|
|
18022
|
+
spanKind: import_src$18.SpanKind.CLIENT
|
|
17569
18023
|
});
|
|
17570
18024
|
else return this.originalFetch(input, init);
|
|
17571
18025
|
}
|
|
17572
18026
|
_handleRecordFetch(input, inputValue, isPreAppStart, init) {
|
|
17573
18027
|
return SpanUtils.createAndExecuteSpan(this.mode, () => this.originalFetch(input, init), {
|
|
17574
18028
|
name: inputValue.url,
|
|
17575
|
-
kind: import_src$
|
|
18029
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17576
18030
|
packageName: "fetch",
|
|
17577
18031
|
packageType: PackageType.HTTP,
|
|
17578
18032
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
@@ -17601,7 +18055,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17601
18055
|
const spanData = {
|
|
17602
18056
|
traceId: spanInfo.traceId,
|
|
17603
18057
|
spanId: spanInfo.spanId,
|
|
17604
|
-
kind: import_src$
|
|
18058
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17605
18059
|
inputValue,
|
|
17606
18060
|
outputValue
|
|
17607
18061
|
};
|
|
@@ -17619,9 +18073,9 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17619
18073
|
...spanData.transformMetadata && { transformMetadata: spanData.transformMetadata }
|
|
17620
18074
|
});
|
|
17621
18075
|
const status = response.status >= 300 ? {
|
|
17622
|
-
code: import_src$
|
|
18076
|
+
code: import_src$18.SpanStatusCode.ERROR,
|
|
17623
18077
|
message: `HTTP ${response.status}`
|
|
17624
|
-
} : { code: import_src$
|
|
18078
|
+
} : { code: import_src$18.SpanStatusCode.OK };
|
|
17625
18079
|
SpanUtils.endSpan(spanInfo.span, status);
|
|
17626
18080
|
} catch (error) {
|
|
17627
18081
|
logger.error(`[FetchInstrumentation] error processing response body:`, error);
|
|
@@ -17630,7 +18084,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17630
18084
|
}).catch((error) => {
|
|
17631
18085
|
try {
|
|
17632
18086
|
SpanUtils.endSpan(spanInfo.span, {
|
|
17633
|
-
code: import_src$
|
|
18087
|
+
code: import_src$18.SpanStatusCode.ERROR,
|
|
17634
18088
|
message: error.message
|
|
17635
18089
|
});
|
|
17636
18090
|
} catch (error$1) {
|
|
@@ -17651,7 +18105,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17651
18105
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
17652
18106
|
submoduleName: inputValue.method,
|
|
17653
18107
|
inputValue,
|
|
17654
|
-
kind: import_src$
|
|
18108
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17655
18109
|
stackTrace
|
|
17656
18110
|
},
|
|
17657
18111
|
tuskDrift: this.tuskDrift,
|
|
@@ -17817,10 +18271,23 @@ function convertValueToJsonable(value) {
|
|
|
17817
18271
|
encoding: BufferEncoding.NONE
|
|
17818
18272
|
};
|
|
17819
18273
|
}
|
|
18274
|
+
/**
|
|
18275
|
+
* Recursively deserialize Buffer objects from JSON representation.
|
|
18276
|
+
* Converts {"type":"Buffer","data":[...]} back to actual Buffer instances.
|
|
18277
|
+
* This handles the format produced by JSON.stringify(Buffer).
|
|
18278
|
+
*/
|
|
18279
|
+
function deserializeBufferValue(value) {
|
|
18280
|
+
if (!value || typeof value !== "object") return value;
|
|
18281
|
+
if (value.type === "Buffer" && Array.isArray(value.data)) return Buffer.from(value.data);
|
|
18282
|
+
if (Array.isArray(value)) return value.map((item) => deserializeBufferValue(item));
|
|
18283
|
+
const result = {};
|
|
18284
|
+
for (const key of Object.keys(value)) result[key] = deserializeBufferValue(value[key]);
|
|
18285
|
+
return result;
|
|
18286
|
+
}
|
|
17820
18287
|
|
|
17821
18288
|
//#endregion
|
|
17822
18289
|
//#region src/instrumentation/libraries/ioredis/Instrumentation.ts
|
|
17823
|
-
var import_src$
|
|
18290
|
+
var import_src$17 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
17824
18291
|
const SUPPORTED_VERSIONS$1 = [">=4.11.0 <5", "5.*"];
|
|
17825
18292
|
var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
17826
18293
|
constructor(config = {}) {
|
|
@@ -17938,7 +18405,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17938
18405
|
replayModeHandler: () => {
|
|
17939
18406
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSendCommand.apply(this, arguments), {
|
|
17940
18407
|
name: `ioredis.${commandName}`,
|
|
17941
|
-
kind: import_src$
|
|
18408
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
17942
18409
|
submodule: commandName,
|
|
17943
18410
|
packageType: PackageType.REDIS,
|
|
17944
18411
|
packageName: "ioredis",
|
|
@@ -17955,7 +18422,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17955
18422
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
17956
18423
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSendCommand.apply(this, arguments), {
|
|
17957
18424
|
name: `ioredis.${commandName}`,
|
|
17958
|
-
kind: import_src$
|
|
18425
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
17959
18426
|
submodule: commandName,
|
|
17960
18427
|
packageType: PackageType.REDIS,
|
|
17961
18428
|
packageName: "ioredis",
|
|
@@ -17966,7 +18433,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17966
18433
|
return self._handleRecordSendCommand(spanInfo, originalSendCommand, cmd, this);
|
|
17967
18434
|
});
|
|
17968
18435
|
},
|
|
17969
|
-
spanKind: import_src$
|
|
18436
|
+
spanKind: import_src$17.SpanKind.CLIENT
|
|
17970
18437
|
});
|
|
17971
18438
|
else return originalSendCommand.apply(this, arguments);
|
|
17972
18439
|
};
|
|
@@ -17991,7 +18458,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17991
18458
|
replayModeHandler: () => {
|
|
17992
18459
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, arguments), {
|
|
17993
18460
|
name: "ioredis.connect",
|
|
17994
|
-
kind: import_src$
|
|
18461
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
17995
18462
|
submodule: "connect",
|
|
17996
18463
|
packageType: PackageType.REDIS,
|
|
17997
18464
|
packageName: "ioredis",
|
|
@@ -18008,7 +18475,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18008
18475
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
18009
18476
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, arguments), {
|
|
18010
18477
|
name: "ioredis.connect",
|
|
18011
|
-
kind: import_src$
|
|
18478
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18012
18479
|
submodule: "connect",
|
|
18013
18480
|
packageType: PackageType.REDIS,
|
|
18014
18481
|
packageName: "ioredis",
|
|
@@ -18019,7 +18486,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18019
18486
|
return self._handleRecordConnect(spanInfo, originalConnect, this);
|
|
18020
18487
|
});
|
|
18021
18488
|
},
|
|
18022
|
-
spanKind: import_src$
|
|
18489
|
+
spanKind: import_src$17.SpanKind.CLIENT
|
|
18023
18490
|
});
|
|
18024
18491
|
else return originalConnect.apply(this, arguments);
|
|
18025
18492
|
};
|
|
@@ -18067,7 +18534,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18067
18534
|
replayModeHandler: () => {
|
|
18068
18535
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExec.apply(this, args), {
|
|
18069
18536
|
name: "ioredis.pipeline.exec",
|
|
18070
|
-
kind: import_src$
|
|
18537
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18071
18538
|
submodule: "pipeline-exec",
|
|
18072
18539
|
packageType: PackageType.REDIS,
|
|
18073
18540
|
packageName: "ioredis",
|
|
@@ -18084,7 +18551,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18084
18551
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
18085
18552
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExec.apply(this, args), {
|
|
18086
18553
|
name: "ioredis.pipeline.exec",
|
|
18087
|
-
kind: import_src$
|
|
18554
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18088
18555
|
submodule: "pipeline-exec",
|
|
18089
18556
|
packageType: PackageType.REDIS,
|
|
18090
18557
|
packageName: "ioredis",
|
|
@@ -18095,7 +18562,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18095
18562
|
return self._handleRecordPipelineExec(spanInfo, originalExec, this, args);
|
|
18096
18563
|
});
|
|
18097
18564
|
},
|
|
18098
|
-
spanKind: import_src$
|
|
18565
|
+
spanKind: import_src$17.SpanKind.CLIENT
|
|
18099
18566
|
});
|
|
18100
18567
|
else return originalExec.apply(this, args);
|
|
18101
18568
|
};
|
|
@@ -18108,7 +18575,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18108
18575
|
logger.debug(`[IORedisInstrumentation] IORedis command ${cmd.name} completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
18109
18576
|
const outputValue = this._serializeOutput(result);
|
|
18110
18577
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
18111
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18578
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18112
18579
|
} catch (error) {
|
|
18113
18580
|
logger.error(`[IORedisInstrumentation] error processing command response:`, error);
|
|
18114
18581
|
}
|
|
@@ -18117,7 +18584,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18117
18584
|
try {
|
|
18118
18585
|
logger.debug(`[IORedisInstrumentation] IORedis command ${cmd.name} error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
18119
18586
|
SpanUtils.endSpan(spanInfo.span, {
|
|
18120
|
-
code: import_src$
|
|
18587
|
+
code: import_src$17.SpanStatusCode.ERROR,
|
|
18121
18588
|
message: error.message
|
|
18122
18589
|
});
|
|
18123
18590
|
} catch (spanError) {
|
|
@@ -18138,7 +18605,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18138
18605
|
packageName: "ioredis",
|
|
18139
18606
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
18140
18607
|
submoduleName: cmd.name,
|
|
18141
|
-
kind: import_src$
|
|
18608
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18142
18609
|
stackTrace
|
|
18143
18610
|
},
|
|
18144
18611
|
tuskDrift: this.tuskDrift
|
|
@@ -18160,7 +18627,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18160
18627
|
try {
|
|
18161
18628
|
logger.debug(`[IORedisInstrumentation] IORedis connect completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
18162
18629
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
18163
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18630
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18164
18631
|
} catch {
|
|
18165
18632
|
logger.error(`[IORedisInstrumentation] error adding span attributes`);
|
|
18166
18633
|
}
|
|
@@ -18169,7 +18636,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18169
18636
|
try {
|
|
18170
18637
|
logger.debug(`[IORedisInstrumentation] IORedis connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
18171
18638
|
SpanUtils.endSpan(spanInfo.span, {
|
|
18172
|
-
code: import_src$
|
|
18639
|
+
code: import_src$17.SpanStatusCode.ERROR,
|
|
18173
18640
|
message: error.message
|
|
18174
18641
|
});
|
|
18175
18642
|
} catch {
|
|
@@ -18180,7 +18647,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18180
18647
|
try {
|
|
18181
18648
|
logger.debug(`[IORedisInstrumentation] IORedis connect completed (synchronous) (${SpanUtils.getTraceInfo()})`);
|
|
18182
18649
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
18183
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18650
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18184
18651
|
} catch {
|
|
18185
18652
|
logger.error(`[IORedisInstrumentation] error adding span attributes`);
|
|
18186
18653
|
}
|
|
@@ -18200,7 +18667,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18200
18667
|
logger.debug(`[IORedisInstrumentation] Pipeline exec completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
18201
18668
|
const outputValue = this._serializePipelineOutput(results);
|
|
18202
18669
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
18203
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18670
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18204
18671
|
} catch {
|
|
18205
18672
|
logger.error(`[IORedisInstrumentation] error adding span attributes`);
|
|
18206
18673
|
}
|
|
@@ -18209,7 +18676,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18209
18676
|
try {
|
|
18210
18677
|
logger.debug(`[IORedisInstrumentation] Pipeline exec error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
18211
18678
|
SpanUtils.endSpan(spanInfo.span, {
|
|
18212
|
-
code: import_src$
|
|
18679
|
+
code: import_src$17.SpanStatusCode.ERROR,
|
|
18213
18680
|
message: error.message
|
|
18214
18681
|
});
|
|
18215
18682
|
} catch {
|
|
@@ -18230,7 +18697,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18230
18697
|
packageName: "ioredis",
|
|
18231
18698
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
18232
18699
|
submoduleName: "pipeline-exec",
|
|
18233
|
-
kind: import_src$
|
|
18700
|
+
kind: import_src$17.SpanKind.CLIENT
|
|
18234
18701
|
},
|
|
18235
18702
|
tuskDrift: this.tuskDrift
|
|
18236
18703
|
});
|
|
@@ -18270,12 +18737,12 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18270
18737
|
}
|
|
18271
18738
|
_deserializePipelineOutput(outputValue) {
|
|
18272
18739
|
if (!outputValue) return [];
|
|
18273
|
-
return outputValue.value || outputValue;
|
|
18740
|
+
return deserializeBufferValue(outputValue.value || outputValue);
|
|
18274
18741
|
}
|
|
18275
18742
|
_deserializeOutput(outputValue) {
|
|
18276
18743
|
if (!outputValue) return;
|
|
18277
|
-
if (typeof outputValue !== "object" || !("value" in outputValue)) return outputValue;
|
|
18278
|
-
return outputValue.value;
|
|
18744
|
+
if (typeof outputValue !== "object" || !("value" in outputValue)) return deserializeBufferValue(outputValue);
|
|
18745
|
+
return deserializeBufferValue(outputValue.value);
|
|
18279
18746
|
}
|
|
18280
18747
|
_wrap(target, propertyName, wrapper) {
|
|
18281
18748
|
wrap(target, propertyName, wrapper);
|
|
@@ -18284,7 +18751,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18284
18751
|
|
|
18285
18752
|
//#endregion
|
|
18286
18753
|
//#region src/instrumentation/libraries/upstash-redis-js/Instrumentation.ts
|
|
18287
|
-
var import_src$
|
|
18754
|
+
var import_src$16 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
18288
18755
|
const SUPPORTED_VERSIONS = [">=1.0.0"];
|
|
18289
18756
|
const REDIS_COMMANDS = [
|
|
18290
18757
|
"get",
|
|
@@ -18541,7 +19008,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18541
19008
|
replayModeHandler: () => {
|
|
18542
19009
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalValue.apply(this === receiver ? target : this, args), {
|
|
18543
19010
|
name: operationName,
|
|
18544
|
-
kind: import_src$
|
|
19011
|
+
kind: import_src$16.SpanKind.CLIENT,
|
|
18545
19012
|
submodule: submoduleName,
|
|
18546
19013
|
packageType: PackageType.REDIS,
|
|
18547
19014
|
packageName: "@upstash/redis",
|
|
@@ -18558,7 +19025,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18558
19025
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
18559
19026
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalValue.apply(this === receiver ? target : this, args), {
|
|
18560
19027
|
name: operationName,
|
|
18561
|
-
kind: import_src$
|
|
19028
|
+
kind: import_src$16.SpanKind.CLIENT,
|
|
18562
19029
|
submodule: submoduleName,
|
|
18563
19030
|
packageType: PackageType.REDIS,
|
|
18564
19031
|
packageName: "@upstash/redis",
|
|
@@ -18570,7 +19037,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18570
19037
|
return self._handleRecordCommand(spanInfo, originalValue, this === receiver ? target : this, args);
|
|
18571
19038
|
});
|
|
18572
19039
|
},
|
|
18573
|
-
spanKind: import_src$
|
|
19040
|
+
spanKind: import_src$16.SpanKind.CLIENT
|
|
18574
19041
|
});
|
|
18575
19042
|
else return originalValue.apply(this === receiver ? target : this, args);
|
|
18576
19043
|
};
|
|
@@ -18585,7 +19052,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18585
19052
|
const outputValue = { result };
|
|
18586
19053
|
try {
|
|
18587
19054
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
18588
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
19055
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$16.SpanStatusCode.OK });
|
|
18589
19056
|
} catch (error) {
|
|
18590
19057
|
logger.error(`[UpstashRedisInstrumentation] Error adding span attributes: ${error}`);
|
|
18591
19058
|
}
|
|
@@ -18593,7 +19060,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18593
19060
|
} catch (error) {
|
|
18594
19061
|
logger.debug(`[UpstashRedisInstrumentation] Command error: ${error}`);
|
|
18595
19062
|
try {
|
|
18596
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
19063
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$16.SpanStatusCode.ERROR });
|
|
18597
19064
|
} catch (error$1) {
|
|
18598
19065
|
logger.error(`[UpstashRedisInstrumentation] Error ending span: ${error$1}`);
|
|
18599
19066
|
}
|
|
@@ -18611,7 +19078,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18611
19078
|
packageName: "@upstash/redis",
|
|
18612
19079
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
18613
19080
|
submoduleName,
|
|
18614
|
-
kind: import_src$
|
|
19081
|
+
kind: import_src$16.SpanKind.CLIENT,
|
|
18615
19082
|
stackTrace
|
|
18616
19083
|
},
|
|
18617
19084
|
tuskDrift: this.tuskDrift
|
|
@@ -18784,7 +19251,7 @@ function deepClone(obj) {
|
|
|
18784
19251
|
|
|
18785
19252
|
//#endregion
|
|
18786
19253
|
//#region src/instrumentation/libraries/grpc/Instrumentation.ts
|
|
18787
|
-
var import_src$
|
|
19254
|
+
var import_src$15 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
18788
19255
|
const GRPC_MODULE_NAME = "@grpc/grpc-js";
|
|
18789
19256
|
var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBase {
|
|
18790
19257
|
constructor(config = {}) {
|
|
@@ -18846,16 +19313,28 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18846
19313
|
/**
|
|
18847
19314
|
* Helper method to parse optional unary response arguments
|
|
18848
19315
|
*
|
|
18849
|
-
* Handles the following cases:
|
|
18850
|
-
* 1. (
|
|
18851
|
-
* 2. (metadata: Metadata,
|
|
19316
|
+
* Handles the following cases (matching grpc-node's checkOptionalUnaryResponseArguments):
|
|
19317
|
+
* 1. (callback: Function) - callback only, no metadata or options
|
|
19318
|
+
* 2. (metadata: Metadata, callback: Function) - metadata + callback, no options
|
|
19319
|
+
* 3. (options: Object, callback: Function) - options + callback, no metadata
|
|
19320
|
+
* 4. (metadata: Metadata, options: Object, callback: Function) - full signature
|
|
18852
19321
|
*/
|
|
18853
19322
|
parseUnaryCallArguments(MetadataConstructor, arg1, arg2, arg3) {
|
|
19323
|
+
if (typeof arg1 === "function") return {
|
|
19324
|
+
metadata: new MetadataConstructor(),
|
|
19325
|
+
options: {},
|
|
19326
|
+
callback: arg1
|
|
19327
|
+
};
|
|
18854
19328
|
if (arg1 instanceof MetadataConstructor && typeof arg2 === "function") return {
|
|
18855
19329
|
metadata: arg1,
|
|
18856
19330
|
options: {},
|
|
18857
19331
|
callback: arg2
|
|
18858
19332
|
};
|
|
19333
|
+
if (!(arg1 instanceof MetadataConstructor) && typeof arg1 === "object" && arg1 !== null && typeof arg2 === "function") return {
|
|
19334
|
+
metadata: new MetadataConstructor(),
|
|
19335
|
+
options: arg1,
|
|
19336
|
+
callback: arg2
|
|
19337
|
+
};
|
|
18859
19338
|
if (arg1 instanceof MetadataConstructor && arg2 instanceof Object && typeof arg3 === "function") return {
|
|
18860
19339
|
metadata: arg1,
|
|
18861
19340
|
options: arg2,
|
|
@@ -18935,7 +19414,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18935
19414
|
replayModeHandler: () => {
|
|
18936
19415
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
18937
19416
|
name: "grpc.client.unary",
|
|
18938
|
-
kind: import_src$
|
|
19417
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
18939
19418
|
submodule: "client",
|
|
18940
19419
|
packageType: PackageType.GRPC,
|
|
18941
19420
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -18952,7 +19431,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18952
19431
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
18953
19432
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
18954
19433
|
name: "grpc.client.unary",
|
|
18955
|
-
kind: import_src$
|
|
19434
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
18956
19435
|
submodule: "client",
|
|
18957
19436
|
packageType: PackageType.GRPC,
|
|
18958
19437
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -18963,7 +19442,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18963
19442
|
return self._handleRecordUnaryRequest(spanInfo, original, this, parsedParams, callback);
|
|
18964
19443
|
});
|
|
18965
19444
|
},
|
|
18966
|
-
spanKind: import_src$
|
|
19445
|
+
spanKind: import_src$15.SpanKind.CLIENT
|
|
18967
19446
|
});
|
|
18968
19447
|
else return original.apply(this, args);
|
|
18969
19448
|
};
|
|
@@ -19029,7 +19508,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19029
19508
|
replayModeHandler: () => {
|
|
19030
19509
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
19031
19510
|
name: "grpc.client.server_stream",
|
|
19032
|
-
kind: import_src$
|
|
19511
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
19033
19512
|
submodule: "client",
|
|
19034
19513
|
packageType: PackageType.GRPC,
|
|
19035
19514
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -19046,7 +19525,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19046
19525
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19047
19526
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
19048
19527
|
name: "grpc.client.server_stream",
|
|
19049
|
-
kind: import_src$
|
|
19528
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
19050
19529
|
submodule: "client",
|
|
19051
19530
|
packageType: PackageType.GRPC,
|
|
19052
19531
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -19057,7 +19536,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19057
19536
|
return self._handleRecordServerStreamRequest(spanInfo, original, this, parsedParams);
|
|
19058
19537
|
});
|
|
19059
19538
|
},
|
|
19060
|
-
spanKind: import_src$
|
|
19539
|
+
spanKind: import_src$15.SpanKind.CLIENT
|
|
19061
19540
|
});
|
|
19062
19541
|
else return original.apply(this, args);
|
|
19063
19542
|
};
|
|
@@ -19140,7 +19619,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19140
19619
|
status,
|
|
19141
19620
|
bufferMap: responseBufferMap,
|
|
19142
19621
|
jsonableStringMap: responseJsonableStringMap
|
|
19143
|
-
}, import_src$
|
|
19622
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19144
19623
|
else if (isStatusEmitted && hasErrorOccurred) completeSpan({
|
|
19145
19624
|
error: {
|
|
19146
19625
|
message: serviceError.message,
|
|
@@ -19149,7 +19628,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19149
19628
|
},
|
|
19150
19629
|
status,
|
|
19151
19630
|
metadata: responseMetadataInitial
|
|
19152
|
-
}, import_src$
|
|
19631
|
+
}, import_src$15.SpanStatusCode.ERROR, serviceError.message);
|
|
19153
19632
|
} catch (e) {
|
|
19154
19633
|
logger.error(`[GrpcInstrumentation] Error in patchedCallback:`, e);
|
|
19155
19634
|
}
|
|
@@ -19181,7 +19660,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19181
19660
|
status,
|
|
19182
19661
|
bufferMap: responseBufferMap,
|
|
19183
19662
|
jsonableStringMap: responseJsonableStringMap
|
|
19184
|
-
}, import_src$
|
|
19663
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19185
19664
|
else if (hasErrorOccurred) completeSpan({
|
|
19186
19665
|
error: {
|
|
19187
19666
|
message: serviceError.message,
|
|
@@ -19190,7 +19669,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19190
19669
|
},
|
|
19191
19670
|
status,
|
|
19192
19671
|
metadata: responseMetadataInitial
|
|
19193
|
-
}, import_src$
|
|
19672
|
+
}, import_src$15.SpanStatusCode.ERROR, serviceError.message);
|
|
19194
19673
|
});
|
|
19195
19674
|
return result;
|
|
19196
19675
|
}
|
|
@@ -19214,7 +19693,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19214
19693
|
packageType: PackageType.GRPC,
|
|
19215
19694
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
19216
19695
|
submoduleName: "client",
|
|
19217
|
-
kind: import_src$
|
|
19696
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
19218
19697
|
stackTrace
|
|
19219
19698
|
},
|
|
19220
19699
|
tuskDrift: this.tuskDrift
|
|
@@ -19318,14 +19797,14 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19318
19797
|
status,
|
|
19319
19798
|
bufferMap: {},
|
|
19320
19799
|
jsonableStringMap: {}
|
|
19321
|
-
}, import_src$
|
|
19800
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19322
19801
|
else if (!hasErrorOccurred && streamResponses.length === 0) completeSpan({
|
|
19323
19802
|
body: [],
|
|
19324
19803
|
metadata: responseMetadataInitial,
|
|
19325
19804
|
status,
|
|
19326
19805
|
bufferMap: {},
|
|
19327
19806
|
jsonableStringMap: {}
|
|
19328
|
-
}, import_src$
|
|
19807
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19329
19808
|
else if (hasErrorOccurred) completeSpan({
|
|
19330
19809
|
error: {
|
|
19331
19810
|
message: serviceError.message,
|
|
@@ -19334,7 +19813,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19334
19813
|
},
|
|
19335
19814
|
status,
|
|
19336
19815
|
metadata: responseMetadataInitial
|
|
19337
|
-
}, import_src$
|
|
19816
|
+
}, import_src$15.SpanStatusCode.ERROR, serviceError.message);
|
|
19338
19817
|
});
|
|
19339
19818
|
return stream$1;
|
|
19340
19819
|
}
|
|
@@ -19359,7 +19838,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19359
19838
|
packageType: PackageType.GRPC,
|
|
19360
19839
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
19361
19840
|
submoduleName: "client",
|
|
19362
|
-
kind: import_src$
|
|
19841
|
+
kind: import_src$15.SpanKind.CLIENT
|
|
19363
19842
|
},
|
|
19364
19843
|
tuskDrift: this.tuskDrift
|
|
19365
19844
|
}).then((mockData) => {
|
|
@@ -19631,7 +20110,7 @@ var TdFirestoreWriteResultMock = class {
|
|
|
19631
20110
|
|
|
19632
20111
|
//#endregion
|
|
19633
20112
|
//#region src/instrumentation/libraries/firestore/Instrumentation.ts
|
|
19634
|
-
var import_src$
|
|
20113
|
+
var import_src$14 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
19635
20114
|
const FIRESTORE_VERSION = "7.*";
|
|
19636
20115
|
const PACKAGE_NAME = "@google-cloud/firestore";
|
|
19637
20116
|
var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
@@ -19739,7 +20218,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19739
20218
|
replayModeHandler: () => {
|
|
19740
20219
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
19741
20220
|
name: "firestore.document.get",
|
|
19742
|
-
kind: import_src$
|
|
20221
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19743
20222
|
submodule: "document",
|
|
19744
20223
|
packageType: PackageType.FIRESTORE,
|
|
19745
20224
|
packageName: PACKAGE_NAME,
|
|
@@ -19757,7 +20236,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19757
20236
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19758
20237
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
19759
20238
|
name: "firestore.document.get",
|
|
19760
|
-
kind: import_src$
|
|
20239
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19761
20240
|
submodule: "document",
|
|
19762
20241
|
packageType: PackageType.FIRESTORE,
|
|
19763
20242
|
packageName: PACKAGE_NAME,
|
|
@@ -19769,7 +20248,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19769
20248
|
return self._handleRecordDocumentGet(spanInfo, originalGet, this);
|
|
19770
20249
|
});
|
|
19771
20250
|
},
|
|
19772
|
-
spanKind: import_src$
|
|
20251
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19773
20252
|
});
|
|
19774
20253
|
else return originalGet.call(this);
|
|
19775
20254
|
};
|
|
@@ -19797,7 +20276,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19797
20276
|
};
|
|
19798
20277
|
try {
|
|
19799
20278
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: documentResult });
|
|
19800
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20279
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
19801
20280
|
} catch {
|
|
19802
20281
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for document.get`);
|
|
19803
20282
|
}
|
|
@@ -19814,7 +20293,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19814
20293
|
packageName: PACKAGE_NAME,
|
|
19815
20294
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
19816
20295
|
submoduleName: "document",
|
|
19817
|
-
kind: import_src$
|
|
20296
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
19818
20297
|
},
|
|
19819
20298
|
tuskDrift: this.tuskDrift
|
|
19820
20299
|
});
|
|
@@ -19846,7 +20325,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19846
20325
|
replayModeHandler: () => {
|
|
19847
20326
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCreate.call(this, data), {
|
|
19848
20327
|
name: "firestore.document.create",
|
|
19849
|
-
kind: import_src$
|
|
20328
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19850
20329
|
submodule: "document",
|
|
19851
20330
|
packageType: PackageType.FIRESTORE,
|
|
19852
20331
|
packageName: PACKAGE_NAME,
|
|
@@ -19864,7 +20343,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19864
20343
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19865
20344
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCreate.call(this, data), {
|
|
19866
20345
|
name: "firestore.document.create",
|
|
19867
|
-
kind: import_src$
|
|
20346
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19868
20347
|
submodule: "document",
|
|
19869
20348
|
packageType: PackageType.FIRESTORE,
|
|
19870
20349
|
packageName: PACKAGE_NAME,
|
|
@@ -19876,7 +20355,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19876
20355
|
return self._handleRecordDocumentWrite(spanInfo, originalCreate, this, data);
|
|
19877
20356
|
});
|
|
19878
20357
|
},
|
|
19879
|
-
spanKind: import_src$
|
|
20358
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19880
20359
|
});
|
|
19881
20360
|
else return originalCreate.call(this, data);
|
|
19882
20361
|
};
|
|
@@ -19904,7 +20383,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19904
20383
|
replayModeHandler: () => {
|
|
19905
20384
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSet.call(this, data, options), {
|
|
19906
20385
|
name: "firestore.document.set",
|
|
19907
|
-
kind: import_src$
|
|
20386
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19908
20387
|
submodule: "document",
|
|
19909
20388
|
packageType: PackageType.FIRESTORE,
|
|
19910
20389
|
packageName: PACKAGE_NAME,
|
|
@@ -19922,7 +20401,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19922
20401
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19923
20402
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSet.call(this, data, options), {
|
|
19924
20403
|
name: "firestore.document.set",
|
|
19925
|
-
kind: import_src$
|
|
20404
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19926
20405
|
submodule: "document",
|
|
19927
20406
|
packageType: PackageType.FIRESTORE,
|
|
19928
20407
|
packageName: PACKAGE_NAME,
|
|
@@ -19934,7 +20413,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19934
20413
|
return self._handleRecordDocumentWrite(spanInfo, originalSet, this, data, options);
|
|
19935
20414
|
});
|
|
19936
20415
|
},
|
|
19937
|
-
spanKind: import_src$
|
|
20416
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19938
20417
|
});
|
|
19939
20418
|
else return originalSet.call(this, data, options);
|
|
19940
20419
|
};
|
|
@@ -19961,7 +20440,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19961
20440
|
replayModeHandler: () => {
|
|
19962
20441
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalUpdate.apply(this, args), {
|
|
19963
20442
|
name: "firestore.document.update",
|
|
19964
|
-
kind: import_src$
|
|
20443
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19965
20444
|
submodule: "document",
|
|
19966
20445
|
packageType: PackageType.FIRESTORE,
|
|
19967
20446
|
packageName: PACKAGE_NAME,
|
|
@@ -19979,7 +20458,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19979
20458
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19980
20459
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalUpdate.apply(this, args), {
|
|
19981
20460
|
name: "firestore.document.update",
|
|
19982
|
-
kind: import_src$
|
|
20461
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19983
20462
|
submodule: "document",
|
|
19984
20463
|
packageType: PackageType.FIRESTORE,
|
|
19985
20464
|
packageName: PACKAGE_NAME,
|
|
@@ -19991,7 +20470,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19991
20470
|
return self._handleRecordDocumentWrite(spanInfo, originalUpdate, this, ...args);
|
|
19992
20471
|
});
|
|
19993
20472
|
},
|
|
19994
|
-
spanKind: import_src$
|
|
20473
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19995
20474
|
});
|
|
19996
20475
|
else return originalUpdate.apply(this, args);
|
|
19997
20476
|
};
|
|
@@ -20018,7 +20497,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20018
20497
|
replayModeHandler: () => {
|
|
20019
20498
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalDelete.call(this, precondition), {
|
|
20020
20499
|
name: "firestore.document.delete",
|
|
20021
|
-
kind: import_src$
|
|
20500
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20022
20501
|
submodule: "document",
|
|
20023
20502
|
packageType: PackageType.FIRESTORE,
|
|
20024
20503
|
packageName: PACKAGE_NAME,
|
|
@@ -20036,7 +20515,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20036
20515
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20037
20516
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalDelete.call(this, precondition), {
|
|
20038
20517
|
name: "firestore.document.delete",
|
|
20039
|
-
kind: import_src$
|
|
20518
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20040
20519
|
submodule: "document",
|
|
20041
20520
|
packageType: PackageType.FIRESTORE,
|
|
20042
20521
|
packageName: PACKAGE_NAME,
|
|
@@ -20048,7 +20527,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20048
20527
|
return self._handleRecordDocumentWrite(spanInfo, originalDelete, this, precondition);
|
|
20049
20528
|
});
|
|
20050
20529
|
},
|
|
20051
|
-
spanKind: import_src$
|
|
20530
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20052
20531
|
});
|
|
20053
20532
|
else return originalDelete.call(this, precondition);
|
|
20054
20533
|
};
|
|
@@ -20062,7 +20541,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20062
20541
|
} : void 0 };
|
|
20063
20542
|
try {
|
|
20064
20543
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: result });
|
|
20065
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20544
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20066
20545
|
} catch {
|
|
20067
20546
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for document.write`);
|
|
20068
20547
|
}
|
|
@@ -20079,7 +20558,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20079
20558
|
packageName: PACKAGE_NAME,
|
|
20080
20559
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20081
20560
|
submoduleName: "document",
|
|
20082
|
-
kind: import_src$
|
|
20561
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20083
20562
|
},
|
|
20084
20563
|
tuskDrift: this.tuskDrift
|
|
20085
20564
|
});
|
|
@@ -20111,7 +20590,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20111
20590
|
replayModeHandler: () => {
|
|
20112
20591
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalAdd.call(this, data), {
|
|
20113
20592
|
name: "firestore.collection.add",
|
|
20114
|
-
kind: import_src$
|
|
20593
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20115
20594
|
submodule: "collection",
|
|
20116
20595
|
packageType: PackageType.FIRESTORE,
|
|
20117
20596
|
packageName: PACKAGE_NAME,
|
|
@@ -20129,7 +20608,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20129
20608
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20130
20609
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalAdd.call(this, data), {
|
|
20131
20610
|
name: "firestore.collection.add",
|
|
20132
|
-
kind: import_src$
|
|
20611
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20133
20612
|
submodule: "collection",
|
|
20134
20613
|
packageType: PackageType.FIRESTORE,
|
|
20135
20614
|
packageName: PACKAGE_NAME,
|
|
@@ -20141,7 +20620,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20141
20620
|
return self._handleRecordCollectionAdd(spanInfo, originalAdd, this, data);
|
|
20142
20621
|
});
|
|
20143
20622
|
},
|
|
20144
|
-
spanKind: import_src$
|
|
20623
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20145
20624
|
});
|
|
20146
20625
|
else return originalAdd.call(this, data);
|
|
20147
20626
|
};
|
|
@@ -20155,7 +20634,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20155
20634
|
};
|
|
20156
20635
|
try {
|
|
20157
20636
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: result });
|
|
20158
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20637
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20159
20638
|
} catch {
|
|
20160
20639
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for collection.add`);
|
|
20161
20640
|
}
|
|
@@ -20172,7 +20651,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20172
20651
|
packageName: PACKAGE_NAME,
|
|
20173
20652
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20174
20653
|
submoduleName: "collection",
|
|
20175
|
-
kind: import_src$
|
|
20654
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20176
20655
|
},
|
|
20177
20656
|
tuskDrift: this.tuskDrift
|
|
20178
20657
|
});
|
|
@@ -20205,7 +20684,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20205
20684
|
replayModeHandler: () => {
|
|
20206
20685
|
return SpanUtils.createAndExecuteSpan(self.mode, () => documentPath ? originalDoc.call(this, documentPath) : originalDoc.call(this), {
|
|
20207
20686
|
name: "firestore.collection.doc",
|
|
20208
|
-
kind: import_src$
|
|
20687
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20209
20688
|
submodule: "collection",
|
|
20210
20689
|
packageType: PackageType.FIRESTORE,
|
|
20211
20690
|
packageName: PACKAGE_NAME,
|
|
@@ -20223,7 +20702,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20223
20702
|
packageName: PACKAGE_NAME,
|
|
20224
20703
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
20225
20704
|
submoduleName: "collection",
|
|
20226
|
-
kind: import_src$
|
|
20705
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20227
20706
|
},
|
|
20228
20707
|
tuskDrift: self.tuskDrift
|
|
20229
20708
|
});
|
|
@@ -20244,7 +20723,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20244
20723
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20245
20724
|
return SpanUtils.createAndExecuteSpan(self.mode, () => documentPath ? originalDoc.call(this, documentPath) : originalDoc.call(this), {
|
|
20246
20725
|
name: "firestore.collection.doc",
|
|
20247
|
-
kind: import_src$
|
|
20726
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20248
20727
|
submodule: "collection",
|
|
20249
20728
|
packageType: PackageType.FIRESTORE,
|
|
20250
20729
|
packageName: PACKAGE_NAME,
|
|
@@ -20260,14 +20739,14 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20260
20739
|
};
|
|
20261
20740
|
try {
|
|
20262
20741
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: result });
|
|
20263
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20742
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20264
20743
|
} catch {
|
|
20265
20744
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for collection.doc`);
|
|
20266
20745
|
}
|
|
20267
20746
|
return docRef;
|
|
20268
20747
|
});
|
|
20269
20748
|
},
|
|
20270
|
-
spanKind: import_src$
|
|
20749
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20271
20750
|
});
|
|
20272
20751
|
else return documentPath ? originalDoc.call(this, documentPath) : originalDoc.call(this);
|
|
20273
20752
|
};
|
|
@@ -20293,7 +20772,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20293
20772
|
replayModeHandler: () => {
|
|
20294
20773
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
20295
20774
|
name: "firestore.query.get",
|
|
20296
|
-
kind: import_src$
|
|
20775
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20297
20776
|
submodule: "query",
|
|
20298
20777
|
packageType: PackageType.FIRESTORE,
|
|
20299
20778
|
packageName: PACKAGE_NAME,
|
|
@@ -20311,7 +20790,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20311
20790
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20312
20791
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
20313
20792
|
name: "firestore.query.get",
|
|
20314
|
-
kind: import_src$
|
|
20793
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20315
20794
|
submodule: "query",
|
|
20316
20795
|
packageType: PackageType.FIRESTORE,
|
|
20317
20796
|
packageName: PACKAGE_NAME,
|
|
@@ -20323,7 +20802,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20323
20802
|
return self._handleRecordQueryGet(spanInfo, originalGet, this);
|
|
20324
20803
|
});
|
|
20325
20804
|
},
|
|
20326
|
-
spanKind: import_src$
|
|
20805
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20327
20806
|
});
|
|
20328
20807
|
else return originalGet.call(this);
|
|
20329
20808
|
};
|
|
@@ -20359,7 +20838,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20359
20838
|
};
|
|
20360
20839
|
try {
|
|
20361
20840
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: queryResult });
|
|
20362
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20841
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20363
20842
|
} catch {
|
|
20364
20843
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for query.get`);
|
|
20365
20844
|
}
|
|
@@ -20376,7 +20855,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20376
20855
|
packageName: PACKAGE_NAME,
|
|
20377
20856
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20378
20857
|
submoduleName: "query",
|
|
20379
|
-
kind: import_src$
|
|
20858
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20380
20859
|
},
|
|
20381
20860
|
tuskDrift: this.tuskDrift
|
|
20382
20861
|
});
|
|
@@ -20399,7 +20878,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20399
20878
|
|
|
20400
20879
|
//#endregion
|
|
20401
20880
|
//#region src/instrumentation/libraries/nextjs/Instrumentation.ts
|
|
20402
|
-
var import_src$
|
|
20881
|
+
var import_src$13 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
20403
20882
|
var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
20404
20883
|
constructor(config = {}) {
|
|
20405
20884
|
super("nextjs", config);
|
|
@@ -20485,10 +20964,10 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20485
20964
|
logger.debug(`[NextjsInstrumentation] Setting replay trace id`, replayTraceId);
|
|
20486
20965
|
const ctxWithReplayTraceId = SpanUtils.setCurrentReplayTraceId(replayTraceId);
|
|
20487
20966
|
if (!ctxWithReplayTraceId) throw new Error("Error setting current replay trace id");
|
|
20488
|
-
return import_src$
|
|
20967
|
+
return import_src$13.context.with(ctxWithReplayTraceId, () => {
|
|
20489
20968
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalHandleRequest.call(this, req, res, parsedUrl), {
|
|
20490
20969
|
name: url,
|
|
20491
|
-
kind: import_src$
|
|
20970
|
+
kind: import_src$13.SpanKind.SERVER,
|
|
20492
20971
|
packageName: "nextjs",
|
|
20493
20972
|
submodule: method,
|
|
20494
20973
|
packageType: PackageType.HTTP,
|
|
@@ -20524,7 +21003,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20524
21003
|
};
|
|
20525
21004
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalHandleRequest.call(this, req, res, parsedUrl), {
|
|
20526
21005
|
name: url,
|
|
20527
|
-
kind: import_src$
|
|
21006
|
+
kind: import_src$13.SpanKind.SERVER,
|
|
20528
21007
|
packageName: "nextjs",
|
|
20529
21008
|
packageType: PackageType.HTTP,
|
|
20530
21009
|
submodule: method,
|
|
@@ -20544,7 +21023,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20544
21023
|
});
|
|
20545
21024
|
});
|
|
20546
21025
|
},
|
|
20547
|
-
spanKind: import_src$
|
|
21026
|
+
spanKind: import_src$13.SpanKind.SERVER
|
|
20548
21027
|
});
|
|
20549
21028
|
} else return originalHandleRequest.call(this, req, res, parsedUrl);
|
|
20550
21029
|
};
|
|
@@ -20552,8 +21031,8 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20552
21031
|
}
|
|
20553
21032
|
async _handleNextjsRequestInSpan({ req, res, parsedUrl, originalHandleRequest, spanInfo, inputValue, thisContext }) {
|
|
20554
21033
|
const self = this;
|
|
20555
|
-
import_src$
|
|
20556
|
-
import_src$
|
|
21034
|
+
import_src$13.context.bind(spanInfo.context, req);
|
|
21035
|
+
import_src$13.context.bind(spanInfo.context, res);
|
|
20557
21036
|
let completeInputValue = inputValue;
|
|
20558
21037
|
this._captureRequestBody(req, spanInfo, inputValue, (updatedInputValue) => {
|
|
20559
21038
|
completeInputValue = updatedInputValue;
|
|
@@ -20594,7 +21073,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20594
21073
|
logger.error(`[NextjsInstrumentation] Error in Next.js request: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
20595
21074
|
try {
|
|
20596
21075
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20597
|
-
code: import_src$
|
|
21076
|
+
code: import_src$13.SpanStatusCode.ERROR,
|
|
20598
21077
|
message: error instanceof Error ? error.message : "Unknown error"
|
|
20599
21078
|
});
|
|
20600
21079
|
} catch (e) {
|
|
@@ -20640,9 +21119,9 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20640
21119
|
}
|
|
20641
21120
|
});
|
|
20642
21121
|
const status = (capturedStatusCode || 200) >= 300 ? {
|
|
20643
|
-
code: import_src$
|
|
21122
|
+
code: import_src$13.SpanStatusCode.ERROR,
|
|
20644
21123
|
message: `HTTP ${capturedStatusCode}`
|
|
20645
|
-
} : { code: import_src$
|
|
21124
|
+
} : { code: import_src$13.SpanStatusCode.OK };
|
|
20646
21125
|
SpanUtils.setStatus(spanInfo.span, status);
|
|
20647
21126
|
const decodedType = getDecodedType(outputValue.headers?.["content-type"] || "");
|
|
20648
21127
|
if (decodedType && !ACCEPTABLE_CONTENT_TYPES.has(decodedType)) {
|
|
@@ -20684,7 +21163,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20684
21163
|
outputSchemaHash: JsonSchemaHelper.generateDeterministicHash(outputSchema),
|
|
20685
21164
|
inputValueHash,
|
|
20686
21165
|
outputValueHash,
|
|
20687
|
-
kind: import_src$
|
|
21166
|
+
kind: import_src$13.SpanKind.SERVER,
|
|
20688
21167
|
packageType: PackageType.HTTP,
|
|
20689
21168
|
status: {
|
|
20690
21169
|
code: (capturedStatusCode || 200) >= 300 ? StatusCode.ERROR : StatusCode.OK,
|
|
@@ -20710,7 +21189,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20710
21189
|
logger.error(`[NextjsInstrumentation] Error in Next.js request: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
20711
21190
|
try {
|
|
20712
21191
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20713
|
-
code: import_src$
|
|
21192
|
+
code: import_src$13.SpanStatusCode.ERROR,
|
|
20714
21193
|
message: error instanceof Error ? error.message : "Unknown error"
|
|
20715
21194
|
});
|
|
20716
21195
|
} catch (e) {
|
|
@@ -20804,7 +21283,7 @@ let PrismaErrorClassName = /* @__PURE__ */ function(PrismaErrorClassName$1) {
|
|
|
20804
21283
|
|
|
20805
21284
|
//#endregion
|
|
20806
21285
|
//#region src/instrumentation/libraries/prisma/Instrumentation.ts
|
|
20807
|
-
var import_src$
|
|
21286
|
+
var import_src$12 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
20808
21287
|
var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
20809
21288
|
constructor(config = {}) {
|
|
20810
21289
|
super("@prisma/client", config);
|
|
@@ -20890,7 +21369,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20890
21369
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20891
21370
|
return SpanUtils.createAndExecuteSpan(this.mode, () => query(args), {
|
|
20892
21371
|
name: `prisma.${operation}`,
|
|
20893
|
-
kind: import_src$
|
|
21372
|
+
kind: import_src$12.SpanKind.CLIENT,
|
|
20894
21373
|
submodule: model,
|
|
20895
21374
|
packageType: PackageType.PRISMA,
|
|
20896
21375
|
packageName: "@prisma/client",
|
|
@@ -20901,7 +21380,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20901
21380
|
return this._handleRecordPrismaOperation(spanInfo, query, args);
|
|
20902
21381
|
});
|
|
20903
21382
|
},
|
|
20904
|
-
spanKind: import_src$
|
|
21383
|
+
spanKind: import_src$12.SpanKind.CLIENT
|
|
20905
21384
|
});
|
|
20906
21385
|
else if (this.mode === TuskDriftMode.REPLAY) {
|
|
20907
21386
|
const stackTrace = captureStackTrace(["PrismaInstrumentation"]);
|
|
@@ -20911,7 +21390,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20911
21390
|
replayModeHandler: () => {
|
|
20912
21391
|
return SpanUtils.createAndExecuteSpan(this.mode, () => query(args), {
|
|
20913
21392
|
name: `prisma.${operation}`,
|
|
20914
|
-
kind: import_src$
|
|
21393
|
+
kind: import_src$12.SpanKind.CLIENT,
|
|
20915
21394
|
submodule: model,
|
|
20916
21395
|
packageType: PackageType.PRISMA,
|
|
20917
21396
|
packageName: "@prisma/client",
|
|
@@ -20935,7 +21414,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20935
21414
|
};
|
|
20936
21415
|
try {
|
|
20937
21416
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
20938
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
21417
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$12.SpanStatusCode.OK });
|
|
20939
21418
|
} catch (spanError) {
|
|
20940
21419
|
logger.error(`[PrismaInstrumentation] error adding span attributes:`, spanError);
|
|
20941
21420
|
}
|
|
@@ -20952,7 +21431,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20952
21431
|
};
|
|
20953
21432
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
20954
21433
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20955
|
-
code: import_src$
|
|
21434
|
+
code: import_src$12.SpanStatusCode.ERROR,
|
|
20956
21435
|
message: error.message
|
|
20957
21436
|
});
|
|
20958
21437
|
} catch (spanError) {
|
|
@@ -20971,7 +21450,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20971
21450
|
packageName: "@prisma/client",
|
|
20972
21451
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20973
21452
|
submoduleName: inputValue.model,
|
|
20974
|
-
kind: import_src$
|
|
21453
|
+
kind: import_src$12.SpanKind.CLIENT,
|
|
20975
21454
|
stackTrace
|
|
20976
21455
|
},
|
|
20977
21456
|
tuskDrift: this.tuskDrift
|
|
@@ -20989,12 +21468,12 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20989
21468
|
if (errorClass) Object.setPrototypeOf(errorObj, errorClass.prototype);
|
|
20990
21469
|
}
|
|
20991
21470
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20992
|
-
code: import_src$
|
|
21471
|
+
code: import_src$12.SpanStatusCode.ERROR,
|
|
20993
21472
|
message: errorObj.message || "Prisma error"
|
|
20994
21473
|
});
|
|
20995
21474
|
throw errorObj;
|
|
20996
21475
|
}
|
|
20997
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
21476
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$12.SpanStatusCode.OK });
|
|
20998
21477
|
return outputValue.prismaResult;
|
|
20999
21478
|
}
|
|
21000
21479
|
_getPrismaErrorClassName(error) {
|
|
@@ -25155,8 +25634,8 @@ var require_src$6 = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/co
|
|
|
25155
25634
|
|
|
25156
25635
|
//#endregion
|
|
25157
25636
|
//#region src/core/tracing/SpanTransformer.ts
|
|
25158
|
-
var import_src$
|
|
25159
|
-
var import_src$
|
|
25637
|
+
var import_src$10 = /* @__PURE__ */ __toESM(require_src$6(), 1);
|
|
25638
|
+
var import_src$11 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
25160
25639
|
/**
|
|
25161
25640
|
* Utility class for transforming OpenTelemetry spans to CleanSpanData
|
|
25162
25641
|
*/
|
|
@@ -25167,7 +25646,7 @@ var SpanTransformer = class SpanTransformer {
|
|
|
25167
25646
|
* We use JSON because serialized protobuf is extremely verbose and not readable.
|
|
25168
25647
|
*/
|
|
25169
25648
|
static transformSpanToCleanJSON(span, environment) {
|
|
25170
|
-
const isRootSpan =
|
|
25649
|
+
const isRootSpan = span.kind === import_src$11.SpanKind.SERVER;
|
|
25171
25650
|
const attributes = span.attributes;
|
|
25172
25651
|
const packageName = SpanTransformer.extractPackageName(attributes);
|
|
25173
25652
|
const instrumentationName = SpanTransformer.extractInstrumentationName(span, attributes);
|
|
@@ -25287,11 +25766,11 @@ var FilesystemSpanAdapter = class {
|
|
|
25287
25766
|
fs.appendFileSync(filePath, jsonLine, "utf8");
|
|
25288
25767
|
}
|
|
25289
25768
|
logger.debug(`Exported ${spans.length} span(s) to trace-specific files in ${this.baseDirectory}`);
|
|
25290
|
-
return { code: import_src$
|
|
25769
|
+
return { code: import_src$10.ExportResultCode.SUCCESS };
|
|
25291
25770
|
} catch (error) {
|
|
25292
25771
|
logger.error(`Failed to export spans to local files:`, error);
|
|
25293
25772
|
return {
|
|
25294
|
-
code: import_src$
|
|
25773
|
+
code: import_src$10.ExportResultCode.FAILED,
|
|
25295
25774
|
error: error instanceof Error ? error : /* @__PURE__ */ new Error("Filesystem export failed")
|
|
25296
25775
|
};
|
|
25297
25776
|
}
|
|
@@ -25646,9 +26125,9 @@ var require_commonjs = /* @__PURE__ */ __commonJS({ "node_modules/@protobuf-ts/t
|
|
|
25646
26125
|
|
|
25647
26126
|
//#endregion
|
|
25648
26127
|
//#region src/core/tracing/adapters/ApiSpanAdapter.ts
|
|
25649
|
-
var import_src$
|
|
26128
|
+
var import_src$8 = /* @__PURE__ */ __toESM(require_src$6(), 1);
|
|
25650
26129
|
var import_commonjs$2 = /* @__PURE__ */ __toESM(require_commonjs(), 1);
|
|
25651
|
-
var import_src$
|
|
26130
|
+
var import_src$9 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
25652
26131
|
const DRIFT_API_PATH = "/api/drift";
|
|
25653
26132
|
/**
|
|
25654
26133
|
* Exports spans to Tusk backend API via protobuf
|
|
@@ -25682,11 +26161,11 @@ var ApiSpanAdapter = class {
|
|
|
25682
26161
|
const response = await this.spanExportClient.exportSpans(request);
|
|
25683
26162
|
if (!response.response.success) throw new Error(`Remote export failed: ${response.response.message}`);
|
|
25684
26163
|
logger.debug(`Successfully exported ${spans.length} spans to remote endpoint`);
|
|
25685
|
-
return { code: import_src$
|
|
26164
|
+
return { code: import_src$8.ExportResultCode.SUCCESS };
|
|
25686
26165
|
} catch (error) {
|
|
25687
26166
|
logger.error(`Failed to export spans to remote:`, error);
|
|
25688
26167
|
return {
|
|
25689
|
-
code: import_src$
|
|
26168
|
+
code: import_src$8.ExportResultCode.FAILED,
|
|
25690
26169
|
error: error instanceof Error ? error : /* @__PURE__ */ new Error("API export failed")
|
|
25691
26170
|
};
|
|
25692
26171
|
}
|
|
@@ -25727,12 +26206,12 @@ var ApiSpanAdapter = class {
|
|
|
25727
26206
|
}
|
|
25728
26207
|
mapSpanKind(kind) {
|
|
25729
26208
|
switch (kind) {
|
|
25730
|
-
case import_src$
|
|
25731
|
-
case import_src$
|
|
25732
|
-
case import_src$
|
|
25733
|
-
case import_src$
|
|
25734
|
-
case import_src$
|
|
25735
|
-
default: return SpanKind$
|
|
26209
|
+
case import_src$9.SpanKind.CLIENT: return SpanKind$2.CLIENT;
|
|
26210
|
+
case import_src$9.SpanKind.SERVER: return SpanKind$2.SERVER;
|
|
26211
|
+
case import_src$9.SpanKind.PRODUCER: return SpanKind$2.PRODUCER;
|
|
26212
|
+
case import_src$9.SpanKind.CONSUMER: return SpanKind$2.CONSUMER;
|
|
26213
|
+
case import_src$9.SpanKind.INTERNAL: return SpanKind$2.INTERNAL;
|
|
26214
|
+
default: return SpanKind$2.UNSPECIFIED;
|
|
25736
26215
|
}
|
|
25737
26216
|
}
|
|
25738
26217
|
async shutdown() {
|
|
@@ -25743,6 +26222,8 @@ var ApiSpanAdapter = class {
|
|
|
25743
26222
|
//#endregion
|
|
25744
26223
|
//#region src/core/tracing/TdSpanExporter.ts
|
|
25745
26224
|
var import_src$5 = /* @__PURE__ */ __toESM(require_src$6(), 1);
|
|
26225
|
+
var import_src$6 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
26226
|
+
var import_src$7 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
25746
26227
|
var TdSpanExporter = class {
|
|
25747
26228
|
constructor(config) {
|
|
25748
26229
|
this.adapters = [];
|
|
@@ -25795,15 +26276,13 @@ var TdSpanExporter = class {
|
|
|
25795
26276
|
logger.debug("All adapters cleared");
|
|
25796
26277
|
}
|
|
25797
26278
|
/**
|
|
25798
|
-
* Set the mode for determining which adapters to run
|
|
25799
|
-
*/
|
|
25800
|
-
setMode(mode) {
|
|
25801
|
-
this.mode = mode;
|
|
25802
|
-
}
|
|
25803
|
-
/**
|
|
25804
26279
|
* Export spans using all configured adapters
|
|
25805
26280
|
*/
|
|
25806
26281
|
export(spans, resultCallback) {
|
|
26282
|
+
if (this.mode !== TuskDriftMode.RECORD) {
|
|
26283
|
+
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
26284
|
+
return;
|
|
26285
|
+
}
|
|
25807
26286
|
logger.debug(`TdSpanExporter.export() called with ${spans.length} span(s)`);
|
|
25808
26287
|
const traceBlockingManager = TraceBlockingManager.getInstance();
|
|
25809
26288
|
const filteredSpansBasedOnLibraryName = spans.filter((span) => {
|
|
@@ -25819,6 +26298,11 @@ var TdSpanExporter = class {
|
|
|
25819
26298
|
logger.debug(`Skipping span '${span.name}' (${span.spanContext().spanId}) - trace ${traceId} is blocked`);
|
|
25820
26299
|
return false;
|
|
25821
26300
|
}
|
|
26301
|
+
if (span.kind === import_src$7.SpanKind.SERVER && span.status.code === import_src$6.SpanStatusCode.ERROR) {
|
|
26302
|
+
traceBlockingManager.blockTrace(traceId);
|
|
26303
|
+
logger.debug(`Blocking trace ${traceId} - server span has error status`);
|
|
26304
|
+
return false;
|
|
26305
|
+
}
|
|
25822
26306
|
const inputValueString = span.attributes[TdSpanAttributes.INPUT_VALUE] || "";
|
|
25823
26307
|
const outputValueString = span.attributes[TdSpanAttributes.OUTPUT_VALUE] || "";
|
|
25824
26308
|
const estimatedTotalSize = Buffer.byteLength(inputValueString, "utf8") + Buffer.byteLength(outputValueString, "utf8") + 5e4;
|
|
@@ -25837,21 +26321,16 @@ var TdSpanExporter = class {
|
|
|
25837
26321
|
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
25838
26322
|
return;
|
|
25839
26323
|
}
|
|
25840
|
-
|
|
25841
|
-
if (activeAdapters.length === 0) {
|
|
26324
|
+
if (this.adapters.length === 0) {
|
|
25842
26325
|
logger.debug(`No active adapters for mode: ${this.mode}`);
|
|
25843
26326
|
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
25844
26327
|
return;
|
|
25845
26328
|
}
|
|
25846
|
-
Promise.all(
|
|
26329
|
+
Promise.all(this.adapters.map((adapter) => adapter.exportSpans(cleanSpans))).then(() => resultCallback({ code: import_src$5.ExportResultCode.SUCCESS })).catch((error) => resultCallback({
|
|
25847
26330
|
code: import_src$5.ExportResultCode.FAILED,
|
|
25848
26331
|
error
|
|
25849
26332
|
}));
|
|
25850
26333
|
}
|
|
25851
|
-
getActiveAdapters() {
|
|
25852
|
-
if (this.mode !== TuskDriftMode.RECORD) return this.adapters.filter((adapter) => adapter.name === "in-memory" || adapter.name === "callback");
|
|
25853
|
-
return this.adapters;
|
|
25854
|
-
}
|
|
25855
26334
|
/**
|
|
25856
26335
|
* Shutdown all adapters
|
|
25857
26336
|
*/
|
|
@@ -32982,7 +33461,7 @@ var require_src = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/sdk-
|
|
|
32982
33461
|
//#endregion
|
|
32983
33462
|
//#region package.json
|
|
32984
33463
|
var import_src$1 = /* @__PURE__ */ __toESM(require_src(), 1);
|
|
32985
|
-
var version = "0.1.
|
|
33464
|
+
var version = "0.1.22";
|
|
32986
33465
|
|
|
32987
33466
|
//#endregion
|
|
32988
33467
|
//#region src/version.ts
|
|
@@ -34881,14 +35360,8 @@ var TuskDriftCore = class TuskDriftCore {
|
|
|
34881
35360
|
logger.debug(`Using TCP connection to CLI: ${mockHost}:${mockPort}`);
|
|
34882
35361
|
} else {
|
|
34883
35362
|
const socketPath = mockSocket || path.default.join(os.default.tmpdir(), "tusk-connect.sock");
|
|
34884
|
-
|
|
34885
|
-
|
|
34886
|
-
if (!fs.default.statSync(socketPath).isSocket()) throw new Error(`Path exists but is not a socket: ${socketPath}`);
|
|
34887
|
-
logger.debug("Socket found and verified at", socketPath);
|
|
34888
|
-
} catch (error) {
|
|
34889
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") throw new Error(`Socket not found at ${socketPath}. Make sure Tusk CLI is running.`);
|
|
34890
|
-
throw new Error(`Socket check failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
34891
|
-
}
|
|
35363
|
+
if (!fs.default.existsSync(socketPath)) throw new Error(`Socket not found at ${socketPath}. Make sure Tusk CLI is running.`);
|
|
35364
|
+
logger.debug("Socket found at", socketPath);
|
|
34892
35365
|
connectionInfo = { socketPath };
|
|
34893
35366
|
}
|
|
34894
35367
|
this.cliConnectionPromise = this.communicator.connect(connectionInfo, this.config.service?.id || "unknown").then(() => {
|