@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.js
CHANGED
|
@@ -151,7 +151,8 @@ function warn(suppress, message) {
|
|
|
151
151
|
*
|
|
152
152
|
* This function automatically configures Next.js to work with Tusk Drift by:
|
|
153
153
|
* - Enabling the Next.js instrumentation hook (for Next.js < 15.0.0-rc.1)
|
|
154
|
-
* - Configuring
|
|
154
|
+
* - Configuring server external packages to prevent bundling of core instrumentation packages
|
|
155
|
+
* - Supporting both webpack and Turbopack bundlers
|
|
155
156
|
* - Preserving your existing Next.js configuration and webpack customizations
|
|
156
157
|
*
|
|
157
158
|
* @param nextConfig - Your existing Next.js configuration object (optional)
|
|
@@ -186,9 +187,12 @@ function warn(suppress, message) {
|
|
|
186
187
|
* ```
|
|
187
188
|
*
|
|
188
189
|
* @remarks
|
|
189
|
-
* The following
|
|
190
|
+
* The following packages are added as server externals for both webpack and Turbopack:
|
|
190
191
|
* - `require-in-the-middle` - Required for CommonJS module interception
|
|
191
192
|
* - `jsonpath` - Required for schema manipulation
|
|
193
|
+
* - Additional packages when TUSK_DRIFT_MODE is RECORD or REPLAY (e.g., database clients, etc.)
|
|
194
|
+
*
|
|
195
|
+
* Works with both webpack (default) and Turbopack (`next dev --turbo`).
|
|
192
196
|
*/
|
|
193
197
|
function withTuskDrift(nextConfig = {}, options = {}) {
|
|
194
198
|
const config = nextConfig;
|
|
@@ -198,33 +202,34 @@ function withTuskDrift(nextConfig = {}, options = {}) {
|
|
|
198
202
|
if (nextjsVersion) debugLog(debug, `Detected Next.js version: ${nextjsVersion}`);
|
|
199
203
|
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.");
|
|
200
204
|
const needsInstrumentationHook = !options.disableInstrumentationHook && shouldSetInstrumentationHook(nextjsVersion);
|
|
205
|
+
const mode = process.env.TUSK_DRIFT_MODE?.toUpperCase();
|
|
206
|
+
const coreExternals = [
|
|
207
|
+
"require-in-the-middle",
|
|
208
|
+
"jsonpath",
|
|
209
|
+
...mode === "RECORD" || mode === "REPLAY" ? [
|
|
210
|
+
"@upstash/redis",
|
|
211
|
+
"ioredis",
|
|
212
|
+
"pg",
|
|
213
|
+
"postgres",
|
|
214
|
+
"mysql2",
|
|
215
|
+
"@prisma/client",
|
|
216
|
+
"@google-cloud/firestore",
|
|
217
|
+
"@grpc/grpc-js",
|
|
218
|
+
"graphql",
|
|
219
|
+
"jsonwebtoken",
|
|
220
|
+
"jwks-rsa"
|
|
221
|
+
] : []
|
|
222
|
+
];
|
|
201
223
|
const wrappedConfig = {
|
|
202
224
|
...config,
|
|
203
225
|
...needsInstrumentationHook ? { experimental: {
|
|
204
226
|
...config.experimental,
|
|
205
227
|
instrumentationHook: true
|
|
206
228
|
} } : { experimental: config.experimental },
|
|
229
|
+
serverExternalPackages: [...config.serverExternalPackages || [], ...coreExternals],
|
|
207
230
|
webpack: (webpackConfig, webpackOptions) => {
|
|
208
231
|
if (webpackOptions.isServer) {
|
|
209
232
|
const originalExternals = webpackConfig.externals;
|
|
210
|
-
const mode = process.env.TUSK_DRIFT_MODE?.toUpperCase();
|
|
211
|
-
const coreExternals = [
|
|
212
|
-
"require-in-the-middle",
|
|
213
|
-
"jsonpath",
|
|
214
|
-
...mode === "RECORD" || mode === "REPLAY" ? [
|
|
215
|
-
"@upstash/redis",
|
|
216
|
-
"ioredis",
|
|
217
|
-
"pg",
|
|
218
|
-
"postgres",
|
|
219
|
-
"mysql2",
|
|
220
|
-
"@prisma/client",
|
|
221
|
-
"@google-cloud/firestore",
|
|
222
|
-
"@grpc/grpc-js",
|
|
223
|
-
"graphql",
|
|
224
|
-
"jsonwebtoken",
|
|
225
|
-
"jwks-rsa"
|
|
226
|
-
] : []
|
|
227
|
-
];
|
|
228
233
|
const externalsMapping = {};
|
|
229
234
|
for (const pkg of coreExternals) {
|
|
230
235
|
externalsMapping[pkg] = `commonjs ${pkg}`;
|
|
@@ -4978,31 +4983,31 @@ var require_SamplingResult = /* @__PURE__ */ __commonJS({ "node_modules/@opentel
|
|
|
4978
4983
|
var require_span_kind = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/api/build/src/trace/span_kind.js": ((exports) => {
|
|
4979
4984
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4980
4985
|
exports.SpanKind = void 0;
|
|
4981
|
-
(function(SpanKind$
|
|
4986
|
+
(function(SpanKind$27) {
|
|
4982
4987
|
/** Default value. Indicates that the span is used internally. */
|
|
4983
|
-
SpanKind$
|
|
4988
|
+
SpanKind$27[SpanKind$27["INTERNAL"] = 0] = "INTERNAL";
|
|
4984
4989
|
/**
|
|
4985
4990
|
* Indicates that the span covers server-side handling of an RPC or other
|
|
4986
4991
|
* remote request.
|
|
4987
4992
|
*/
|
|
4988
|
-
SpanKind$
|
|
4993
|
+
SpanKind$27[SpanKind$27["SERVER"] = 1] = "SERVER";
|
|
4989
4994
|
/**
|
|
4990
4995
|
* Indicates that the span covers the client-side wrapper around an RPC or
|
|
4991
4996
|
* other remote request.
|
|
4992
4997
|
*/
|
|
4993
|
-
SpanKind$
|
|
4998
|
+
SpanKind$27[SpanKind$27["CLIENT"] = 2] = "CLIENT";
|
|
4994
4999
|
/**
|
|
4995
5000
|
* Indicates that the span describes producer sending a message to a
|
|
4996
5001
|
* broker. Unlike client and server, there is no direct critical path latency
|
|
4997
5002
|
* relationship between producer and consumer spans.
|
|
4998
5003
|
*/
|
|
4999
|
-
SpanKind$
|
|
5004
|
+
SpanKind$27[SpanKind$27["PRODUCER"] = 3] = "PRODUCER";
|
|
5000
5005
|
/**
|
|
5001
5006
|
* Indicates that the span describes consumer receiving a message from a
|
|
5002
5007
|
* broker. Unlike client and server, there is no direct critical path latency
|
|
5003
5008
|
* relationship between producer and consumer spans.
|
|
5004
5009
|
*/
|
|
5005
|
-
SpanKind$
|
|
5010
|
+
SpanKind$27[SpanKind$27["CONSUMER"] = 4] = "CONSUMER";
|
|
5006
5011
|
})(exports.SpanKind || (exports.SpanKind = {}));
|
|
5007
5012
|
}) });
|
|
5008
5013
|
|
|
@@ -5011,20 +5016,20 @@ var require_span_kind = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetr
|
|
|
5011
5016
|
var require_status = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/api/build/src/trace/status.js": ((exports) => {
|
|
5012
5017
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5013
5018
|
exports.SpanStatusCode = void 0;
|
|
5014
|
-
(function(SpanStatusCode$
|
|
5019
|
+
(function(SpanStatusCode$16) {
|
|
5015
5020
|
/**
|
|
5016
5021
|
* The default status.
|
|
5017
5022
|
*/
|
|
5018
|
-
SpanStatusCode$
|
|
5023
|
+
SpanStatusCode$16[SpanStatusCode$16["UNSET"] = 0] = "UNSET";
|
|
5019
5024
|
/**
|
|
5020
5025
|
* The operation has been validated by an Application developer or
|
|
5021
5026
|
* Operator to have completed successfully.
|
|
5022
5027
|
*/
|
|
5023
|
-
SpanStatusCode$
|
|
5028
|
+
SpanStatusCode$16[SpanStatusCode$16["OK"] = 1] = "OK";
|
|
5024
5029
|
/**
|
|
5025
5030
|
* The operation contains an error.
|
|
5026
5031
|
*/
|
|
5027
|
-
SpanStatusCode$
|
|
5032
|
+
SpanStatusCode$16[SpanStatusCode$16["ERROR"] = 2] = "ERROR";
|
|
5028
5033
|
})(exports.SpanStatusCode || (exports.SpanStatusCode = {}));
|
|
5029
5034
|
}) });
|
|
5030
5035
|
|
|
@@ -5673,7 +5678,7 @@ var require_src$7 = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/ap
|
|
|
5673
5678
|
|
|
5674
5679
|
//#endregion
|
|
5675
5680
|
//#region node_modules/@use-tusk/drift-schemas/dist/duration-B3fwb4jB.js
|
|
5676
|
-
var import_src$
|
|
5681
|
+
var import_src$37 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
5677
5682
|
var import_commonjs$9 = /* @__PURE__ */ __toESM(require_commonjs$2(), 1);
|
|
5678
5683
|
var Duration$Type = class extends import_commonjs$9.MessageType {
|
|
5679
5684
|
constructor() {
|
|
@@ -6284,7 +6289,7 @@ let PackageType = /* @__PURE__ */ function(PackageType$1) {
|
|
|
6284
6289
|
*
|
|
6285
6290
|
* @generated from protobuf enum tusk.drift.core.v1.SpanKind
|
|
6286
6291
|
*/
|
|
6287
|
-
let SpanKind$
|
|
6292
|
+
let SpanKind$2 = /* @__PURE__ */ function(SpanKind$1$1) {
|
|
6288
6293
|
/**
|
|
6289
6294
|
* @generated from protobuf enum value: SPAN_KIND_UNSPECIFIED = 0;
|
|
6290
6295
|
*/
|
|
@@ -6454,7 +6459,7 @@ var Span$Type = class extends import_commonjs$6.MessageType {
|
|
|
6454
6459
|
kind: "enum",
|
|
6455
6460
|
T: () => [
|
|
6456
6461
|
"tusk.drift.core.v1.SpanKind",
|
|
6457
|
-
SpanKind$
|
|
6462
|
+
SpanKind$2,
|
|
6458
6463
|
"SPAN_KIND_"
|
|
6459
6464
|
]
|
|
6460
6465
|
},
|
|
@@ -6997,12 +7002,12 @@ const Trace = new Trace$Type();
|
|
|
6997
7002
|
const toStruct = (obj) => obj ? objectToProtobufStruct(obj) : void 0;
|
|
6998
7003
|
const mapOtToPb = (k) => {
|
|
6999
7004
|
switch (k) {
|
|
7000
|
-
case import_src$
|
|
7001
|
-
case import_src$
|
|
7002
|
-
case import_src$
|
|
7003
|
-
case import_src$
|
|
7004
|
-
case import_src$
|
|
7005
|
-
default: return SpanKind$
|
|
7005
|
+
case import_src$37.SpanKind.INTERNAL: return SpanKind$2.INTERNAL;
|
|
7006
|
+
case import_src$37.SpanKind.SERVER: return SpanKind$2.SERVER;
|
|
7007
|
+
case import_src$37.SpanKind.CLIENT: return SpanKind$2.CLIENT;
|
|
7008
|
+
case import_src$37.SpanKind.PRODUCER: return SpanKind$2.PRODUCER;
|
|
7009
|
+
case import_src$37.SpanKind.CONSUMER: return SpanKind$2.CONSUMER;
|
|
7010
|
+
default: return SpanKind$2.UNSPECIFIED;
|
|
7006
7011
|
}
|
|
7007
7012
|
};
|
|
7008
7013
|
/**
|
|
@@ -7405,13 +7410,13 @@ var TdInstrumentationNodeModule = class {
|
|
|
7405
7410
|
|
|
7406
7411
|
//#endregion
|
|
7407
7412
|
//#region src/core/types.ts
|
|
7408
|
-
var import_src$
|
|
7413
|
+
var import_src$36 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
7409
7414
|
const TD_INSTRUMENTATION_LIBRARY_NAME = "tusk-drift-sdk";
|
|
7410
|
-
const REPLAY_TRACE_ID_CONTEXT_KEY = (0, import_src$
|
|
7411
|
-
const SPAN_KIND_CONTEXT_KEY = (0, import_src$
|
|
7412
|
-
const IS_PRE_APP_START_CONTEXT_KEY = (0, import_src$
|
|
7413
|
-
const STOP_RECORDING_CHILD_SPANS_CONTEXT_KEY = (0, import_src$
|
|
7414
|
-
const CALLING_LIBRARY_CONTEXT_KEY = (0, import_src$
|
|
7415
|
+
const REPLAY_TRACE_ID_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.replayTraceId");
|
|
7416
|
+
const SPAN_KIND_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.spanKind");
|
|
7417
|
+
const IS_PRE_APP_START_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.isPreAppStart");
|
|
7418
|
+
const STOP_RECORDING_CHILD_SPANS_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.stopRecordingChildSpans");
|
|
7419
|
+
const CALLING_LIBRARY_CONTEXT_KEY = (0, import_src$36.createContextKey)("td.callingLibrary");
|
|
7415
7420
|
let TdSpanAttributes = /* @__PURE__ */ function(TdSpanAttributes$1) {
|
|
7416
7421
|
/**
|
|
7417
7422
|
* Presentational information:
|
|
@@ -7523,7 +7528,7 @@ TraceBlockingManager.instance = null;
|
|
|
7523
7528
|
|
|
7524
7529
|
//#endregion
|
|
7525
7530
|
//#region src/core/tracing/SpanUtils.ts
|
|
7526
|
-
var import_src$
|
|
7531
|
+
var import_src$35 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
7527
7532
|
var SpanUtils = class SpanUtils {
|
|
7528
7533
|
/**
|
|
7529
7534
|
* Creates a new span and returns span info including trace ID and span ID
|
|
@@ -7531,8 +7536,8 @@ var SpanUtils = class SpanUtils {
|
|
|
7531
7536
|
static createSpan(options) {
|
|
7532
7537
|
try {
|
|
7533
7538
|
const tracer = TuskDriftCore.getInstance().getTracer();
|
|
7534
|
-
const parentContext = options.parentContext || import_src$
|
|
7535
|
-
const activeSpan = import_src$
|
|
7539
|
+
const parentContext = options.parentContext || import_src$35.context.active();
|
|
7540
|
+
const activeSpan = import_src$35.trace.getSpan(parentContext);
|
|
7536
7541
|
if (activeSpan) {
|
|
7537
7542
|
const parentTraceId = activeSpan.spanContext().traceId;
|
|
7538
7543
|
if (TraceBlockingManager.getInstance().isTraceBlocked(parentTraceId)) {
|
|
@@ -7541,11 +7546,11 @@ var SpanUtils = class SpanUtils {
|
|
|
7541
7546
|
}
|
|
7542
7547
|
}
|
|
7543
7548
|
const span = tracer.startSpan(options.name, {
|
|
7544
|
-
kind: options.kind || import_src$
|
|
7549
|
+
kind: options.kind || import_src$35.SpanKind.CLIENT,
|
|
7545
7550
|
attributes: options.attributes || {}
|
|
7546
7551
|
}, parentContext);
|
|
7547
7552
|
const spanContext = span.spanContext();
|
|
7548
|
-
const newContext = import_src$
|
|
7553
|
+
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);
|
|
7549
7554
|
return {
|
|
7550
7555
|
traceId: spanContext.traceId,
|
|
7551
7556
|
spanId: spanContext.spanId,
|
|
@@ -7562,7 +7567,7 @@ var SpanUtils = class SpanUtils {
|
|
|
7562
7567
|
* Executes a function within a span context
|
|
7563
7568
|
*/
|
|
7564
7569
|
static withSpan(spanInfo, fn) {
|
|
7565
|
-
return import_src$
|
|
7570
|
+
return import_src$35.context.with(spanInfo.context, fn);
|
|
7566
7571
|
}
|
|
7567
7572
|
/**
|
|
7568
7573
|
* Execute a function within a properly configured span
|
|
@@ -7579,9 +7584,9 @@ var SpanUtils = class SpanUtils {
|
|
|
7579
7584
|
* @returns The result of the function execution
|
|
7580
7585
|
*/
|
|
7581
7586
|
static createAndExecuteSpan(mode, originalFunctionCall, options, fn) {
|
|
7582
|
-
const spanContext = import_src$
|
|
7587
|
+
const spanContext = import_src$35.trace.getActiveSpan()?.spanContext();
|
|
7583
7588
|
if (spanContext) {
|
|
7584
|
-
if (import_src$
|
|
7589
|
+
if (import_src$35.context.active().getValue(STOP_RECORDING_CHILD_SPANS_CONTEXT_KEY)) {
|
|
7585
7590
|
logger.debug(`[SpanUtils] Stopping recording of child spans for span ${spanContext.spanId}, packageName: ${options.packageName}, instrumentationName: ${options.instrumentationName}`);
|
|
7586
7591
|
return originalFunctionCall();
|
|
7587
7592
|
}
|
|
@@ -7620,15 +7625,15 @@ var SpanUtils = class SpanUtils {
|
|
|
7620
7625
|
*/
|
|
7621
7626
|
static getCurrentSpanInfo() {
|
|
7622
7627
|
try {
|
|
7623
|
-
const activeSpan = import_src$
|
|
7628
|
+
const activeSpan = import_src$35.trace.getActiveSpan();
|
|
7624
7629
|
if (!activeSpan) return null;
|
|
7625
7630
|
const spanContext = activeSpan.spanContext();
|
|
7626
7631
|
return {
|
|
7627
7632
|
traceId: spanContext.traceId,
|
|
7628
7633
|
spanId: spanContext.spanId,
|
|
7629
7634
|
span: activeSpan,
|
|
7630
|
-
context: import_src$
|
|
7631
|
-
isPreAppStart: import_src$
|
|
7635
|
+
context: import_src$35.context.active(),
|
|
7636
|
+
isPreAppStart: import_src$35.context.active().getValue(IS_PRE_APP_START_CONTEXT_KEY)
|
|
7632
7637
|
};
|
|
7633
7638
|
} catch (error) {
|
|
7634
7639
|
logger.error("SpanUtils error getting current span info:", error);
|
|
@@ -7692,7 +7697,7 @@ var SpanUtils = class SpanUtils {
|
|
|
7692
7697
|
}
|
|
7693
7698
|
static setCurrentReplayTraceId(replayTraceId) {
|
|
7694
7699
|
try {
|
|
7695
|
-
return import_src$
|
|
7700
|
+
return import_src$35.context.active().setValue(REPLAY_TRACE_ID_CONTEXT_KEY, replayTraceId);
|
|
7696
7701
|
} catch (error) {
|
|
7697
7702
|
logger.error("SpanUtils error setting current replay trace id:", error);
|
|
7698
7703
|
return null;
|
|
@@ -7703,7 +7708,7 @@ var SpanUtils = class SpanUtils {
|
|
|
7703
7708
|
*/
|
|
7704
7709
|
static getCurrentReplayTraceId() {
|
|
7705
7710
|
try {
|
|
7706
|
-
return import_src$
|
|
7711
|
+
return import_src$35.context.active().getValue(REPLAY_TRACE_ID_CONTEXT_KEY);
|
|
7707
7712
|
} catch (error) {
|
|
7708
7713
|
logger.error("SpanUtils error getting current replay trace id:", error);
|
|
7709
7714
|
return null;
|
|
@@ -8352,7 +8357,7 @@ function findMockResponseSync({ mockRequestData, tuskDrift, inputValueSchemaMerg
|
|
|
8352
8357
|
|
|
8353
8358
|
//#endregion
|
|
8354
8359
|
//#region src/instrumentation/libraries/http/mocks/TdMockClientRequest.ts
|
|
8355
|
-
var import_src$
|
|
8360
|
+
var import_src$34 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
8356
8361
|
let ClientRequest;
|
|
8357
8362
|
/**
|
|
8358
8363
|
* Mock ClientRequest implementation for Tusk Drift HTTP replay
|
|
@@ -8523,7 +8528,7 @@ var TdMockClientRequest = class TdMockClientRequest extends EventEmitter {
|
|
|
8523
8528
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
8524
8529
|
submoduleName: rawInputValue.method,
|
|
8525
8530
|
inputValue,
|
|
8526
|
-
kind: import_src$
|
|
8531
|
+
kind: import_src$34.SpanKind.CLIENT,
|
|
8527
8532
|
stackTrace: this.stackTrace
|
|
8528
8533
|
},
|
|
8529
8534
|
tuskDrift: this.tuskDrift,
|
|
@@ -8693,7 +8698,7 @@ var HttpReplayHooks = class {
|
|
|
8693
8698
|
|
|
8694
8699
|
//#endregion
|
|
8695
8700
|
//#region src/instrumentation/core/utils/modeUtils.ts
|
|
8696
|
-
var import_src$
|
|
8701
|
+
var import_src$33 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
8697
8702
|
/**
|
|
8698
8703
|
* Utility function that abstracts the common record mode pattern of checking for current span context
|
|
8699
8704
|
* and deciding whether to execute record mode logic or just call the original function.
|
|
@@ -8714,7 +8719,7 @@ function handleRecordMode({ originalFunctionCall, recordModeHandler, spanKind })
|
|
|
8714
8719
|
return originalFunctionCall();
|
|
8715
8720
|
}
|
|
8716
8721
|
if (!isAppReady) return recordModeHandler({ isPreAppStart: true });
|
|
8717
|
-
if (!currentSpanInfo && spanKind !== import_src$
|
|
8722
|
+
if (!currentSpanInfo && spanKind !== import_src$33.SpanKind.SERVER || currentSpanInfo?.isPreAppStart) return originalFunctionCall();
|
|
8718
8723
|
else return recordModeHandler({ isPreAppStart: false });
|
|
8719
8724
|
}
|
|
8720
8725
|
/**
|
|
@@ -10194,7 +10199,7 @@ function captureStackTrace(excludeClassNames = []) {
|
|
|
10194
10199
|
|
|
10195
10200
|
//#endregion
|
|
10196
10201
|
//#region src/instrumentation/libraries/http/HttpTransformEngine.ts
|
|
10197
|
-
var import_src$
|
|
10202
|
+
var import_src$32 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
10198
10203
|
/**
|
|
10199
10204
|
* Creates an empty HttpClientInputValue object for dropped spans
|
|
10200
10205
|
*/
|
|
@@ -10247,7 +10252,7 @@ var HttpTransformEngine = class {
|
|
|
10247
10252
|
const testSpan = {
|
|
10248
10253
|
traceId: "",
|
|
10249
10254
|
spanId: "",
|
|
10250
|
-
kind: import_src$
|
|
10255
|
+
kind: import_src$32.SpanKind.SERVER,
|
|
10251
10256
|
protocol: "http",
|
|
10252
10257
|
inputValue: {
|
|
10253
10258
|
method,
|
|
@@ -10270,7 +10275,7 @@ var HttpTransformEngine = class {
|
|
|
10270
10275
|
const testSpan = {
|
|
10271
10276
|
traceId: "",
|
|
10272
10277
|
spanId: "",
|
|
10273
|
-
kind: import_src$
|
|
10278
|
+
kind: import_src$32.SpanKind.CLIENT,
|
|
10274
10279
|
protocol: inputValue.protocol || "http",
|
|
10275
10280
|
inputValue: clonedInputValue
|
|
10276
10281
|
};
|
|
@@ -10297,8 +10302,8 @@ var HttpTransformEngine = class {
|
|
|
10297
10302
|
const matcherFunction = this.compileMatcher(matcher);
|
|
10298
10303
|
if (action.type === "drop") return (span) => {
|
|
10299
10304
|
if (!matcherFunction(span)) return;
|
|
10300
|
-
if (span.inputValue) span.inputValue = span.kind === import_src$
|
|
10301
|
-
if (span.outputValue) span.outputValue = span.kind === import_src$
|
|
10305
|
+
if (span.inputValue) span.inputValue = span.kind === import_src$32.SpanKind.CLIENT ? createEmptyClientInputValue(span.protocol) : createEmptyServerInputValue();
|
|
10306
|
+
if (span.outputValue) span.outputValue = span.kind === import_src$32.SpanKind.CLIENT ? createEmptyClientOutputValue() : createEmptyServerOutputValue();
|
|
10302
10307
|
return {
|
|
10303
10308
|
type: "drop",
|
|
10304
10309
|
field: "entire_span",
|
|
@@ -10328,8 +10333,8 @@ var HttpTransformEngine = class {
|
|
|
10328
10333
|
}
|
|
10329
10334
|
compileMatcher(matcher) {
|
|
10330
10335
|
const checks = [];
|
|
10331
|
-
if (matcher.direction === "outbound") checks.push((span) => span.kind === import_src$
|
|
10332
|
-
else if (matcher.direction === "inbound") checks.push((span) => span.kind === import_src$
|
|
10336
|
+
if (matcher.direction === "outbound") checks.push((span) => span.kind === import_src$32.SpanKind.CLIENT);
|
|
10337
|
+
else if (matcher.direction === "inbound") checks.push((span) => span.kind === import_src$32.SpanKind.SERVER);
|
|
10333
10338
|
if (matcher.method) if (matcher.method.length === 0) {} else {
|
|
10334
10339
|
const methods = matcher.method.map((method) => method.toUpperCase());
|
|
10335
10340
|
checks.push((span) => {
|
|
@@ -10557,7 +10562,7 @@ var HttpTransformEngine = class {
|
|
|
10557
10562
|
|
|
10558
10563
|
//#endregion
|
|
10559
10564
|
//#region src/instrumentation/libraries/http/Instrumentation.ts
|
|
10560
|
-
var import_src$
|
|
10565
|
+
var import_src$31 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
10561
10566
|
var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
10562
10567
|
constructor(config) {
|
|
10563
10568
|
super("http", config);
|
|
@@ -10644,10 +10649,10 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10644
10649
|
logger.debug(`[HttpInstrumentation] Setting replay trace id`, replayTraceId);
|
|
10645
10650
|
const ctxWithReplayTraceId = SpanUtils.setCurrentReplayTraceId(replayTraceId);
|
|
10646
10651
|
if (!ctxWithReplayTraceId) throw new Error("Error setting current replay trace id");
|
|
10647
|
-
return import_src$
|
|
10652
|
+
return import_src$31.context.with(ctxWithReplayTraceId, () => {
|
|
10648
10653
|
return SpanUtils.createAndExecuteSpan(this.mode, () => originalHandler.call(this), {
|
|
10649
10654
|
name: `${target}`,
|
|
10650
|
-
kind: import_src$
|
|
10655
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10651
10656
|
packageName: spanProtocol,
|
|
10652
10657
|
submodule: method,
|
|
10653
10658
|
packageType: PackageType.HTTP,
|
|
@@ -10692,7 +10697,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10692
10697
|
logger.debug(`[HttpInstrumentation] Http inbound request arriving, inputValue: ${JSON.stringify(inputValue)}`);
|
|
10693
10698
|
return SpanUtils.createAndExecuteSpan(this.mode, () => originalHandler.call(this), {
|
|
10694
10699
|
name: `${target}`,
|
|
10695
|
-
kind: import_src$
|
|
10700
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10696
10701
|
packageName: spanProtocol,
|
|
10697
10702
|
packageType: PackageType.HTTP,
|
|
10698
10703
|
submodule: method,
|
|
@@ -10712,7 +10717,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10712
10717
|
});
|
|
10713
10718
|
});
|
|
10714
10719
|
},
|
|
10715
|
-
spanKind: import_src$
|
|
10720
|
+
spanKind: import_src$31.SpanKind.SERVER
|
|
10716
10721
|
});
|
|
10717
10722
|
} else return originalHandler.call(this);
|
|
10718
10723
|
}
|
|
@@ -10729,8 +10734,8 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10729
10734
|
_handleInboundRequestInSpan({ req, res, originalHandler, spanInfo, inputValue, schemaMerges, protocol }) {
|
|
10730
10735
|
const self = this;
|
|
10731
10736
|
const spanProtocol = this._normalizeProtocol(protocol, "http");
|
|
10732
|
-
import_src$
|
|
10733
|
-
import_src$
|
|
10737
|
+
import_src$31.context.bind(spanInfo.context, req);
|
|
10738
|
+
import_src$31.context.bind(spanInfo.context, res);
|
|
10734
10739
|
let completeInputValue = inputValue;
|
|
10735
10740
|
this._captureServerRequestBody(req, spanInfo, inputValue, schemaMerges, (updatedInputValue) => {
|
|
10736
10741
|
completeInputValue = updatedInputValue;
|
|
@@ -10768,7 +10773,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10768
10773
|
const spanData = {
|
|
10769
10774
|
traceId: spanInfo.traceId,
|
|
10770
10775
|
spanId: spanInfo.spanId,
|
|
10771
|
-
kind: import_src$
|
|
10776
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10772
10777
|
protocol: spanProtocol,
|
|
10773
10778
|
inputValue: completeInputValue,
|
|
10774
10779
|
outputValue
|
|
@@ -10787,9 +10792,9 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10787
10792
|
...spanData.transformMetadata && { transformMetadata: spanData.transformMetadata }
|
|
10788
10793
|
});
|
|
10789
10794
|
const status = statusCode >= 300 ? {
|
|
10790
|
-
code: import_src$
|
|
10795
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
10791
10796
|
message: `HTTP ${statusCode}`
|
|
10792
|
-
} : { code: import_src$
|
|
10797
|
+
} : { code: import_src$31.SpanStatusCode.OK };
|
|
10793
10798
|
SpanUtils.setStatus(spanInfo.span, status);
|
|
10794
10799
|
const decodedType = getDecodedType(outputValue.headers?.["content-type"] || "");
|
|
10795
10800
|
if (decodedType && !ACCEPTABLE_CONTENT_TYPES.has(decodedType)) {
|
|
@@ -10839,7 +10844,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10839
10844
|
outputSchemaHash: JsonSchemaHelper.generateDeterministicHash(outputSchema),
|
|
10840
10845
|
inputValueHash,
|
|
10841
10846
|
outputValueHash,
|
|
10842
|
-
kind: import_src$
|
|
10847
|
+
kind: import_src$31.SpanKind.SERVER,
|
|
10843
10848
|
packageType: PackageType.HTTP,
|
|
10844
10849
|
status: {
|
|
10845
10850
|
code: statusCode >= 300 ? StatusCode.ERROR : StatusCode.OK,
|
|
@@ -10868,7 +10873,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10868
10873
|
try {
|
|
10869
10874
|
logger.debug(`[HttpInstrumentation] Server request error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
10870
10875
|
SpanUtils.endSpan(spanInfo.span, {
|
|
10871
|
-
code: import_src$
|
|
10876
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
10872
10877
|
message: error.message
|
|
10873
10878
|
});
|
|
10874
10879
|
} catch (error$1) {
|
|
@@ -10879,7 +10884,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
10879
10884
|
try {
|
|
10880
10885
|
logger.debug(`[HttpInstrumentation] Server response 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) {
|
|
@@ -11084,7 +11089,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11084
11089
|
inputValue: completeInputValue
|
|
11085
11090
|
});
|
|
11086
11091
|
SpanUtils.endSpan(spanInfo.span, {
|
|
11087
|
-
code: import_src$
|
|
11092
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
11088
11093
|
message: error.message
|
|
11089
11094
|
});
|
|
11090
11095
|
} catch (error$1) {
|
|
@@ -11101,7 +11106,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11101
11106
|
const spanData = {
|
|
11102
11107
|
traceId: spanInfo.traceId,
|
|
11103
11108
|
spanId: spanInfo.spanId,
|
|
11104
|
-
kind: import_src$
|
|
11109
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11105
11110
|
protocol: normalizedProtocol,
|
|
11106
11111
|
inputValue,
|
|
11107
11112
|
outputValue
|
|
@@ -11114,9 +11119,9 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11114
11119
|
transformMetadata: spanData.transformMetadata ? spanData.transformMetadata : void 0
|
|
11115
11120
|
});
|
|
11116
11121
|
const status = statusCode >= 300 ? {
|
|
11117
|
-
code: import_src$
|
|
11122
|
+
code: import_src$31.SpanStatusCode.ERROR,
|
|
11118
11123
|
message: `HTTP ${statusCode}`
|
|
11119
|
-
} : { code: import_src$
|
|
11124
|
+
} : { code: import_src$31.SpanStatusCode.OK };
|
|
11120
11125
|
SpanUtils.endSpan(spanInfo.span, status);
|
|
11121
11126
|
}
|
|
11122
11127
|
_captureHeadersFromRawHeaders(rawHeaders) {
|
|
@@ -11134,13 +11139,23 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11134
11139
|
let requestOptions;
|
|
11135
11140
|
if (typeof args[0] === "string") {
|
|
11136
11141
|
const url = new URL(args[0]);
|
|
11142
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11137
11143
|
requestOptions = {
|
|
11138
11144
|
protocol: url.protocol,
|
|
11139
11145
|
hostname: url.hostname,
|
|
11140
11146
|
port: url.port ? parseInt(url.port) : void 0,
|
|
11141
11147
|
path: url.pathname + url.search,
|
|
11142
|
-
method:
|
|
11143
|
-
headers:
|
|
11148
|
+
method: additionalOptions?.method || "GET",
|
|
11149
|
+
headers: additionalOptions?.headers || {}
|
|
11150
|
+
};
|
|
11151
|
+
} else if (self._isURLObject(args[0])) {
|
|
11152
|
+
const url = args[0];
|
|
11153
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11154
|
+
requestOptions = {
|
|
11155
|
+
...self._urlToRequestOptions(url),
|
|
11156
|
+
method: additionalOptions?.method || "GET",
|
|
11157
|
+
headers: additionalOptions?.headers || {},
|
|
11158
|
+
...additionalOptions
|
|
11144
11159
|
};
|
|
11145
11160
|
} else requestOptions = args[0] || {};
|
|
11146
11161
|
const method = requestOptions.method || "GET";
|
|
@@ -11170,7 +11185,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11170
11185
|
};
|
|
11171
11186
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRequest.apply(this, args), {
|
|
11172
11187
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11173
|
-
kind: import_src$
|
|
11188
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11174
11189
|
packageName: requestProtocol,
|
|
11175
11190
|
packageType: PackageType.HTTP,
|
|
11176
11191
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11205,7 +11220,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11205
11220
|
};
|
|
11206
11221
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRequest.apply(this, args), {
|
|
11207
11222
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11208
|
-
kind: import_src$
|
|
11223
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11209
11224
|
packageName: requestProtocol,
|
|
11210
11225
|
packageType: PackageType.HTTP,
|
|
11211
11226
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11217,7 +11232,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11217
11232
|
return self._handleOutboundRequestInSpan(originalRequest, args, spanInfo, inputValue, { headers: { matchImportance: 0 } });
|
|
11218
11233
|
});
|
|
11219
11234
|
},
|
|
11220
|
-
spanKind: import_src$
|
|
11235
|
+
spanKind: import_src$31.SpanKind.CLIENT
|
|
11221
11236
|
});
|
|
11222
11237
|
else return originalRequest.apply(this, args);
|
|
11223
11238
|
};
|
|
@@ -11230,12 +11245,21 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11230
11245
|
let requestOptions;
|
|
11231
11246
|
if (typeof args[0] === "string") {
|
|
11232
11247
|
const url = new URL(args[0]);
|
|
11248
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11233
11249
|
requestOptions = {
|
|
11234
11250
|
protocol: url.protocol,
|
|
11235
11251
|
hostname: url.hostname,
|
|
11236
11252
|
port: url.port ? parseInt(url.port) : void 0,
|
|
11237
11253
|
path: url.pathname + url.search,
|
|
11238
|
-
headers:
|
|
11254
|
+
headers: additionalOptions?.headers || {}
|
|
11255
|
+
};
|
|
11256
|
+
} else if (self._isURLObject(args[0])) {
|
|
11257
|
+
const url = args[0];
|
|
11258
|
+
const additionalOptions = typeof args[1] === "function" ? void 0 : args[1];
|
|
11259
|
+
requestOptions = {
|
|
11260
|
+
...self._urlToRequestOptions(url),
|
|
11261
|
+
headers: additionalOptions?.headers || {},
|
|
11262
|
+
...additionalOptions
|
|
11239
11263
|
};
|
|
11240
11264
|
} else requestOptions = args[0] || {};
|
|
11241
11265
|
const method = "GET";
|
|
@@ -11263,7 +11287,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11263
11287
|
};
|
|
11264
11288
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.apply(this, args), {
|
|
11265
11289
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11266
|
-
kind: import_src$
|
|
11290
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11267
11291
|
packageName: requestProtocol,
|
|
11268
11292
|
packageType: PackageType.HTTP,
|
|
11269
11293
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11297,7 +11321,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11297
11321
|
};
|
|
11298
11322
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.apply(this, args), {
|
|
11299
11323
|
name: requestOptions.path || `${requestProtocol.toUpperCase()} ${method}`,
|
|
11300
|
-
kind: import_src$
|
|
11324
|
+
kind: import_src$31.SpanKind.CLIENT,
|
|
11301
11325
|
packageName: requestProtocol,
|
|
11302
11326
|
packageType: PackageType.HTTP,
|
|
11303
11327
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -11309,7 +11333,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11309
11333
|
return self._handleOutboundRequestInSpan(originalGet, args, spanInfo, inputValue, { headers: { matchImportance: 0 } });
|
|
11310
11334
|
});
|
|
11311
11335
|
},
|
|
11312
|
-
spanKind: import_src$
|
|
11336
|
+
spanKind: import_src$31.SpanKind.CLIENT
|
|
11313
11337
|
});
|
|
11314
11338
|
else return originalGet.apply(this, args);
|
|
11315
11339
|
};
|
|
@@ -11341,6 +11365,25 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11341
11365
|
};
|
|
11342
11366
|
};
|
|
11343
11367
|
}
|
|
11368
|
+
/**
|
|
11369
|
+
* Check if the input is a URL object (WHATWG URL API)
|
|
11370
|
+
* This is used to detect when a URL object is passed to http.get/request
|
|
11371
|
+
*/
|
|
11372
|
+
_isURLObject(input) {
|
|
11373
|
+
return input instanceof URL || input && typeof input.href === "string" && typeof input.pathname === "string";
|
|
11374
|
+
}
|
|
11375
|
+
/**
|
|
11376
|
+
* Convert a URL object to RequestOptions
|
|
11377
|
+
* Similar to Node.js's internal urlToHttpOptions function
|
|
11378
|
+
*/
|
|
11379
|
+
_urlToRequestOptions(url) {
|
|
11380
|
+
return {
|
|
11381
|
+
protocol: url.protocol,
|
|
11382
|
+
hostname: url.hostname,
|
|
11383
|
+
port: url.port ? parseInt(url.port) : void 0,
|
|
11384
|
+
path: url.pathname + (url.search || "")
|
|
11385
|
+
};
|
|
11386
|
+
}
|
|
11344
11387
|
_normalizeProtocol(protocol, fallback) {
|
|
11345
11388
|
if (!protocol) return fallback;
|
|
11346
11389
|
const normalized = protocol.toLowerCase().replace(/:$/, "");
|
|
@@ -11354,7 +11397,7 @@ var HttpInstrumentation = class extends TdInstrumentationBase {
|
|
|
11354
11397
|
|
|
11355
11398
|
//#endregion
|
|
11356
11399
|
//#region src/instrumentation/libraries/date/Instrumentation.ts
|
|
11357
|
-
var import_src$
|
|
11400
|
+
var import_src$30 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
11358
11401
|
/**
|
|
11359
11402
|
* Date instrumentation that provides consistent dates in replay mode.
|
|
11360
11403
|
* In replay mode, new Date() calls return the latest mock response timestamp.
|
|
@@ -11393,7 +11436,7 @@ var DateInstrumentation = class DateInstrumentation extends TdInstrumentationBas
|
|
|
11393
11436
|
if (this.mode !== TuskDriftMode.REPLAY) return this._callOriginalDate(args, isConstructorCall);
|
|
11394
11437
|
const currentSpanInfo = SpanUtils.getCurrentSpanInfo();
|
|
11395
11438
|
if (!currentSpanInfo) return this._callOriginalDate(args, isConstructorCall);
|
|
11396
|
-
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) !== import_src$
|
|
11439
|
+
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) !== import_src$30.SpanKind.SERVER) return this._callOriginalDate(args, isConstructorCall);
|
|
11397
11440
|
this.isInPatchedCall = true;
|
|
11398
11441
|
try {
|
|
11399
11442
|
return this._handleReplayDate(args, isConstructorCall);
|
|
@@ -11639,7 +11682,7 @@ var TdPgClientMock = class extends EventEmitter {
|
|
|
11639
11682
|
|
|
11640
11683
|
//#endregion
|
|
11641
11684
|
//#region src/instrumentation/libraries/pg/Instrumentation.ts
|
|
11642
|
-
var import_src$
|
|
11685
|
+
var import_src$29 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
11643
11686
|
var PgInstrumentation = class extends TdInstrumentationBase {
|
|
11644
11687
|
constructor(config = {}) {
|
|
11645
11688
|
super("pg", config);
|
|
@@ -11712,12 +11755,13 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11712
11755
|
const spanName = inputValue.clientType === "pool" ? "pg-pool.query" : "pg.query";
|
|
11713
11756
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
11714
11757
|
name: spanName,
|
|
11715
|
-
kind: import_src$
|
|
11758
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11716
11759
|
submodule: "query",
|
|
11717
11760
|
packageType: PackageType.PG,
|
|
11718
11761
|
packageName,
|
|
11719
11762
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
11720
11763
|
inputValue,
|
|
11764
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
11721
11765
|
isPreAppStart: false
|
|
11722
11766
|
}, (spanInfo) => {
|
|
11723
11767
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, stackTrace);
|
|
@@ -11731,18 +11775,19 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11731
11775
|
const spanName = inputValue.clientType === "pool" ? "pg-pool.query" : "pg.query";
|
|
11732
11776
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
11733
11777
|
name: spanName,
|
|
11734
|
-
kind: import_src$
|
|
11778
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11735
11779
|
submodule: "query",
|
|
11736
11780
|
packageType: PackageType.PG,
|
|
11737
11781
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
11738
11782
|
packageName,
|
|
11739
11783
|
inputValue,
|
|
11784
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
11740
11785
|
isPreAppStart
|
|
11741
11786
|
}, (spanInfo) => {
|
|
11742
11787
|
return self._handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, this);
|
|
11743
11788
|
});
|
|
11744
11789
|
},
|
|
11745
|
-
spanKind: import_src$
|
|
11790
|
+
spanKind: import_src$29.SpanKind.CLIENT
|
|
11746
11791
|
});
|
|
11747
11792
|
else return originalQuery.apply(this, args);
|
|
11748
11793
|
};
|
|
@@ -11764,7 +11809,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11764
11809
|
replayModeHandler: () => {
|
|
11765
11810
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
11766
11811
|
name: `pg.connect`,
|
|
11767
|
-
kind: import_src$
|
|
11812
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11768
11813
|
submodule: "connect",
|
|
11769
11814
|
packageName: "pg",
|
|
11770
11815
|
packageType: PackageType.PG,
|
|
@@ -11781,7 +11826,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11781
11826
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
11782
11827
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
11783
11828
|
name: `pg.connect`,
|
|
11784
|
-
kind: import_src$
|
|
11829
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11785
11830
|
submodule: "connect",
|
|
11786
11831
|
packageName: "pg",
|
|
11787
11832
|
packageType: PackageType.PG,
|
|
@@ -11792,7 +11837,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11792
11837
|
return self._handleRecordConnectInSpan(spanInfo, originalConnect, callback, this);
|
|
11793
11838
|
});
|
|
11794
11839
|
},
|
|
11795
|
-
spanKind: import_src$
|
|
11840
|
+
spanKind: import_src$29.SpanKind.CLIENT
|
|
11796
11841
|
});
|
|
11797
11842
|
else return originalConnect.apply(this, [callback]);
|
|
11798
11843
|
};
|
|
@@ -11832,7 +11877,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11832
11877
|
logger.debug(`[PgInstrumentation] PG query error (hasCallback): ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
11833
11878
|
try {
|
|
11834
11879
|
SpanUtils.endSpan(spanInfo.span, {
|
|
11835
|
-
code: import_src$
|
|
11880
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
11836
11881
|
message: error.message
|
|
11837
11882
|
});
|
|
11838
11883
|
} catch (error$1) {
|
|
@@ -11842,7 +11887,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11842
11887
|
logger.debug(`[PgInstrumentation] PG query completed successfully (hasCallback) (${SpanUtils.getTraceInfo()})`);
|
|
11843
11888
|
try {
|
|
11844
11889
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
11845
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
11890
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
11846
11891
|
} catch (error$1) {
|
|
11847
11892
|
logger.error(`[PgInstrumentation] error processing response:`, error$1);
|
|
11848
11893
|
}
|
|
@@ -11869,7 +11914,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11869
11914
|
logger.debug(`[PgInstrumentation] PG query completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
11870
11915
|
try {
|
|
11871
11916
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
11872
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
11917
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
11873
11918
|
} catch (error) {
|
|
11874
11919
|
logger.error(`[PgInstrumentation] error processing response:`, error);
|
|
11875
11920
|
}
|
|
@@ -11878,7 +11923,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11878
11923
|
logger.debug(`[PgInstrumentation] PG query error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
11879
11924
|
try {
|
|
11880
11925
|
SpanUtils.endSpan(spanInfo.span, {
|
|
11881
|
-
code: import_src$
|
|
11926
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
11882
11927
|
message: error.message
|
|
11883
11928
|
});
|
|
11884
11929
|
} catch (error$1) {
|
|
@@ -11910,10 +11955,11 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11910
11955
|
packageName,
|
|
11911
11956
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
11912
11957
|
submoduleName: "query",
|
|
11913
|
-
kind: import_src$
|
|
11958
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
11914
11959
|
stackTrace
|
|
11915
11960
|
},
|
|
11916
|
-
tuskDrift: this.tuskDrift
|
|
11961
|
+
tuskDrift: this.tuskDrift,
|
|
11962
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
11917
11963
|
});
|
|
11918
11964
|
if (!mockData) {
|
|
11919
11965
|
const queryText = queryConfig.text || inputValue.text || "UNKNOWN_QUERY";
|
|
@@ -11996,7 +12042,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
11996
12042
|
logger.debug(`[PgInstrumentation] PG connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
11997
12043
|
try {
|
|
11998
12044
|
SpanUtils.endSpan(spanInfo.span, {
|
|
11999
|
-
code: import_src$
|
|
12045
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12000
12046
|
message: error.message
|
|
12001
12047
|
});
|
|
12002
12048
|
} catch (error$1) {
|
|
@@ -12006,7 +12052,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12006
12052
|
logger.debug(`[PgInstrumentation] PG connect completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
12007
12053
|
try {
|
|
12008
12054
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
12009
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12055
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12010
12056
|
} catch (error$1) {
|
|
12011
12057
|
logger.error(`[PgInstrumentation] error processing connect response:`, error$1);
|
|
12012
12058
|
}
|
|
@@ -12018,7 +12064,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12018
12064
|
logger.debug(`[PgInstrumentation] PG connect completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
12019
12065
|
try {
|
|
12020
12066
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
12021
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12067
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12022
12068
|
} catch (error) {
|
|
12023
12069
|
logger.error(`[PgInstrumentation] error processing connect response:`, error);
|
|
12024
12070
|
}
|
|
@@ -12027,7 +12073,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12027
12073
|
logger.debug(`[PgInstrumentation] PG connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
12028
12074
|
try {
|
|
12029
12075
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12030
|
-
code: import_src$
|
|
12076
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12031
12077
|
message: error.message
|
|
12032
12078
|
});
|
|
12033
12079
|
} catch (error$1) {
|
|
@@ -12099,7 +12145,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12099
12145
|
replayModeHandler: () => {
|
|
12100
12146
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
12101
12147
|
name: `pg-pool.connect`,
|
|
12102
|
-
kind: import_src$
|
|
12148
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
12103
12149
|
submodule: "connect",
|
|
12104
12150
|
packageName: "pg-pool",
|
|
12105
12151
|
packageType: PackageType.PG,
|
|
@@ -12116,7 +12162,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12116
12162
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12117
12163
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
12118
12164
|
name: `pg-pool.connect`,
|
|
12119
|
-
kind: import_src$
|
|
12165
|
+
kind: import_src$29.SpanKind.CLIENT,
|
|
12120
12166
|
submodule: "connect",
|
|
12121
12167
|
packageName: "pg-pool",
|
|
12122
12168
|
packageType: PackageType.PG,
|
|
@@ -12127,7 +12173,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12127
12173
|
return self._handleRecordPoolConnectInSpan(spanInfo, originalConnect, callback, this);
|
|
12128
12174
|
});
|
|
12129
12175
|
},
|
|
12130
|
-
spanKind: import_src$
|
|
12176
|
+
spanKind: import_src$29.SpanKind.CLIENT
|
|
12131
12177
|
});
|
|
12132
12178
|
else return originalConnect.apply(this, [callback]);
|
|
12133
12179
|
};
|
|
@@ -12140,7 +12186,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12140
12186
|
logger.debug(`[PgInstrumentation] PG Pool connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
12141
12187
|
try {
|
|
12142
12188
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12143
|
-
code: import_src$
|
|
12189
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12144
12190
|
message: error.message
|
|
12145
12191
|
});
|
|
12146
12192
|
} catch (error$1) {
|
|
@@ -12153,7 +12199,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12153
12199
|
connected: true,
|
|
12154
12200
|
hasClient: !!client
|
|
12155
12201
|
} });
|
|
12156
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12202
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12157
12203
|
} catch (error$1) {
|
|
12158
12204
|
logger.error(`[PgInstrumentation] error processing pool connect response:`, error$1);
|
|
12159
12205
|
}
|
|
@@ -12168,7 +12214,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12168
12214
|
connected: true,
|
|
12169
12215
|
hasClient: !!client
|
|
12170
12216
|
} });
|
|
12171
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12217
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$29.SpanStatusCode.OK });
|
|
12172
12218
|
} catch (error) {
|
|
12173
12219
|
logger.error(`[PgInstrumentation] error processing pool connect response:`, error);
|
|
12174
12220
|
}
|
|
@@ -12177,7 +12223,7 @@ var PgInstrumentation = class extends TdInstrumentationBase {
|
|
|
12177
12223
|
logger.debug(`[PgInstrumentation] PG Pool connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
12178
12224
|
try {
|
|
12179
12225
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12180
|
-
code: import_src$
|
|
12226
|
+
code: import_src$29.SpanStatusCode.ERROR,
|
|
12181
12227
|
message: error.message
|
|
12182
12228
|
});
|
|
12183
12229
|
} catch (error$1) {
|
|
@@ -12302,7 +12348,7 @@ function reconstructQueryString(strings, values) {
|
|
|
12302
12348
|
|
|
12303
12349
|
//#endregion
|
|
12304
12350
|
//#region src/instrumentation/libraries/postgres/handlers/ConnectionHandler.ts
|
|
12305
|
-
var import_src$
|
|
12351
|
+
var import_src$28 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
12306
12352
|
var ConnectionHandler = class {
|
|
12307
12353
|
constructor(mode, instrumentationName, isAppReady, wrapSqlInstance) {
|
|
12308
12354
|
this.mode = mode;
|
|
@@ -12346,7 +12392,7 @@ var ConnectionHandler = class {
|
|
|
12346
12392
|
return this.wrapSqlInstance(sqlInstance);
|
|
12347
12393
|
}, {
|
|
12348
12394
|
name: "postgres.connect",
|
|
12349
|
-
kind: import_src$
|
|
12395
|
+
kind: import_src$28.SpanKind.CLIENT,
|
|
12350
12396
|
submodule: "connect",
|
|
12351
12397
|
packageType: PackageType.PG,
|
|
12352
12398
|
packageName: "postgres",
|
|
@@ -12369,7 +12415,7 @@ var ConnectionHandler = class {
|
|
|
12369
12415
|
return this.wrapSqlInstance(sqlInstance);
|
|
12370
12416
|
}, {
|
|
12371
12417
|
name: "postgres.connect",
|
|
12372
|
-
kind: import_src$
|
|
12418
|
+
kind: import_src$28.SpanKind.CLIENT,
|
|
12373
12419
|
submodule: "connect",
|
|
12374
12420
|
packageType: PackageType.PG,
|
|
12375
12421
|
packageName: "postgres",
|
|
@@ -12380,7 +12426,7 @@ var ConnectionHandler = class {
|
|
|
12380
12426
|
return this.handleRecordConnect(spanInfo, originalFunction, args);
|
|
12381
12427
|
});
|
|
12382
12428
|
},
|
|
12383
|
-
spanKind: import_src$
|
|
12429
|
+
spanKind: import_src$28.SpanKind.CLIENT
|
|
12384
12430
|
});
|
|
12385
12431
|
else return originalFunction(...args);
|
|
12386
12432
|
}
|
|
@@ -12390,7 +12436,7 @@ var ConnectionHandler = class {
|
|
|
12390
12436
|
try {
|
|
12391
12437
|
logger.debug(`[PostgresInstrumentation] Postgres connection created successfully (${SpanUtils.getTraceInfo()})`);
|
|
12392
12438
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
12393
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12439
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$28.SpanStatusCode.OK });
|
|
12394
12440
|
} catch (error) {
|
|
12395
12441
|
logger.error(`[PostgresInstrumentation] error adding span attributes:`, error);
|
|
12396
12442
|
}
|
|
@@ -12410,7 +12456,7 @@ var ConnectionHandler = class {
|
|
|
12410
12456
|
|
|
12411
12457
|
//#endregion
|
|
12412
12458
|
//#region src/instrumentation/libraries/postgres/Instrumentation.ts
|
|
12413
|
-
var import_src$
|
|
12459
|
+
var import_src$27 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
12414
12460
|
var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
12415
12461
|
constructor(config = {}) {
|
|
12416
12462
|
super("postgres", config);
|
|
@@ -12581,7 +12627,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12581
12627
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12582
12628
|
return SpanUtils.createAndExecuteSpan(this.mode, () => originalListen.call(sqlInstance, channelName, callback, onlisten), {
|
|
12583
12629
|
name: "postgres.listen",
|
|
12584
|
-
kind: import_src$
|
|
12630
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12585
12631
|
submodule: "listen",
|
|
12586
12632
|
packageType: PackageType.PG,
|
|
12587
12633
|
packageName: "postgres",
|
|
@@ -12608,7 +12654,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12608
12654
|
state: result.state,
|
|
12609
12655
|
payloads: receivedPayloads
|
|
12610
12656
|
} });
|
|
12611
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12657
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12612
12658
|
} catch (error) {
|
|
12613
12659
|
logger.error(`[PostgresInstrumentation] error adding span attributes:`, error);
|
|
12614
12660
|
}
|
|
@@ -12622,7 +12668,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12622
12668
|
logger.error(`[PostgresInstrumentation] RECORD listen error: ${error.message}`);
|
|
12623
12669
|
try {
|
|
12624
12670
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12625
|
-
code: import_src$
|
|
12671
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12626
12672
|
message: error.message
|
|
12627
12673
|
});
|
|
12628
12674
|
} catch (error$1) {
|
|
@@ -12632,7 +12678,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12632
12678
|
}
|
|
12633
12679
|
});
|
|
12634
12680
|
},
|
|
12635
|
-
spanKind: import_src$
|
|
12681
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
12636
12682
|
});
|
|
12637
12683
|
}
|
|
12638
12684
|
async _handleReplayListen(channelName, callback, onlisten, inputValue) {
|
|
@@ -12650,7 +12696,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12650
12696
|
unlisten: async () => {}
|
|
12651
12697
|
}), {
|
|
12652
12698
|
name: "postgres.listen",
|
|
12653
|
-
kind: import_src$
|
|
12699
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12654
12700
|
submodule: "listen",
|
|
12655
12701
|
packageType: PackageType.PG,
|
|
12656
12702
|
packageName: "postgres",
|
|
@@ -12678,7 +12724,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12678
12724
|
logger.debug(`[PostgresInstrumentation] REPLAY: Invoking callback with recorded payload: ${payload}`);
|
|
12679
12725
|
callback(payload);
|
|
12680
12726
|
}
|
|
12681
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12727
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12682
12728
|
return {
|
|
12683
12729
|
state: recordedState,
|
|
12684
12730
|
unlisten: async () => {
|
|
@@ -12688,7 +12734,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12688
12734
|
} catch (error) {
|
|
12689
12735
|
logger.error(`[PostgresInstrumentation] REPLAY listen error: ${error.message}`);
|
|
12690
12736
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12691
|
-
code: import_src$
|
|
12737
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12692
12738
|
message: error.message
|
|
12693
12739
|
});
|
|
12694
12740
|
throw error;
|
|
@@ -12707,7 +12753,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12707
12753
|
}
|
|
12708
12754
|
_handleSqlQuery(originalSql, strings, values) {
|
|
12709
12755
|
if (!strings || !Array.isArray(strings.raw)) return originalSql.call(this, strings, ...values);
|
|
12710
|
-
const creationContext = import_src$
|
|
12756
|
+
const creationContext = import_src$27.context.active();
|
|
12711
12757
|
const query = originalSql.call(this, strings, ...values);
|
|
12712
12758
|
const inputValue = {
|
|
12713
12759
|
query: reconstructQueryString(strings, values).trim(),
|
|
@@ -12730,7 +12776,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12730
12776
|
else if (parameters !== void 0) return originalUnsafe.call(sqlInstance, query, parameters);
|
|
12731
12777
|
else return originalUnsafe.call(sqlInstance, query);
|
|
12732
12778
|
})();
|
|
12733
|
-
const creationContext = import_src$
|
|
12779
|
+
const creationContext = import_src$27.context.active();
|
|
12734
12780
|
const originalThen = unsafeQuery.then.bind(unsafeQuery);
|
|
12735
12781
|
const inputValue = {
|
|
12736
12782
|
query: query.trim(),
|
|
@@ -12753,7 +12799,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12753
12799
|
else if (parameters !== void 0) return originalFile.call(sqlInstance, path$2, parameters);
|
|
12754
12800
|
else return originalFile.call(sqlInstance, path$2);
|
|
12755
12801
|
})();
|
|
12756
|
-
const creationContext = import_src$
|
|
12802
|
+
const creationContext = import_src$27.context.active();
|
|
12757
12803
|
const originalThen = fileQuery.then.bind(fileQuery);
|
|
12758
12804
|
const self = this;
|
|
12759
12805
|
const inputValue = {
|
|
@@ -12764,25 +12810,26 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12764
12810
|
fileQuery.then = function(onFulfilled, onRejected) {
|
|
12765
12811
|
if (fileQuery._tuskRecorded) return originalThen(onFulfilled, onRejected);
|
|
12766
12812
|
fileQuery._tuskRecorded = true;
|
|
12767
|
-
return import_src$
|
|
12813
|
+
return import_src$27.context.with(creationContext, () => {
|
|
12768
12814
|
if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
12769
12815
|
originalFunctionCall: () => originalThen(onFulfilled, onRejected),
|
|
12770
12816
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12771
12817
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
12772
12818
|
name: "postgres.file",
|
|
12773
|
-
kind: import_src$
|
|
12819
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12774
12820
|
submodule: "file",
|
|
12775
12821
|
packageType: PackageType.PG,
|
|
12776
12822
|
packageName: "postgres",
|
|
12777
12823
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
12778
12824
|
inputValue,
|
|
12825
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
12779
12826
|
isPreAppStart
|
|
12780
12827
|
}, (spanInfo) => {
|
|
12781
12828
|
const wrappedOnFulfilled = (result) => {
|
|
12782
12829
|
try {
|
|
12783
12830
|
logger.debug(`[PostgresInstrumentation] Postgres file query completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
12784
12831
|
addOutputAttributesToSpan(spanInfo, result);
|
|
12785
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12832
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12786
12833
|
} catch (error) {
|
|
12787
12834
|
logger.error(`[PostgresInstrumentation] error processing file query response:`, error);
|
|
12788
12835
|
}
|
|
@@ -12792,7 +12839,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12792
12839
|
try {
|
|
12793
12840
|
logger.debug(`[PostgresInstrumentation] Postgres file query error: ${error.message}`);
|
|
12794
12841
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12795
|
-
code: import_src$
|
|
12842
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12796
12843
|
message: error.message
|
|
12797
12844
|
});
|
|
12798
12845
|
} catch (spanError) {
|
|
@@ -12804,7 +12851,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12804
12851
|
return originalThen(wrappedOnFulfilled, wrappedOnRejected);
|
|
12805
12852
|
});
|
|
12806
12853
|
},
|
|
12807
|
-
spanKind: import_src$
|
|
12854
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
12808
12855
|
});
|
|
12809
12856
|
else if (self.mode === TuskDriftMode.REPLAY) {
|
|
12810
12857
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
@@ -12817,12 +12864,13 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12817
12864
|
replayModeHandler: () => {
|
|
12818
12865
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
12819
12866
|
name: "postgres.file",
|
|
12820
|
-
kind: import_src$
|
|
12867
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12821
12868
|
submodule: "file",
|
|
12822
12869
|
packageType: PackageType.PG,
|
|
12823
12870
|
packageName: "postgres",
|
|
12824
12871
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
12825
12872
|
inputValue,
|
|
12873
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
12826
12874
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
12827
12875
|
}, async (spanInfo) => {
|
|
12828
12876
|
const mockedResult = await self._handleReplayQueryOperation({
|
|
@@ -12890,7 +12938,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12890
12938
|
replayModeHandler: () => {
|
|
12891
12939
|
return SpanUtils.createAndExecuteSpan(this.mode, () => executeBegin(), {
|
|
12892
12940
|
name: "postgres.begin",
|
|
12893
|
-
kind: import_src$
|
|
12941
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12894
12942
|
submodule: "transaction",
|
|
12895
12943
|
packageType: PackageType.PG,
|
|
12896
12944
|
packageName: "postgres",
|
|
@@ -12907,7 +12955,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12907
12955
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
12908
12956
|
return SpanUtils.createAndExecuteSpan(this.mode, executeBegin, {
|
|
12909
12957
|
name: "postgres.begin",
|
|
12910
|
-
kind: import_src$
|
|
12958
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
12911
12959
|
submodule: "transaction",
|
|
12912
12960
|
packageType: PackageType.PG,
|
|
12913
12961
|
packageName: "postgres",
|
|
@@ -12918,7 +12966,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12918
12966
|
return this._handleRecordBeginTransaction(spanInfo, executeBegin);
|
|
12919
12967
|
});
|
|
12920
12968
|
},
|
|
12921
|
-
spanKind: import_src$
|
|
12969
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
12922
12970
|
});
|
|
12923
12971
|
else return executeBegin();
|
|
12924
12972
|
}
|
|
@@ -12930,7 +12978,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12930
12978
|
status: "committed",
|
|
12931
12979
|
result
|
|
12932
12980
|
} });
|
|
12933
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
12981
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
12934
12982
|
} catch (error) {
|
|
12935
12983
|
logger.error(`[PostgresInstrumentation] error processing transaction response:`, error);
|
|
12936
12984
|
}
|
|
@@ -12943,7 +12991,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
12943
12991
|
error: error.message
|
|
12944
12992
|
} });
|
|
12945
12993
|
SpanUtils.endSpan(spanInfo.span, {
|
|
12946
|
-
code: import_src$
|
|
12994
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
12947
12995
|
message: error.message
|
|
12948
12996
|
});
|
|
12949
12997
|
} catch (spanError) {
|
|
@@ -13022,10 +13070,11 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13022
13070
|
packageName: "postgres",
|
|
13023
13071
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
13024
13072
|
submoduleName,
|
|
13025
|
-
kind: import_src$
|
|
13073
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13026
13074
|
stackTrace
|
|
13027
13075
|
},
|
|
13028
|
-
tuskDrift: this.tuskDrift
|
|
13076
|
+
tuskDrift: this.tuskDrift,
|
|
13077
|
+
inputValueSchemaMerges: { parameters: { matchImportance: 0 } }
|
|
13029
13078
|
});
|
|
13030
13079
|
}
|
|
13031
13080
|
/**
|
|
@@ -13039,7 +13088,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13039
13088
|
state: result?.state,
|
|
13040
13089
|
statement: result?.statement
|
|
13041
13090
|
}));
|
|
13042
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13091
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13043
13092
|
logger.debug(`[PostgresInstrumentation] ${operation} completed, recorded ${allRows.length} rows`);
|
|
13044
13093
|
}
|
|
13045
13094
|
/**
|
|
@@ -13067,18 +13116,19 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13067
13116
|
}
|
|
13068
13117
|
_handleCursorCallbackRecord({ originalCursor, rows, inputValue, creationContext, userCallback }) {
|
|
13069
13118
|
const self = this;
|
|
13070
|
-
return import_src$
|
|
13119
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13071
13120
|
return handleRecordMode({
|
|
13072
13121
|
originalFunctionCall: () => originalCursor(rows, userCallback),
|
|
13073
13122
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
13074
13123
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCursor(rows, userCallback), {
|
|
13075
13124
|
name: "postgres.cursor",
|
|
13076
|
-
kind: import_src$
|
|
13125
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13077
13126
|
submodule: "cursor",
|
|
13078
13127
|
packageType: PackageType.PG,
|
|
13079
13128
|
packageName: "postgres",
|
|
13080
13129
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13081
13130
|
inputValue,
|
|
13131
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13082
13132
|
isPreAppStart
|
|
13083
13133
|
}, (spanInfo) => {
|
|
13084
13134
|
return self._executeAndRecordCursorCallback({
|
|
@@ -13089,7 +13139,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13089
13139
|
});
|
|
13090
13140
|
});
|
|
13091
13141
|
},
|
|
13092
|
-
spanKind: import_src$
|
|
13142
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
13093
13143
|
});
|
|
13094
13144
|
});
|
|
13095
13145
|
}
|
|
@@ -13112,7 +13162,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13112
13162
|
logger.debug(`[PostgresInstrumentation] Cursor callback error: ${error.message}`);
|
|
13113
13163
|
if (spanInfo) try {
|
|
13114
13164
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13115
|
-
code: import_src$
|
|
13165
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13116
13166
|
message: error.message
|
|
13117
13167
|
});
|
|
13118
13168
|
} catch (error$1) {
|
|
@@ -13124,19 +13174,20 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13124
13174
|
_handleCursorCallbackReplay({ inputValue, creationContext, cursorBatchSize, userCallback }) {
|
|
13125
13175
|
const self = this;
|
|
13126
13176
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
13127
|
-
return import_src$
|
|
13177
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13128
13178
|
return handleReplayMode({
|
|
13129
13179
|
noOpRequestHandler: () => Promise.resolve(),
|
|
13130
13180
|
isServerRequest: false,
|
|
13131
13181
|
replayModeHandler: () => {
|
|
13132
13182
|
return SpanUtils.createAndExecuteSpan(self.mode, () => Promise.resolve(), {
|
|
13133
13183
|
name: "postgres.cursor",
|
|
13134
|
-
kind: import_src$
|
|
13184
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13135
13185
|
submodule: "cursor",
|
|
13136
13186
|
packageType: PackageType.PG,
|
|
13137
13187
|
packageName: "postgres",
|
|
13138
13188
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13139
13189
|
inputValue,
|
|
13190
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13140
13191
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13141
13192
|
}, async (spanInfo) => {
|
|
13142
13193
|
try {
|
|
@@ -13156,11 +13207,11 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13156
13207
|
logger.debug(`[PostgresInstrumentation] Cursor replay calling callback with batch of ${batch.length} rows`);
|
|
13157
13208
|
await userCallback(batch);
|
|
13158
13209
|
}
|
|
13159
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13210
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13160
13211
|
} catch (error) {
|
|
13161
13212
|
logger.debug(`[PostgresInstrumentation] Cursor callback replay error: ${error.message}`);
|
|
13162
13213
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13163
|
-
code: import_src$
|
|
13214
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13164
13215
|
message: error.message
|
|
13165
13216
|
});
|
|
13166
13217
|
throw error;
|
|
@@ -13180,7 +13231,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13180
13231
|
let spanStarted = false;
|
|
13181
13232
|
return {
|
|
13182
13233
|
async next() {
|
|
13183
|
-
return import_src$
|
|
13234
|
+
return import_src$27.context.with(creationContext, async () => {
|
|
13184
13235
|
if (!spanStarted) {
|
|
13185
13236
|
spanStarted = true;
|
|
13186
13237
|
let spanInputValue;
|
|
@@ -13192,7 +13243,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13192
13243
|
}
|
|
13193
13244
|
spanInfo = SpanUtils.createSpan({
|
|
13194
13245
|
name: "postgres.cursor",
|
|
13195
|
-
kind: import_src$
|
|
13246
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13196
13247
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true,
|
|
13197
13248
|
attributes: {
|
|
13198
13249
|
[TdSpanAttributes.NAME]: "postgres.cursor",
|
|
@@ -13227,7 +13278,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13227
13278
|
} catch (error) {
|
|
13228
13279
|
if (spanInfo) try {
|
|
13229
13280
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13230
|
-
code: import_src$
|
|
13281
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13231
13282
|
message: error.message
|
|
13232
13283
|
});
|
|
13233
13284
|
} catch (error$1) {
|
|
@@ -13262,12 +13313,12 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13262
13313
|
let dataFetched = false;
|
|
13263
13314
|
return {
|
|
13264
13315
|
async next() {
|
|
13265
|
-
return import_src$
|
|
13316
|
+
return import_src$27.context.with(creationContext, async () => {
|
|
13266
13317
|
if (!dataFetched) {
|
|
13267
13318
|
dataFetched = true;
|
|
13268
13319
|
spanInfo = SpanUtils.createSpan({
|
|
13269
13320
|
name: "postgres.cursor",
|
|
13270
|
-
kind: import_src$
|
|
13321
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13271
13322
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true,
|
|
13272
13323
|
attributes: {
|
|
13273
13324
|
[TdSpanAttributes.NAME]: "postgres.cursor",
|
|
@@ -13289,7 +13340,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13289
13340
|
});
|
|
13290
13341
|
if (!mockData) {
|
|
13291
13342
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13292
|
-
code: import_src$
|
|
13343
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13293
13344
|
message: "No mock data found"
|
|
13294
13345
|
});
|
|
13295
13346
|
throw new Error(`[PostgresInstrumentation] No matching mock found for cursor query: ${inputValue.query}`);
|
|
@@ -13299,7 +13350,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13299
13350
|
mockedData = Array.isArray(processedResult) ? processedResult : [];
|
|
13300
13351
|
}
|
|
13301
13352
|
if (currentIndex >= mockedData.length) {
|
|
13302
|
-
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13353
|
+
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13303
13354
|
return {
|
|
13304
13355
|
done: true,
|
|
13305
13356
|
value: void 0
|
|
@@ -13315,7 +13366,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13315
13366
|
});
|
|
13316
13367
|
},
|
|
13317
13368
|
async return() {
|
|
13318
|
-
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13369
|
+
if (spanInfo) SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13319
13370
|
return {
|
|
13320
13371
|
done: true,
|
|
13321
13372
|
value: void 0
|
|
@@ -13326,18 +13377,19 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13326
13377
|
}
|
|
13327
13378
|
_handleForEachRecord({ originalForEach, inputValue, creationContext, userCallback }) {
|
|
13328
13379
|
const self = this;
|
|
13329
|
-
return import_src$
|
|
13380
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13330
13381
|
return handleRecordMode({
|
|
13331
13382
|
originalFunctionCall: () => originalForEach(userCallback),
|
|
13332
13383
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
13333
13384
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalForEach(userCallback), {
|
|
13334
13385
|
name: "postgres.query",
|
|
13335
|
-
kind: import_src$
|
|
13386
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13336
13387
|
submodule: "query",
|
|
13337
13388
|
packageType: PackageType.PG,
|
|
13338
13389
|
packageName: "postgres",
|
|
13339
13390
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13340
13391
|
inputValue,
|
|
13392
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13341
13393
|
isPreAppStart
|
|
13342
13394
|
}, async (spanInfo) => {
|
|
13343
13395
|
const allRows = [];
|
|
@@ -13356,7 +13408,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13356
13408
|
} catch (error) {
|
|
13357
13409
|
try {
|
|
13358
13410
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13359
|
-
code: import_src$
|
|
13411
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13360
13412
|
message: error.message
|
|
13361
13413
|
});
|
|
13362
13414
|
} catch (error$1) {
|
|
@@ -13366,14 +13418,14 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13366
13418
|
}
|
|
13367
13419
|
});
|
|
13368
13420
|
},
|
|
13369
|
-
spanKind: import_src$
|
|
13421
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
13370
13422
|
});
|
|
13371
13423
|
});
|
|
13372
13424
|
}
|
|
13373
13425
|
_handleForEachReplay({ inputValue, creationContext, userCallback }) {
|
|
13374
13426
|
const self = this;
|
|
13375
13427
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
13376
|
-
return import_src$
|
|
13428
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13377
13429
|
return handleReplayMode({
|
|
13378
13430
|
noOpRequestHandler: () => Promise.resolve(Object.assign([], {
|
|
13379
13431
|
count: 0,
|
|
@@ -13386,12 +13438,13 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13386
13438
|
command: null
|
|
13387
13439
|
})), {
|
|
13388
13440
|
name: "postgres.query",
|
|
13389
|
-
kind: import_src$
|
|
13441
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13390
13442
|
submodule: "query",
|
|
13391
13443
|
packageType: PackageType.PG,
|
|
13392
13444
|
packageName: "postgres",
|
|
13393
13445
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13394
13446
|
inputValue,
|
|
13447
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13395
13448
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13396
13449
|
}, async (spanInfo) => {
|
|
13397
13450
|
try {
|
|
@@ -13406,7 +13459,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13406
13459
|
const mockedRows = Array.isArray(mockedResult) ? mockedResult : [];
|
|
13407
13460
|
logger.debug(`[PostgresInstrumentation] forEach replay: calling callback with ${mockedRows.length} mocked rows`);
|
|
13408
13461
|
for (const row of mockedRows) userCallback(row, mockedResult);
|
|
13409
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13462
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13410
13463
|
return Object.assign([], {
|
|
13411
13464
|
count: mockedRows.length,
|
|
13412
13465
|
command: null
|
|
@@ -13414,7 +13467,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13414
13467
|
} catch (error) {
|
|
13415
13468
|
logger.debug(`[PostgresInstrumentation] forEach replay error: ${error.message}`);
|
|
13416
13469
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13417
|
-
code: import_src$
|
|
13470
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13418
13471
|
message: error.message
|
|
13419
13472
|
});
|
|
13420
13473
|
throw error;
|
|
@@ -13434,25 +13487,26 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13434
13487
|
if (query._forEachCalled) return originalThen(onFulfilled, onRejected);
|
|
13435
13488
|
if (query._tuskRecorded) return originalThen(onFulfilled, onRejected);
|
|
13436
13489
|
query._tuskRecorded = true;
|
|
13437
|
-
return import_src$
|
|
13490
|
+
return import_src$27.context.with(creationContext, () => {
|
|
13438
13491
|
if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
13439
13492
|
originalFunctionCall: () => originalThen(onFulfilled, onRejected),
|
|
13440
13493
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
13441
13494
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
13442
13495
|
name: spanConfig.name,
|
|
13443
|
-
kind: import_src$
|
|
13496
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13444
13497
|
submodule: spanConfig.submodule,
|
|
13445
13498
|
packageType: PackageType.PG,
|
|
13446
13499
|
packageName: "postgres",
|
|
13447
13500
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13448
13501
|
inputValue,
|
|
13502
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13449
13503
|
isPreAppStart
|
|
13450
13504
|
}, (spanInfo) => {
|
|
13451
13505
|
const wrappedOnFulfilled = (result) => {
|
|
13452
13506
|
try {
|
|
13453
13507
|
logger.debug(`[PostgresInstrumentation] Postgres ${spanConfig.operationType} query completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
13454
13508
|
addOutputAttributesToSpan(spanInfo, result);
|
|
13455
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
13509
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$27.SpanStatusCode.OK });
|
|
13456
13510
|
} catch (error) {
|
|
13457
13511
|
logger.error(`[PostgresInstrumentation] error processing ${spanConfig.operationType} query response:`, error);
|
|
13458
13512
|
}
|
|
@@ -13462,7 +13516,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13462
13516
|
try {
|
|
13463
13517
|
logger.debug(`[PostgresInstrumentation] Postgres ${spanConfig.operationType} query error: ${error.message}`);
|
|
13464
13518
|
SpanUtils.endSpan(spanInfo.span, {
|
|
13465
|
-
code: import_src$
|
|
13519
|
+
code: import_src$27.SpanStatusCode.ERROR,
|
|
13466
13520
|
message: error.message
|
|
13467
13521
|
});
|
|
13468
13522
|
} catch (spanError) {
|
|
@@ -13474,7 +13528,7 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13474
13528
|
return originalThen(wrappedOnFulfilled, wrappedOnRejected);
|
|
13475
13529
|
});
|
|
13476
13530
|
},
|
|
13477
|
-
spanKind: import_src$
|
|
13531
|
+
spanKind: import_src$27.SpanKind.CLIENT
|
|
13478
13532
|
});
|
|
13479
13533
|
else if (self.mode === TuskDriftMode.REPLAY) {
|
|
13480
13534
|
const stackTrace = captureStackTrace(["PostgresInstrumentation"]);
|
|
@@ -13487,12 +13541,13 @@ var PostgresInstrumentation = class extends TdInstrumentationBase {
|
|
|
13487
13541
|
replayModeHandler: () => {
|
|
13488
13542
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalThen(onFulfilled, onRejected), {
|
|
13489
13543
|
name: spanConfig.name,
|
|
13490
|
-
kind: import_src$
|
|
13544
|
+
kind: import_src$27.SpanKind.CLIENT,
|
|
13491
13545
|
submodule: spanConfig.submodule,
|
|
13492
13546
|
packageType: PackageType.PG,
|
|
13493
13547
|
packageName: "postgres",
|
|
13494
13548
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
13495
13549
|
inputValue,
|
|
13550
|
+
inputSchemaMerges: { parameters: { matchImportance: 0 } },
|
|
13496
13551
|
isPreAppStart: self.tuskDrift.isAppReady() ? false : true
|
|
13497
13552
|
}, async (spanInfo) => {
|
|
13498
13553
|
const mockedResult = await self._handleReplayQueryOperation({
|
|
@@ -13768,7 +13823,7 @@ var TdMysqlConnectionMock = class extends EventEmitter {
|
|
|
13768
13823
|
|
|
13769
13824
|
//#endregion
|
|
13770
13825
|
//#region src/instrumentation/libraries/mysql/mocks/TdMysqlQueryMock.ts
|
|
13771
|
-
var import_src$
|
|
13826
|
+
var import_src$26 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
13772
13827
|
/**
|
|
13773
13828
|
* Handles replay mode for MySQL query operations
|
|
13774
13829
|
* Returns EventEmitters synchronously to support both callback and streaming modes
|
|
@@ -13889,17 +13944,18 @@ var TdMysqlQueryMock = class {
|
|
|
13889
13944
|
packageName: "mysql",
|
|
13890
13945
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
13891
13946
|
submoduleName: "query",
|
|
13892
|
-
kind: import_src$
|
|
13947
|
+
kind: import_src$26.SpanKind.CLIENT,
|
|
13893
13948
|
stackTrace
|
|
13894
13949
|
},
|
|
13895
|
-
tuskDrift: this.tuskDrift
|
|
13950
|
+
tuskDrift: this.tuskDrift,
|
|
13951
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
13896
13952
|
});
|
|
13897
13953
|
}
|
|
13898
13954
|
};
|
|
13899
13955
|
|
|
13900
13956
|
//#endregion
|
|
13901
13957
|
//#region src/instrumentation/libraries/mysql/Instrumentation.ts
|
|
13902
|
-
var import_src$
|
|
13958
|
+
var import_src$25 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
13903
13959
|
var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
13904
13960
|
constructor(config = {}) {
|
|
13905
13961
|
super("mysql", config);
|
|
@@ -14142,12 +14198,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14142
14198
|
replayModeHandler: () => {
|
|
14143
14199
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
14144
14200
|
name: "mysql.query",
|
|
14145
|
-
kind: import_src$
|
|
14201
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14146
14202
|
submodule: "query",
|
|
14147
14203
|
packageType: PackageType.MYSQL,
|
|
14148
14204
|
packageName: "mysql",
|
|
14149
14205
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14150
14206
|
inputValue,
|
|
14207
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14151
14208
|
isPreAppStart: false
|
|
14152
14209
|
}, (spanInfo) => {
|
|
14153
14210
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -14168,18 +14225,19 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14168
14225
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14169
14226
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
14170
14227
|
name: "mysql.query",
|
|
14171
|
-
kind: import_src$
|
|
14228
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14172
14229
|
submodule: "query",
|
|
14173
14230
|
packageType: PackageType.MYSQL,
|
|
14174
14231
|
packageName: "mysql",
|
|
14175
14232
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14176
14233
|
inputValue,
|
|
14234
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14177
14235
|
isPreAppStart
|
|
14178
14236
|
}, (spanInfo) => {
|
|
14179
14237
|
return self._handleRecordQuery(spanInfo, originalQuery, this, args, callback, isEventEmitterMode);
|
|
14180
14238
|
});
|
|
14181
14239
|
},
|
|
14182
|
-
spanKind: import_src$
|
|
14240
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14183
14241
|
});
|
|
14184
14242
|
else return originalQuery.apply(this, args);
|
|
14185
14243
|
};
|
|
@@ -14210,7 +14268,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14210
14268
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14211
14269
|
return originalConnect.apply(this, arguments);
|
|
14212
14270
|
},
|
|
14213
|
-
spanKind: import_src$
|
|
14271
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14214
14272
|
});
|
|
14215
14273
|
else return originalConnect.apply(this, arguments);
|
|
14216
14274
|
};
|
|
@@ -14235,7 +14293,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14235
14293
|
replayModeHandler: () => {
|
|
14236
14294
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(this, arguments), {
|
|
14237
14295
|
name: "mysql.beginTransaction",
|
|
14238
|
-
kind: import_src$
|
|
14296
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14239
14297
|
submodule: "transaction",
|
|
14240
14298
|
packageType: PackageType.MYSQL,
|
|
14241
14299
|
packageName: "mysql",
|
|
@@ -14252,7 +14310,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14252
14310
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14253
14311
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(this, arguments), {
|
|
14254
14312
|
name: "mysql.beginTransaction",
|
|
14255
|
-
kind: import_src$
|
|
14313
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14256
14314
|
submodule: "transaction",
|
|
14257
14315
|
packageType: PackageType.MYSQL,
|
|
14258
14316
|
packageName: "mysql",
|
|
@@ -14263,7 +14321,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14263
14321
|
return self._handleRecordTransaction(spanInfo, originalBeginTransaction, this, arguments, actualCallback);
|
|
14264
14322
|
});
|
|
14265
14323
|
},
|
|
14266
|
-
spanKind: import_src$
|
|
14324
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14267
14325
|
});
|
|
14268
14326
|
else return originalBeginTransaction.apply(this, arguments);
|
|
14269
14327
|
};
|
|
@@ -14288,7 +14346,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14288
14346
|
replayModeHandler: () => {
|
|
14289
14347
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(this, arguments), {
|
|
14290
14348
|
name: "mysql.commit",
|
|
14291
|
-
kind: import_src$
|
|
14349
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14292
14350
|
submodule: "transaction",
|
|
14293
14351
|
packageType: PackageType.MYSQL,
|
|
14294
14352
|
packageName: "mysql",
|
|
@@ -14305,7 +14363,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14305
14363
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14306
14364
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(this, arguments), {
|
|
14307
14365
|
name: "mysql.commit",
|
|
14308
|
-
kind: import_src$
|
|
14366
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14309
14367
|
submodule: "transaction",
|
|
14310
14368
|
packageType: PackageType.MYSQL,
|
|
14311
14369
|
packageName: "mysql",
|
|
@@ -14316,7 +14374,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14316
14374
|
return self._handleRecordTransaction(spanInfo, originalCommit, this, arguments, actualCallback);
|
|
14317
14375
|
});
|
|
14318
14376
|
},
|
|
14319
|
-
spanKind: import_src$
|
|
14377
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14320
14378
|
});
|
|
14321
14379
|
else return originalCommit.apply(this, arguments);
|
|
14322
14380
|
};
|
|
@@ -14341,7 +14399,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14341
14399
|
replayModeHandler: () => {
|
|
14342
14400
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(this, arguments), {
|
|
14343
14401
|
name: "mysql.rollback",
|
|
14344
|
-
kind: import_src$
|
|
14402
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14345
14403
|
submodule: "transaction",
|
|
14346
14404
|
packageType: PackageType.MYSQL,
|
|
14347
14405
|
packageName: "mysql",
|
|
@@ -14358,7 +14416,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14358
14416
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14359
14417
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(this, arguments), {
|
|
14360
14418
|
name: "mysql.rollback",
|
|
14361
|
-
kind: import_src$
|
|
14419
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14362
14420
|
submodule: "transaction",
|
|
14363
14421
|
packageType: PackageType.MYSQL,
|
|
14364
14422
|
packageName: "mysql",
|
|
@@ -14369,7 +14427,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14369
14427
|
return self._handleRecordTransaction(spanInfo, originalRollback, this, arguments, actualCallback);
|
|
14370
14428
|
});
|
|
14371
14429
|
},
|
|
14372
|
-
spanKind: import_src$
|
|
14430
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14373
14431
|
});
|
|
14374
14432
|
else return originalRollback.apply(this, arguments);
|
|
14375
14433
|
};
|
|
@@ -14396,7 +14454,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14396
14454
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14397
14455
|
return originalPing.apply(this, arguments);
|
|
14398
14456
|
},
|
|
14399
|
-
spanKind: import_src$
|
|
14457
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14400
14458
|
});
|
|
14401
14459
|
else return originalPing.apply(this, arguments);
|
|
14402
14460
|
};
|
|
@@ -14425,7 +14483,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14425
14483
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14426
14484
|
return originalEnd.apply(this, arguments);
|
|
14427
14485
|
},
|
|
14428
|
-
spanKind: import_src$
|
|
14486
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14429
14487
|
});
|
|
14430
14488
|
else return originalEnd.apply(this, arguments);
|
|
14431
14489
|
};
|
|
@@ -14454,7 +14512,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14454
14512
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14455
14513
|
return originalChangeUser.apply(this, arguments);
|
|
14456
14514
|
},
|
|
14457
|
-
spanKind: import_src$
|
|
14515
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14458
14516
|
});
|
|
14459
14517
|
else return originalChangeUser.apply(this, arguments);
|
|
14460
14518
|
};
|
|
@@ -14520,7 +14578,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14520
14578
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14521
14579
|
return originalEnd.apply(this, arguments);
|
|
14522
14580
|
},
|
|
14523
|
-
spanKind: import_src$
|
|
14581
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14524
14582
|
});
|
|
14525
14583
|
else return originalEnd.apply(this, arguments);
|
|
14526
14584
|
};
|
|
@@ -14543,7 +14601,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14543
14601
|
replayModeHandler: () => {
|
|
14544
14602
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
14545
14603
|
name: `mysql.pool.getConnection`,
|
|
14546
|
-
kind: import_src$
|
|
14604
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14547
14605
|
submodule: "getConnection",
|
|
14548
14606
|
packageName: "mysql",
|
|
14549
14607
|
packageType: PackageType.MYSQL,
|
|
@@ -14560,7 +14618,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14560
14618
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14561
14619
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
14562
14620
|
name: `mysql.pool.getConnection`,
|
|
14563
|
-
kind: import_src$
|
|
14621
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14564
14622
|
submodule: "getConnection",
|
|
14565
14623
|
packageName: "mysql",
|
|
14566
14624
|
packageType: PackageType.MYSQL,
|
|
@@ -14571,7 +14629,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14571
14629
|
return self._handleRecordPoolGetConnectionInSpan(spanInfo, originalGetConnection, callback, this);
|
|
14572
14630
|
});
|
|
14573
14631
|
},
|
|
14574
|
-
spanKind: import_src$
|
|
14632
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14575
14633
|
});
|
|
14576
14634
|
else return originalGetConnection.apply(this, [callback]);
|
|
14577
14635
|
};
|
|
@@ -14615,12 +14673,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14615
14673
|
replayModeHandler: () => {
|
|
14616
14674
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(connection, args), {
|
|
14617
14675
|
name: "mysql.query",
|
|
14618
|
-
kind: import_src$
|
|
14676
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14619
14677
|
submodule: "query",
|
|
14620
14678
|
packageType: PackageType.MYSQL,
|
|
14621
14679
|
packageName: "mysql",
|
|
14622
14680
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14623
14681
|
inputValue,
|
|
14682
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14624
14683
|
isPreAppStart: false
|
|
14625
14684
|
}, (spanInfo) => {
|
|
14626
14685
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -14641,18 +14700,19 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14641
14700
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14642
14701
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(connection, args), {
|
|
14643
14702
|
name: "mysql.query",
|
|
14644
|
-
kind: import_src$
|
|
14703
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14645
14704
|
submodule: "query",
|
|
14646
14705
|
packageType: PackageType.MYSQL,
|
|
14647
14706
|
packageName: "mysql",
|
|
14648
14707
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
14649
14708
|
inputValue,
|
|
14709
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
14650
14710
|
isPreAppStart
|
|
14651
14711
|
}, (spanInfo) => {
|
|
14652
14712
|
return self._handleRecordQuery(spanInfo, originalQuery, connection, args, callback, isEventEmitterMode);
|
|
14653
14713
|
});
|
|
14654
14714
|
},
|
|
14655
|
-
spanKind: import_src$
|
|
14715
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14656
14716
|
});
|
|
14657
14717
|
else return originalQuery.apply(connection, args);
|
|
14658
14718
|
};
|
|
@@ -14690,7 +14750,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14690
14750
|
};
|
|
14691
14751
|
if (error) try {
|
|
14692
14752
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14693
|
-
code: import_src$
|
|
14753
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14694
14754
|
message: error.message
|
|
14695
14755
|
});
|
|
14696
14756
|
} catch (error$1) {
|
|
@@ -14698,7 +14758,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14698
14758
|
}
|
|
14699
14759
|
else try {
|
|
14700
14760
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
14701
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
14761
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14702
14762
|
} catch (error$1) {
|
|
14703
14763
|
logger.error(`[MysqlInstrumentation] error ending span:`, error$1);
|
|
14704
14764
|
}
|
|
@@ -14712,7 +14772,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14712
14772
|
queryObject._callback = function(err, results, fields) {
|
|
14713
14773
|
if (err) try {
|
|
14714
14774
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14715
|
-
code: import_src$
|
|
14775
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14716
14776
|
message: err.message
|
|
14717
14777
|
});
|
|
14718
14778
|
} catch (error) {
|
|
@@ -14724,7 +14784,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14724
14784
|
fields
|
|
14725
14785
|
};
|
|
14726
14786
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
14727
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
14787
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14728
14788
|
} catch (error) {
|
|
14729
14789
|
logger.error(`[MysqlInstrumentation] error ending span:`, error);
|
|
14730
14790
|
}
|
|
@@ -14738,7 +14798,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14738
14798
|
args[callbackIndex] = function(err, results, fields) {
|
|
14739
14799
|
if (err) try {
|
|
14740
14800
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14741
|
-
code: import_src$
|
|
14801
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14742
14802
|
message: err.message
|
|
14743
14803
|
});
|
|
14744
14804
|
} catch (error) {
|
|
@@ -14750,7 +14810,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14750
14810
|
fields
|
|
14751
14811
|
};
|
|
14752
14812
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
14753
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
14813
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14754
14814
|
} catch (error) {
|
|
14755
14815
|
logger.error(`[MysqlInstrumentation] error ending span:`, error);
|
|
14756
14816
|
}
|
|
@@ -14778,7 +14838,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14778
14838
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14779
14839
|
return originalConnect.apply(connection, arguments);
|
|
14780
14840
|
},
|
|
14781
|
-
spanKind: import_src$
|
|
14841
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14782
14842
|
});
|
|
14783
14843
|
else return originalConnect.apply(connection, arguments);
|
|
14784
14844
|
};
|
|
@@ -14800,7 +14860,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14800
14860
|
replayModeHandler: () => {
|
|
14801
14861
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(connection, arguments), {
|
|
14802
14862
|
name: "mysql.beginTransaction",
|
|
14803
|
-
kind: import_src$
|
|
14863
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14804
14864
|
submodule: "transaction",
|
|
14805
14865
|
packageType: PackageType.MYSQL,
|
|
14806
14866
|
packageName: "mysql",
|
|
@@ -14817,7 +14877,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14817
14877
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14818
14878
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalBeginTransaction.apply(connection, arguments), {
|
|
14819
14879
|
name: "mysql.beginTransaction",
|
|
14820
|
-
kind: import_src$
|
|
14880
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14821
14881
|
submodule: "transaction",
|
|
14822
14882
|
packageType: PackageType.MYSQL,
|
|
14823
14883
|
packageName: "mysql",
|
|
@@ -14828,7 +14888,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14828
14888
|
return self._handleRecordTransaction(spanInfo, originalBeginTransaction, connection, arguments, actualCallback);
|
|
14829
14889
|
});
|
|
14830
14890
|
},
|
|
14831
|
-
spanKind: import_src$
|
|
14891
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14832
14892
|
});
|
|
14833
14893
|
else return originalBeginTransaction.apply(connection, arguments);
|
|
14834
14894
|
};
|
|
@@ -14850,7 +14910,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14850
14910
|
replayModeHandler: () => {
|
|
14851
14911
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(connection, arguments), {
|
|
14852
14912
|
name: "mysql.commit",
|
|
14853
|
-
kind: import_src$
|
|
14913
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14854
14914
|
submodule: "transaction",
|
|
14855
14915
|
packageType: PackageType.MYSQL,
|
|
14856
14916
|
packageName: "mysql",
|
|
@@ -14867,7 +14927,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14867
14927
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14868
14928
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCommit.apply(connection, arguments), {
|
|
14869
14929
|
name: "mysql.commit",
|
|
14870
|
-
kind: import_src$
|
|
14930
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14871
14931
|
submodule: "transaction",
|
|
14872
14932
|
packageType: PackageType.MYSQL,
|
|
14873
14933
|
packageName: "mysql",
|
|
@@ -14878,7 +14938,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14878
14938
|
return self._handleRecordTransaction(spanInfo, originalCommit, connection, arguments, actualCallback);
|
|
14879
14939
|
});
|
|
14880
14940
|
},
|
|
14881
|
-
spanKind: import_src$
|
|
14941
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14882
14942
|
});
|
|
14883
14943
|
else return originalCommit.apply(connection, arguments);
|
|
14884
14944
|
};
|
|
@@ -14900,7 +14960,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14900
14960
|
replayModeHandler: () => {
|
|
14901
14961
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(connection, arguments), {
|
|
14902
14962
|
name: "mysql.rollback",
|
|
14903
|
-
kind: import_src$
|
|
14963
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14904
14964
|
submodule: "transaction",
|
|
14905
14965
|
packageType: PackageType.MYSQL,
|
|
14906
14966
|
packageName: "mysql",
|
|
@@ -14917,7 +14977,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14917
14977
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
14918
14978
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalRollback.apply(connection, arguments), {
|
|
14919
14979
|
name: "mysql.rollback",
|
|
14920
|
-
kind: import_src$
|
|
14980
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
14921
14981
|
submodule: "transaction",
|
|
14922
14982
|
packageType: PackageType.MYSQL,
|
|
14923
14983
|
packageName: "mysql",
|
|
@@ -14928,7 +14988,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14928
14988
|
return self._handleRecordTransaction(spanInfo, originalRollback, connection, arguments, actualCallback);
|
|
14929
14989
|
});
|
|
14930
14990
|
},
|
|
14931
|
-
spanKind: import_src$
|
|
14991
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
14932
14992
|
});
|
|
14933
14993
|
else return originalRollback.apply(connection, arguments);
|
|
14934
14994
|
};
|
|
@@ -14939,7 +14999,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14939
14999
|
const result = originalFunction.apply(connection, args);
|
|
14940
15000
|
try {
|
|
14941
15001
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { status: "success" } });
|
|
14942
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15002
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14943
15003
|
} catch (error) {
|
|
14944
15004
|
logger.error(`[MysqlInstrumentation] error adding span attributes:`, error);
|
|
14945
15005
|
}
|
|
@@ -14947,7 +15007,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14947
15007
|
} catch (error) {
|
|
14948
15008
|
try {
|
|
14949
15009
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14950
|
-
code: import_src$
|
|
15010
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14951
15011
|
message: error.message
|
|
14952
15012
|
});
|
|
14953
15013
|
} catch (error$1) {
|
|
@@ -14962,7 +15022,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14962
15022
|
argsArray[callbackIndex] = function(err) {
|
|
14963
15023
|
if (err) try {
|
|
14964
15024
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14965
|
-
code: import_src$
|
|
15025
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14966
15026
|
message: err.message
|
|
14967
15027
|
});
|
|
14968
15028
|
} catch (error) {
|
|
@@ -14970,14 +15030,14 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14970
15030
|
}
|
|
14971
15031
|
else try {
|
|
14972
15032
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { status: "success" } });
|
|
14973
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15033
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
14974
15034
|
} catch (error) {
|
|
14975
15035
|
logger.error(`[MysqlInstrumentation] error ending span:`, error);
|
|
14976
15036
|
}
|
|
14977
15037
|
logger.debug(`[MysqlInstrumentation] Transaction completed`);
|
|
14978
15038
|
return originalCallback.apply(this, arguments);
|
|
14979
15039
|
};
|
|
14980
|
-
argsArray[callbackIndex] = import_src$
|
|
15040
|
+
argsArray[callbackIndex] = import_src$25.context.bind(spanInfo.context, argsArray[callbackIndex]);
|
|
14981
15041
|
}
|
|
14982
15042
|
return originalFunction.apply(connection, argsArray);
|
|
14983
15043
|
}
|
|
@@ -14994,7 +15054,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
14994
15054
|
if (error) {
|
|
14995
15055
|
logger.debug(`[MysqlInstrumentation] MySQL Pool getConnection error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
14996
15056
|
SpanUtils.endSpan(spanInfo.span, {
|
|
14997
|
-
code: import_src$
|
|
15057
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
14998
15058
|
message: error.message
|
|
14999
15059
|
});
|
|
15000
15060
|
} else {
|
|
@@ -15010,9 +15070,9 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15010
15070
|
connected: true,
|
|
15011
15071
|
hasConnection: !!connection
|
|
15012
15072
|
} });
|
|
15013
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15073
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
15014
15074
|
}
|
|
15015
|
-
return import_src$
|
|
15075
|
+
return import_src$25.context.bind(spanInfo.context, callback)(error, connection);
|
|
15016
15076
|
};
|
|
15017
15077
|
return originalGetConnection.call(poolContext, wrappedCallback);
|
|
15018
15078
|
} else try {
|
|
@@ -15021,11 +15081,11 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15021
15081
|
connected: true,
|
|
15022
15082
|
hasConnection: true
|
|
15023
15083
|
} });
|
|
15024
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15084
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
15025
15085
|
return result;
|
|
15026
15086
|
} catch (error) {
|
|
15027
15087
|
SpanUtils.endSpan(spanInfo.span, {
|
|
15028
|
-
code: import_src$
|
|
15088
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
15029
15089
|
message: error.message
|
|
15030
15090
|
});
|
|
15031
15091
|
throw error;
|
|
@@ -15102,12 +15162,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15102
15162
|
replayModeHandler: () => {
|
|
15103
15163
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalStream.apply(queryInstance, arguments), {
|
|
15104
15164
|
name: "mysql.stream",
|
|
15105
|
-
kind: import_src$
|
|
15165
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15106
15166
|
submodule: "stream",
|
|
15107
15167
|
packageType: PackageType.MYSQL,
|
|
15108
15168
|
packageName: "mysql",
|
|
15109
15169
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15110
15170
|
inputValue,
|
|
15171
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15111
15172
|
isPreAppStart: false
|
|
15112
15173
|
}, (spanInfo) => {
|
|
15113
15174
|
return self._handleReplayStream(inputValue, spanInfo, stackTrace, queryInstance);
|
|
@@ -15119,18 +15180,19 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15119
15180
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
15120
15181
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalStream.apply(queryInstance, arguments), {
|
|
15121
15182
|
name: "mysql.stream",
|
|
15122
|
-
kind: import_src$
|
|
15183
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15123
15184
|
submodule: "stream",
|
|
15124
15185
|
packageType: PackageType.MYSQL,
|
|
15125
15186
|
packageName: "mysql",
|
|
15126
15187
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15127
15188
|
inputValue,
|
|
15189
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15128
15190
|
isPreAppStart
|
|
15129
15191
|
}, (spanInfo) => {
|
|
15130
15192
|
return self._handleRecordStream(spanInfo, originalStream, queryInstance, streamOptions);
|
|
15131
15193
|
});
|
|
15132
15194
|
},
|
|
15133
|
-
spanKind: import_src$
|
|
15195
|
+
spanKind: import_src$25.SpanKind.CLIENT
|
|
15134
15196
|
});
|
|
15135
15197
|
else return originalStream.apply(queryInstance, arguments);
|
|
15136
15198
|
};
|
|
@@ -15203,7 +15265,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15203
15265
|
const isMultiStatementQuery = queryCount > 1;
|
|
15204
15266
|
if (error) try {
|
|
15205
15267
|
SpanUtils.endSpan(spanInfo.span, {
|
|
15206
|
-
code: import_src$
|
|
15268
|
+
code: import_src$25.SpanStatusCode.ERROR,
|
|
15207
15269
|
message: error.message
|
|
15208
15270
|
});
|
|
15209
15271
|
} catch (err) {
|
|
@@ -15221,7 +15283,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15221
15283
|
queryCount
|
|
15222
15284
|
};
|
|
15223
15285
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
15224
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
15286
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$25.SpanStatusCode.OK });
|
|
15225
15287
|
} catch (err) {
|
|
15226
15288
|
logger.error(`[MysqlInstrumentation] error ending span:`, err);
|
|
15227
15289
|
}
|
|
@@ -15330,12 +15392,13 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15330
15392
|
replayModeHandler: () => {
|
|
15331
15393
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
15332
15394
|
name: "mysql.query",
|
|
15333
|
-
kind: import_src$
|
|
15395
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15334
15396
|
submodule: "query",
|
|
15335
15397
|
packageType: PackageType.MYSQL,
|
|
15336
15398
|
packageName: "mysql",
|
|
15337
15399
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15338
15400
|
inputValue,
|
|
15401
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15339
15402
|
isPreAppStart: false
|
|
15340
15403
|
}, (spanInfo) => {
|
|
15341
15404
|
const queryEmitter = self.queryMock.handleReplayQuery({
|
|
@@ -15379,7 +15442,7 @@ var MysqlInstrumentation = class extends TdInstrumentationBase {
|
|
|
15379
15442
|
replayModeHandler: () => {
|
|
15380
15443
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(namespace, [callback]), {
|
|
15381
15444
|
name: `mysql.poolNamespace.getConnection`,
|
|
15382
|
-
kind: import_src$
|
|
15445
|
+
kind: import_src$25.SpanKind.CLIENT,
|
|
15383
15446
|
submodule: "getConnection",
|
|
15384
15447
|
packageName: "mysql",
|
|
15385
15448
|
packageType: PackageType.MYSQL,
|
|
@@ -15531,6 +15594,27 @@ var TdMysql2ConnectionMock = class extends EventEmitter {
|
|
|
15531
15594
|
}
|
|
15532
15595
|
return Promise.resolve();
|
|
15533
15596
|
}
|
|
15597
|
+
prepare(sql, callback) {
|
|
15598
|
+
const sqlStr = typeof sql === "string" ? sql : sql.sql;
|
|
15599
|
+
const self = this;
|
|
15600
|
+
const mockStatement = {
|
|
15601
|
+
query: sqlStr,
|
|
15602
|
+
id: 1,
|
|
15603
|
+
columns: [],
|
|
15604
|
+
parameters: [],
|
|
15605
|
+
execute: (...args) => {
|
|
15606
|
+
const values = Array.isArray(args[0]) ? args[0] : [];
|
|
15607
|
+
const execCallback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
15608
|
+
return self.mysql2Instrumentation.handleNoOpReplayQuery({
|
|
15609
|
+
sql: sqlStr,
|
|
15610
|
+
values,
|
|
15611
|
+
callback: execCallback
|
|
15612
|
+
});
|
|
15613
|
+
},
|
|
15614
|
+
close: () => {}
|
|
15615
|
+
};
|
|
15616
|
+
if (callback) process.nextTick(() => callback(null, mockStatement));
|
|
15617
|
+
}
|
|
15534
15618
|
pause() {}
|
|
15535
15619
|
resume() {}
|
|
15536
15620
|
escape(value) {
|
|
@@ -15556,7 +15640,7 @@ var TdMysql2ConnectionMock = class extends EventEmitter {
|
|
|
15556
15640
|
|
|
15557
15641
|
//#endregion
|
|
15558
15642
|
//#region src/instrumentation/libraries/mysql2/mocks/TdMysql2QueryMock.ts
|
|
15559
|
-
var import_src$
|
|
15643
|
+
var import_src$24 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
15560
15644
|
/**
|
|
15561
15645
|
* Handles replay mode for MySQL2 query operations
|
|
15562
15646
|
*/
|
|
@@ -15587,6 +15671,10 @@ var TdMysql2QueryMock = class {
|
|
|
15587
15671
|
});
|
|
15588
15672
|
}).then(onResolve, onReject);
|
|
15589
15673
|
};
|
|
15674
|
+
const self = this;
|
|
15675
|
+
emitter.stream = function(streamOptions) {
|
|
15676
|
+
return self._createReplayStreamForQuery(emitter, streamOptions);
|
|
15677
|
+
};
|
|
15590
15678
|
process.nextTick(() => {
|
|
15591
15679
|
const callback = queryConfig.callback;
|
|
15592
15680
|
if (callback) callback(null, [], []);
|
|
@@ -15613,6 +15701,10 @@ var TdMysql2QueryMock = class {
|
|
|
15613
15701
|
});
|
|
15614
15702
|
}).then(onResolve, onReject);
|
|
15615
15703
|
};
|
|
15704
|
+
const self = this;
|
|
15705
|
+
emitter.stream = function(streamOptions) {
|
|
15706
|
+
return self._createReplayStreamForQuery(emitter, streamOptions);
|
|
15707
|
+
};
|
|
15616
15708
|
(async () => {
|
|
15617
15709
|
try {
|
|
15618
15710
|
const mockData = await this._fetchMockData(inputValue, spanInfo, spanName, submoduleName, stackTrace);
|
|
@@ -15653,13 +15745,51 @@ var TdMysql2QueryMock = class {
|
|
|
15653
15745
|
packageName: "mysql2",
|
|
15654
15746
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
15655
15747
|
submoduleName,
|
|
15656
|
-
kind: import_src$
|
|
15748
|
+
kind: import_src$24.SpanKind.CLIENT,
|
|
15657
15749
|
stackTrace
|
|
15658
15750
|
},
|
|
15659
|
-
tuskDrift: this.tuskDrift
|
|
15751
|
+
tuskDrift: this.tuskDrift,
|
|
15752
|
+
inputValueSchemaMerges: { values: { matchImportance: 0 } }
|
|
15660
15753
|
});
|
|
15661
15754
|
}
|
|
15662
15755
|
/**
|
|
15756
|
+
* Create a replay stream for query.stream() calls
|
|
15757
|
+
* This is called when user calls query.stream() on a query object
|
|
15758
|
+
*/
|
|
15759
|
+
_createReplayStreamForQuery(queryEmitter, streamOptions) {
|
|
15760
|
+
logger.debug(`[Mysql2Instrumentation] Creating replay stream for query.stream()`);
|
|
15761
|
+
const readableStream = new Readable({
|
|
15762
|
+
objectMode: true,
|
|
15763
|
+
read() {}
|
|
15764
|
+
});
|
|
15765
|
+
queryEmitter.on("result", (row) => {
|
|
15766
|
+
readableStream.push(row);
|
|
15767
|
+
});
|
|
15768
|
+
queryEmitter.on("error", (err) => {
|
|
15769
|
+
readableStream.destroy(err);
|
|
15770
|
+
});
|
|
15771
|
+
queryEmitter.on("end", () => {
|
|
15772
|
+
readableStream.push(null);
|
|
15773
|
+
});
|
|
15774
|
+
return readableStream;
|
|
15775
|
+
}
|
|
15776
|
+
/**
|
|
15777
|
+
* Recursively restore Buffer objects from their JSON serialized form.
|
|
15778
|
+
* JSON.stringify converts Buffer to {"type":"Buffer","data":[...]}
|
|
15779
|
+
* This function converts them back to actual Buffer instances.
|
|
15780
|
+
*/
|
|
15781
|
+
_restoreBuffers(obj) {
|
|
15782
|
+
if (obj === null || obj === void 0) return obj;
|
|
15783
|
+
if (typeof obj === "object" && obj.type === "Buffer" && Array.isArray(obj.data)) return Buffer.from(obj.data);
|
|
15784
|
+
if (Array.isArray(obj)) return obj.map((item) => this._restoreBuffers(item));
|
|
15785
|
+
if (typeof obj === "object") {
|
|
15786
|
+
const result = {};
|
|
15787
|
+
for (const key of Object.keys(obj)) result[key] = this._restoreBuffers(obj[key]);
|
|
15788
|
+
return result;
|
|
15789
|
+
}
|
|
15790
|
+
return obj;
|
|
15791
|
+
}
|
|
15792
|
+
/**
|
|
15663
15793
|
* Convert stored MySQL2 values back to appropriate JavaScript types
|
|
15664
15794
|
*/
|
|
15665
15795
|
_convertMysql2Types(result) {
|
|
@@ -15667,12 +15797,17 @@ var TdMysql2QueryMock = class {
|
|
|
15667
15797
|
rows: [],
|
|
15668
15798
|
fields: []
|
|
15669
15799
|
};
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15800
|
+
const restoredResult = this._restoreBuffers(result);
|
|
15801
|
+
if (restoredResult.rows !== void 0 && restoredResult.fields !== void 0) return {
|
|
15802
|
+
rows: restoredResult.rows,
|
|
15803
|
+
fields: restoredResult.fields
|
|
15804
|
+
};
|
|
15805
|
+
if (restoredResult.affectedRows !== void 0) return {
|
|
15806
|
+
rows: restoredResult,
|
|
15807
|
+
fields: []
|
|
15673
15808
|
};
|
|
15674
15809
|
return {
|
|
15675
|
-
rows:
|
|
15810
|
+
rows: restoredResult,
|
|
15676
15811
|
fields: []
|
|
15677
15812
|
};
|
|
15678
15813
|
}
|
|
@@ -15680,7 +15815,7 @@ var TdMysql2QueryMock = class {
|
|
|
15680
15815
|
|
|
15681
15816
|
//#endregion
|
|
15682
15817
|
//#region src/instrumentation/libraries/mysql2/mocks/TdMysql2ConnectionEventMock.ts
|
|
15683
|
-
var import_src$
|
|
15818
|
+
var import_src$23 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
15684
15819
|
/**
|
|
15685
15820
|
* Mock for MySQL2 connection events (connect/error)
|
|
15686
15821
|
* Handles replay of recorded connection establishment events in REPLAY mode
|
|
@@ -15709,7 +15844,7 @@ var TdMysql2ConnectionEventMock = class {
|
|
|
15709
15844
|
packageName: "mysql2",
|
|
15710
15845
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
15711
15846
|
submoduleName: "connectEvent",
|
|
15712
|
-
kind: import_src$
|
|
15847
|
+
kind: import_src$23.SpanKind.CLIENT
|
|
15713
15848
|
},
|
|
15714
15849
|
tuskDrift: this.tuskDrift
|
|
15715
15850
|
});
|
|
@@ -15727,7 +15862,7 @@ var TdMysql2ConnectionEventMock = class {
|
|
|
15727
15862
|
|
|
15728
15863
|
//#endregion
|
|
15729
15864
|
//#region src/instrumentation/libraries/mysql2/Instrumentation.ts
|
|
15730
|
-
var import_src$
|
|
15865
|
+
var import_src$22 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
15731
15866
|
const COMPLETE_SUPPORTED_VERSIONS = ">=2.3.3 <4.0.0";
|
|
15732
15867
|
const V2_3_3_TO_3_11_4 = ">=2.3.3 <3.11.5";
|
|
15733
15868
|
const V3_11_5_TO_4_0 = ">=3.11.5 <4.0.0";
|
|
@@ -15817,6 +15952,18 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15817
15952
|
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.end`);
|
|
15818
15953
|
}
|
|
15819
15954
|
}
|
|
15955
|
+
if (BaseConnectionClass.prototype && BaseConnectionClass.prototype.prepare) {
|
|
15956
|
+
if (!isWrapped$1(BaseConnectionClass.prototype.prepare)) {
|
|
15957
|
+
this._wrap(BaseConnectionClass.prototype, "prepare", this._getPreparePatchFn("connection"));
|
|
15958
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.prepare`);
|
|
15959
|
+
}
|
|
15960
|
+
}
|
|
15961
|
+
if (BaseConnectionClass.prototype && BaseConnectionClass.prototype.changeUser) {
|
|
15962
|
+
if (!isWrapped$1(BaseConnectionClass.prototype.changeUser)) {
|
|
15963
|
+
this._wrap(BaseConnectionClass.prototype, "changeUser", this._getChangeUserPatchFn("connection"));
|
|
15964
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped BaseConnection.prototype.changeUser`);
|
|
15965
|
+
}
|
|
15966
|
+
}
|
|
15820
15967
|
this.markModuleAsPatched(BaseConnectionClass);
|
|
15821
15968
|
logger.debug(`[Mysql2Instrumentation] BaseConnection class patching complete`);
|
|
15822
15969
|
return BaseConnectionClass;
|
|
@@ -15868,6 +16015,18 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15868
16015
|
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.end`);
|
|
15869
16016
|
}
|
|
15870
16017
|
}
|
|
16018
|
+
if (ConnectionClass.prototype && ConnectionClass.prototype.prepare) {
|
|
16019
|
+
if (!isWrapped$1(ConnectionClass.prototype.prepare)) {
|
|
16020
|
+
this._wrap(ConnectionClass.prototype, "prepare", this._getPreparePatchFn("connection"));
|
|
16021
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.prepare`);
|
|
16022
|
+
}
|
|
16023
|
+
}
|
|
16024
|
+
if (ConnectionClass.prototype && ConnectionClass.prototype.changeUser) {
|
|
16025
|
+
if (!isWrapped$1(ConnectionClass.prototype.changeUser)) {
|
|
16026
|
+
this._wrap(ConnectionClass.prototype, "changeUser", this._getChangeUserPatchFn("connection"));
|
|
16027
|
+
logger.debug(`[Mysql2Instrumentation] Wrapped Connection.prototype.changeUser`);
|
|
16028
|
+
}
|
|
16029
|
+
}
|
|
15871
16030
|
}
|
|
15872
16031
|
_patchPoolV2(PoolClass) {
|
|
15873
16032
|
logger.debug(`[Mysql2Instrumentation] Patching Pool class (v2)`);
|
|
@@ -15955,12 +16114,13 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15955
16114
|
const spanName = `mysql2.${clientType}.query`;
|
|
15956
16115
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
15957
16116
|
name: spanName,
|
|
15958
|
-
kind: import_src$
|
|
16117
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
15959
16118
|
submodule: "query",
|
|
15960
16119
|
packageType: PackageType.MYSQL,
|
|
15961
16120
|
packageName: "mysql2",
|
|
15962
16121
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15963
16122
|
inputValue,
|
|
16123
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15964
16124
|
isPreAppStart: false
|
|
15965
16125
|
}, (spanInfo) => {
|
|
15966
16126
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "query", stackTrace);
|
|
@@ -15973,18 +16133,19 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
15973
16133
|
const spanName = `mysql2.${clientType}.query`;
|
|
15974
16134
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalQuery.apply(this, args), {
|
|
15975
16135
|
name: spanName,
|
|
15976
|
-
kind: import_src$
|
|
16136
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
15977
16137
|
submodule: "query",
|
|
15978
16138
|
packageType: PackageType.MYSQL,
|
|
15979
16139
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
15980
16140
|
packageName: "mysql2",
|
|
15981
16141
|
inputValue,
|
|
16142
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
15982
16143
|
isPreAppStart
|
|
15983
16144
|
}, (spanInfo) => {
|
|
15984
16145
|
return self._handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, this);
|
|
15985
16146
|
});
|
|
15986
16147
|
},
|
|
15987
|
-
spanKind: import_src$
|
|
16148
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
15988
16149
|
});
|
|
15989
16150
|
else return originalQuery.apply(this, args);
|
|
15990
16151
|
};
|
|
@@ -16020,12 +16181,13 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16020
16181
|
const spanName = `mysql2.${clientType}.execute`;
|
|
16021
16182
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute.apply(this, args), {
|
|
16022
16183
|
name: spanName,
|
|
16023
|
-
kind: import_src$
|
|
16184
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16024
16185
|
submodule: "execute",
|
|
16025
16186
|
packageType: PackageType.MYSQL,
|
|
16026
16187
|
packageName: "mysql2",
|
|
16027
16188
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16028
16189
|
inputValue,
|
|
16190
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16029
16191
|
isPreAppStart: false
|
|
16030
16192
|
}, (spanInfo) => {
|
|
16031
16193
|
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "execute", stackTrace);
|
|
@@ -16038,18 +16200,19 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16038
16200
|
const spanName = `mysql2.${clientType}.execute`;
|
|
16039
16201
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute.apply(this, args), {
|
|
16040
16202
|
name: spanName,
|
|
16041
|
-
kind: import_src$
|
|
16203
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16042
16204
|
submodule: "execute",
|
|
16043
16205
|
packageType: PackageType.MYSQL,
|
|
16044
16206
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16045
16207
|
packageName: "mysql2",
|
|
16046
16208
|
inputValue,
|
|
16209
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16047
16210
|
isPreAppStart
|
|
16048
16211
|
}, (spanInfo) => {
|
|
16049
16212
|
return self._handleRecordQueryInSpan(spanInfo, originalExecute, queryConfig, args, this);
|
|
16050
16213
|
});
|
|
16051
16214
|
},
|
|
16052
|
-
spanKind: import_src$
|
|
16215
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16053
16216
|
});
|
|
16054
16217
|
else return originalExecute.apply(this, args);
|
|
16055
16218
|
};
|
|
@@ -16068,7 +16231,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16068
16231
|
replayModeHandler: () => {
|
|
16069
16232
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
16070
16233
|
name: `mysql2.pool.getConnection`,
|
|
16071
|
-
kind: import_src$
|
|
16234
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16072
16235
|
submodule: "getConnection",
|
|
16073
16236
|
packageName: "mysql2",
|
|
16074
16237
|
packageType: PackageType.MYSQL,
|
|
@@ -16085,7 +16248,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16085
16248
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16086
16249
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGetConnection.apply(this, [callback]), {
|
|
16087
16250
|
name: `mysql2.pool.getConnection`,
|
|
16088
|
-
kind: import_src$
|
|
16251
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16089
16252
|
submodule: "getConnection",
|
|
16090
16253
|
packageName: "mysql2",
|
|
16091
16254
|
packageType: PackageType.MYSQL,
|
|
@@ -16096,7 +16259,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16096
16259
|
return self._handleRecordPoolGetConnectionInSpan(spanInfo, originalGetConnection, callback, this);
|
|
16097
16260
|
});
|
|
16098
16261
|
},
|
|
16099
|
-
spanKind: import_src$
|
|
16262
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16100
16263
|
});
|
|
16101
16264
|
else return originalGetConnection.apply(this, [callback]);
|
|
16102
16265
|
};
|
|
@@ -16119,7 +16282,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16119
16282
|
replayModeHandler: () => {
|
|
16120
16283
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
16121
16284
|
name: `mysql2.${clientType}.connect`,
|
|
16122
|
-
kind: import_src$
|
|
16285
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16123
16286
|
submodule: "connect",
|
|
16124
16287
|
packageName: "mysql2",
|
|
16125
16288
|
packageType: PackageType.MYSQL,
|
|
@@ -16140,7 +16303,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16140
16303
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16141
16304
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, [callback]), {
|
|
16142
16305
|
name: `mysql2.${clientType}.connect`,
|
|
16143
|
-
kind: import_src$
|
|
16306
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16144
16307
|
submodule: "connect",
|
|
16145
16308
|
packageName: "mysql2",
|
|
16146
16309
|
packageType: PackageType.MYSQL,
|
|
@@ -16151,7 +16314,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16151
16314
|
return self._handleSimpleCallbackMethod(spanInfo, originalConnect, callback, this);
|
|
16152
16315
|
});
|
|
16153
16316
|
},
|
|
16154
|
-
spanKind: import_src$
|
|
16317
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16155
16318
|
});
|
|
16156
16319
|
else return originalConnect.apply(this, [callback]);
|
|
16157
16320
|
};
|
|
@@ -16174,7 +16337,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16174
16337
|
replayModeHandler: () => {
|
|
16175
16338
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalPing.apply(this, [callback]), {
|
|
16176
16339
|
name: `mysql2.${clientType}.ping`,
|
|
16177
|
-
kind: import_src$
|
|
16340
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16178
16341
|
submodule: "ping",
|
|
16179
16342
|
packageName: "mysql2",
|
|
16180
16343
|
packageType: PackageType.MYSQL,
|
|
@@ -16195,7 +16358,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16195
16358
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16196
16359
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalPing.apply(this, [callback]), {
|
|
16197
16360
|
name: `mysql2.${clientType}.ping`,
|
|
16198
|
-
kind: import_src$
|
|
16361
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16199
16362
|
submodule: "ping",
|
|
16200
16363
|
packageName: "mysql2",
|
|
16201
16364
|
packageType: PackageType.MYSQL,
|
|
@@ -16206,7 +16369,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16206
16369
|
return self._handleSimpleCallbackMethod(spanInfo, originalPing, callback, this);
|
|
16207
16370
|
});
|
|
16208
16371
|
},
|
|
16209
|
-
spanKind: import_src$
|
|
16372
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16210
16373
|
});
|
|
16211
16374
|
else return originalPing.apply(this, [callback]);
|
|
16212
16375
|
};
|
|
@@ -16229,7 +16392,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16229
16392
|
replayModeHandler: () => {
|
|
16230
16393
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalEnd.apply(this, [callback]), {
|
|
16231
16394
|
name: `mysql2.${clientType}.end`,
|
|
16232
|
-
kind: import_src$
|
|
16395
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16233
16396
|
submodule: "end",
|
|
16234
16397
|
packageName: "mysql2",
|
|
16235
16398
|
packageType: PackageType.MYSQL,
|
|
@@ -16250,7 +16413,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16250
16413
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16251
16414
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalEnd.apply(this, [callback]), {
|
|
16252
16415
|
name: `mysql2.${clientType}.end`,
|
|
16253
|
-
kind: import_src$
|
|
16416
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16254
16417
|
submodule: "end",
|
|
16255
16418
|
packageName: "mysql2",
|
|
16256
16419
|
packageType: PackageType.MYSQL,
|
|
@@ -16261,12 +16424,257 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16261
16424
|
return self._handleSimpleCallbackMethod(spanInfo, originalEnd, callback, this);
|
|
16262
16425
|
});
|
|
16263
16426
|
},
|
|
16264
|
-
spanKind: import_src$
|
|
16427
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16265
16428
|
});
|
|
16266
16429
|
else return originalEnd.apply(this, [callback]);
|
|
16267
16430
|
};
|
|
16268
16431
|
};
|
|
16269
16432
|
}
|
|
16433
|
+
_getChangeUserPatchFn(clientType) {
|
|
16434
|
+
const self = this;
|
|
16435
|
+
return (originalChangeUser) => {
|
|
16436
|
+
return function changeUser(options, callback) {
|
|
16437
|
+
if (typeof options === "function") {
|
|
16438
|
+
callback = options;
|
|
16439
|
+
options = {};
|
|
16440
|
+
}
|
|
16441
|
+
const inputValue = { clientType };
|
|
16442
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16443
|
+
noOpRequestHandler: () => {
|
|
16444
|
+
if (callback) {
|
|
16445
|
+
process.nextTick(() => callback(null));
|
|
16446
|
+
return;
|
|
16447
|
+
}
|
|
16448
|
+
return Promise.resolve();
|
|
16449
|
+
},
|
|
16450
|
+
isServerRequest: false,
|
|
16451
|
+
replayModeHandler: () => {
|
|
16452
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalChangeUser.apply(this, [options, callback]), {
|
|
16453
|
+
name: `mysql2.${clientType}.changeUser`,
|
|
16454
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16455
|
+
submodule: "changeUser",
|
|
16456
|
+
packageName: "mysql2",
|
|
16457
|
+
packageType: PackageType.MYSQL,
|
|
16458
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16459
|
+
inputValue,
|
|
16460
|
+
isPreAppStart: false
|
|
16461
|
+
}, (spanInfo) => {
|
|
16462
|
+
if (callback) {
|
|
16463
|
+
process.nextTick(() => callback(null));
|
|
16464
|
+
return;
|
|
16465
|
+
}
|
|
16466
|
+
return Promise.resolve();
|
|
16467
|
+
});
|
|
16468
|
+
}
|
|
16469
|
+
});
|
|
16470
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16471
|
+
originalFunctionCall: () => originalChangeUser.apply(this, [options, callback]),
|
|
16472
|
+
recordModeHandler: ({ isPreAppStart }) => {
|
|
16473
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalChangeUser.apply(this, [options, callback]), {
|
|
16474
|
+
name: `mysql2.${clientType}.changeUser`,
|
|
16475
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16476
|
+
submodule: "changeUser",
|
|
16477
|
+
packageName: "mysql2",
|
|
16478
|
+
packageType: PackageType.MYSQL,
|
|
16479
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16480
|
+
inputValue,
|
|
16481
|
+
isPreAppStart
|
|
16482
|
+
}, (spanInfo) => {
|
|
16483
|
+
return self._handleSimpleCallbackMethod(spanInfo, originalChangeUser.bind(this, options), callback, this);
|
|
16484
|
+
});
|
|
16485
|
+
},
|
|
16486
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16487
|
+
});
|
|
16488
|
+
else return originalChangeUser.apply(this, [options, callback]);
|
|
16489
|
+
};
|
|
16490
|
+
};
|
|
16491
|
+
}
|
|
16492
|
+
_getPreparePatchFn(clientType) {
|
|
16493
|
+
const self = this;
|
|
16494
|
+
return (originalPrepare) => {
|
|
16495
|
+
return function prepare(...args) {
|
|
16496
|
+
const firstArg = args[0];
|
|
16497
|
+
const sql = typeof firstArg === "string" ? firstArg : firstArg?.sql;
|
|
16498
|
+
const originalCallback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
16499
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16500
|
+
noOpRequestHandler: () => self._handleNoOpReplayPrepare(sql, originalCallback),
|
|
16501
|
+
isServerRequest: false,
|
|
16502
|
+
replayModeHandler: () => self._handleReplayPrepare(sql, originalCallback, clientType)
|
|
16503
|
+
});
|
|
16504
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16505
|
+
originalFunctionCall: () => originalPrepare.apply(this, args),
|
|
16506
|
+
recordModeHandler: ({ isPreAppStart }) => self._handleRecordPrepare(originalPrepare, args, sql, originalCallback, this, clientType, isPreAppStart),
|
|
16507
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16508
|
+
});
|
|
16509
|
+
return originalPrepare.apply(this, args);
|
|
16510
|
+
};
|
|
16511
|
+
};
|
|
16512
|
+
}
|
|
16513
|
+
_handleRecordPrepare(originalPrepare, args, sql, originalCallback, context$6, clientType, isPreAppStart) {
|
|
16514
|
+
const self = this;
|
|
16515
|
+
return SpanUtils.createAndExecuteSpan(this.mode, () => originalPrepare.apply(context$6, args), {
|
|
16516
|
+
name: `mysql2.${clientType}.prepare`,
|
|
16517
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16518
|
+
submodule: "prepare",
|
|
16519
|
+
packageType: PackageType.MYSQL,
|
|
16520
|
+
packageName: "mysql2",
|
|
16521
|
+
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
16522
|
+
inputValue: {
|
|
16523
|
+
sql,
|
|
16524
|
+
clientType
|
|
16525
|
+
},
|
|
16526
|
+
isPreAppStart
|
|
16527
|
+
}, (spanInfo) => {
|
|
16528
|
+
const wrappedCallback = (err, statement) => {
|
|
16529
|
+
if (err) {
|
|
16530
|
+
logger.debug(`[Mysql2Instrumentation] MySQL2 prepare error: ${err.message} (${SpanUtils.getTraceInfo()})`);
|
|
16531
|
+
try {
|
|
16532
|
+
SpanUtils.endSpan(spanInfo.span, {
|
|
16533
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16534
|
+
message: err.message
|
|
16535
|
+
});
|
|
16536
|
+
} catch (error) {
|
|
16537
|
+
logger.error(`[Mysql2Instrumentation] error ending span:`, error);
|
|
16538
|
+
}
|
|
16539
|
+
} else {
|
|
16540
|
+
logger.debug(`[Mysql2Instrumentation] MySQL2 prepare completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16541
|
+
try {
|
|
16542
|
+
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: {
|
|
16543
|
+
prepared: true,
|
|
16544
|
+
statementId: statement?.id
|
|
16545
|
+
} });
|
|
16546
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16547
|
+
} catch (error) {
|
|
16548
|
+
logger.error(`[Mysql2Instrumentation] error processing prepare response:`, error);
|
|
16549
|
+
}
|
|
16550
|
+
if (statement && statement.execute) {
|
|
16551
|
+
const originalExecute = statement.execute.bind(statement);
|
|
16552
|
+
statement.execute = self._getPreparedStatementExecuteWrapper(originalExecute, sql, clientType);
|
|
16553
|
+
}
|
|
16554
|
+
}
|
|
16555
|
+
if (originalCallback) originalCallback(err, statement);
|
|
16556
|
+
};
|
|
16557
|
+
const newArgs = [...args];
|
|
16558
|
+
const callbackIndex = newArgs.findIndex((a) => typeof a === "function");
|
|
16559
|
+
if (callbackIndex >= 0) newArgs[callbackIndex] = wrappedCallback;
|
|
16560
|
+
else newArgs.push(wrappedCallback);
|
|
16561
|
+
return originalPrepare.apply(context$6, newArgs);
|
|
16562
|
+
});
|
|
16563
|
+
}
|
|
16564
|
+
_getPreparedStatementExecuteWrapper(originalExecute, sql, clientType) {
|
|
16565
|
+
const self = this;
|
|
16566
|
+
return function execute(...args) {
|
|
16567
|
+
let values = [];
|
|
16568
|
+
let callback;
|
|
16569
|
+
for (const arg of args) if (typeof arg === "function") callback = arg;
|
|
16570
|
+
else if (Array.isArray(arg)) values = arg;
|
|
16571
|
+
else if (arg !== void 0) values = [arg];
|
|
16572
|
+
const inputValue = {
|
|
16573
|
+
sql,
|
|
16574
|
+
values,
|
|
16575
|
+
clientType
|
|
16576
|
+
};
|
|
16577
|
+
const queryConfig = {
|
|
16578
|
+
sql,
|
|
16579
|
+
values,
|
|
16580
|
+
callback
|
|
16581
|
+
};
|
|
16582
|
+
const stackTrace = captureStackTrace(["Mysql2Instrumentation"]);
|
|
16583
|
+
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16584
|
+
noOpRequestHandler: () => self.queryMock.handleNoOpReplayQuery(queryConfig),
|
|
16585
|
+
isServerRequest: false,
|
|
16586
|
+
replayModeHandler: () => {
|
|
16587
|
+
const spanName = `mysql2.${clientType}.preparedExecute`;
|
|
16588
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute(...args), {
|
|
16589
|
+
name: spanName,
|
|
16590
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16591
|
+
submodule: "preparedExecute",
|
|
16592
|
+
packageType: PackageType.MYSQL,
|
|
16593
|
+
packageName: "mysql2",
|
|
16594
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16595
|
+
inputValue,
|
|
16596
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16597
|
+
isPreAppStart: false
|
|
16598
|
+
}, (spanInfo) => {
|
|
16599
|
+
return self.handleReplayQuery(queryConfig, inputValue, spanInfo, "preparedExecute", stackTrace);
|
|
16600
|
+
});
|
|
16601
|
+
}
|
|
16602
|
+
});
|
|
16603
|
+
else if (self.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
16604
|
+
originalFunctionCall: () => originalExecute(...args),
|
|
16605
|
+
recordModeHandler: ({ isPreAppStart }) => {
|
|
16606
|
+
const spanName = `mysql2.${clientType}.preparedExecute`;
|
|
16607
|
+
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExecute(...args), {
|
|
16608
|
+
name: spanName,
|
|
16609
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16610
|
+
submodule: "preparedExecute",
|
|
16611
|
+
packageType: PackageType.MYSQL,
|
|
16612
|
+
packageName: "mysql2",
|
|
16613
|
+
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
16614
|
+
inputValue,
|
|
16615
|
+
inputSchemaMerges: { values: { matchImportance: 0 } },
|
|
16616
|
+
isPreAppStart
|
|
16617
|
+
}, (spanInfo) => {
|
|
16618
|
+
return self._handleRecordQueryInSpan(spanInfo, originalExecute, queryConfig, args, void 0);
|
|
16619
|
+
});
|
|
16620
|
+
},
|
|
16621
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16622
|
+
});
|
|
16623
|
+
return originalExecute(...args);
|
|
16624
|
+
};
|
|
16625
|
+
}
|
|
16626
|
+
_handleReplayPrepare(sql, originalCallback, clientType) {
|
|
16627
|
+
const self = this;
|
|
16628
|
+
return SpanUtils.createAndExecuteSpan(this.mode, () => {}, {
|
|
16629
|
+
name: `mysql2.${clientType}.prepare`,
|
|
16630
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16631
|
+
submodule: "prepare",
|
|
16632
|
+
packageType: PackageType.MYSQL,
|
|
16633
|
+
packageName: "mysql2",
|
|
16634
|
+
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
16635
|
+
inputValue: {
|
|
16636
|
+
sql,
|
|
16637
|
+
clientType
|
|
16638
|
+
},
|
|
16639
|
+
isPreAppStart: false
|
|
16640
|
+
}, (spanInfo) => {
|
|
16641
|
+
const mockStatement = {
|
|
16642
|
+
query: sql,
|
|
16643
|
+
id: 1,
|
|
16644
|
+
columns: [],
|
|
16645
|
+
parameters: [],
|
|
16646
|
+
execute: self._getPreparedStatementExecuteWrapper(() => {}, sql, clientType),
|
|
16647
|
+
close: () => {}
|
|
16648
|
+
};
|
|
16649
|
+
try {
|
|
16650
|
+
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { prepared: true } });
|
|
16651
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16652
|
+
} catch (error) {
|
|
16653
|
+
logger.error(`[Mysql2Instrumentation] error ending prepare span:`, error);
|
|
16654
|
+
}
|
|
16655
|
+
if (originalCallback) process.nextTick(() => originalCallback(null, mockStatement));
|
|
16656
|
+
});
|
|
16657
|
+
}
|
|
16658
|
+
_handleNoOpReplayPrepare(sql, originalCallback) {
|
|
16659
|
+
const self = this;
|
|
16660
|
+
const mockStatement = {
|
|
16661
|
+
query: sql,
|
|
16662
|
+
id: 1,
|
|
16663
|
+
columns: [],
|
|
16664
|
+
parameters: [],
|
|
16665
|
+
execute: (...args) => {
|
|
16666
|
+
const values = Array.isArray(args[0]) ? args[0] : [];
|
|
16667
|
+
const callback = typeof args[args.length - 1] === "function" ? args[args.length - 1] : void 0;
|
|
16668
|
+
return self.queryMock.handleNoOpReplayQuery({
|
|
16669
|
+
sql,
|
|
16670
|
+
values,
|
|
16671
|
+
callback
|
|
16672
|
+
});
|
|
16673
|
+
},
|
|
16674
|
+
close: () => {}
|
|
16675
|
+
};
|
|
16676
|
+
if (originalCallback) process.nextTick(() => originalCallback(null, mockStatement));
|
|
16677
|
+
}
|
|
16270
16678
|
_handleSimpleCallbackMethod(spanInfo, originalMethod, callback, context$6) {
|
|
16271
16679
|
if (callback) {
|
|
16272
16680
|
const wrappedCallback = (error) => {
|
|
@@ -16274,7 +16682,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16274
16682
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16275
16683
|
try {
|
|
16276
16684
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16277
|
-
code: import_src$
|
|
16685
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16278
16686
|
message: error.message
|
|
16279
16687
|
});
|
|
16280
16688
|
} catch (error$1) {
|
|
@@ -16284,7 +16692,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16284
16692
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16285
16693
|
try {
|
|
16286
16694
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { success: true } });
|
|
16287
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16695
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16288
16696
|
} catch (error$1) {
|
|
16289
16697
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error$1);
|
|
16290
16698
|
}
|
|
@@ -16298,7 +16706,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16298
16706
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16299
16707
|
try {
|
|
16300
16708
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { success: true } });
|
|
16301
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16709
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16302
16710
|
} catch (error) {
|
|
16303
16711
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error);
|
|
16304
16712
|
}
|
|
@@ -16306,7 +16714,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16306
16714
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16307
16715
|
try {
|
|
16308
16716
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16309
|
-
code: import_src$
|
|
16717
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16310
16718
|
message: error.message
|
|
16311
16719
|
});
|
|
16312
16720
|
} catch (error$1) {
|
|
@@ -16318,7 +16726,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16318
16726
|
logger.debug(`[Mysql2Instrumentation] MySQL2 method completed (non-promise) (${SpanUtils.getTraceInfo()})`);
|
|
16319
16727
|
try {
|
|
16320
16728
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { success: true } });
|
|
16321
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16729
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16322
16730
|
} catch (error) {
|
|
16323
16731
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error);
|
|
16324
16732
|
}
|
|
@@ -16338,22 +16746,36 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16338
16746
|
else if (args.length > 1 && typeof args[1] !== "function") config.values = [args[1]];
|
|
16339
16747
|
return config;
|
|
16340
16748
|
}
|
|
16341
|
-
if (typeof firstArg === "object" && firstArg.sql)
|
|
16342
|
-
|
|
16343
|
-
|
|
16344
|
-
|
|
16345
|
-
|
|
16749
|
+
if (typeof firstArg === "object" && firstArg.sql) {
|
|
16750
|
+
let values = firstArg.values;
|
|
16751
|
+
let callback = firstArg.callback;
|
|
16752
|
+
if (typeof args[1] === "function") callback = args[1];
|
|
16753
|
+
else {
|
|
16754
|
+
if (args[1] !== void 0) values = Array.isArray(args[1]) ? args[1] : [args[1]];
|
|
16755
|
+
if (typeof args[2] === "function") callback = args[2];
|
|
16756
|
+
}
|
|
16757
|
+
return {
|
|
16758
|
+
sql: firstArg.sql,
|
|
16759
|
+
values,
|
|
16760
|
+
callback
|
|
16761
|
+
};
|
|
16762
|
+
}
|
|
16346
16763
|
return null;
|
|
16347
16764
|
}
|
|
16348
16765
|
_handleRecordQueryInSpan(spanInfo, originalQuery, queryConfig, args, context$6) {
|
|
16349
|
-
|
|
16766
|
+
const hasCallback = !!queryConfig.callback;
|
|
16767
|
+
const invokeOriginal = (invokeArgs) => {
|
|
16768
|
+
return context$6 ? originalQuery.apply(context$6, invokeArgs) : originalQuery(...invokeArgs);
|
|
16769
|
+
};
|
|
16770
|
+
if (hasCallback) {
|
|
16771
|
+
const parentContext = import_src$22.context.active();
|
|
16350
16772
|
const originalCallback = queryConfig.callback;
|
|
16351
16773
|
const wrappedCallback = (error, results, fields) => {
|
|
16352
16774
|
if (error) {
|
|
16353
16775
|
logger.debug(`[Mysql2Instrumentation] MySQL2 query error (hasCallback): ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16354
16776
|
try {
|
|
16355
16777
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16356
|
-
code: import_src$
|
|
16778
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16357
16779
|
message: error.message
|
|
16358
16780
|
});
|
|
16359
16781
|
} catch (error$1) {
|
|
@@ -16363,12 +16785,12 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16363
16785
|
logger.debug(`[Mysql2Instrumentation] MySQL2 query completed successfully (hasCallback) (${SpanUtils.getTraceInfo()})`);
|
|
16364
16786
|
try {
|
|
16365
16787
|
this._addOutputAttributesToSpan(spanInfo, results, fields);
|
|
16366
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16788
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16367
16789
|
} catch (error$1) {
|
|
16368
16790
|
logger.error(`[Mysql2Instrumentation] error processing response:`, error$1);
|
|
16369
16791
|
}
|
|
16370
16792
|
}
|
|
16371
|
-
return originalCallback(error, results, fields);
|
|
16793
|
+
return import_src$22.context.with(parentContext, () => originalCallback(error, results, fields));
|
|
16372
16794
|
};
|
|
16373
16795
|
try {
|
|
16374
16796
|
const firstArg = args[0];
|
|
@@ -16383,9 +16805,9 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16383
16805
|
} catch (error) {
|
|
16384
16806
|
logger.error(`[Mysql2Instrumentation] error replacing callback:`, error, args);
|
|
16385
16807
|
}
|
|
16386
|
-
return
|
|
16808
|
+
return invokeOriginal(args);
|
|
16387
16809
|
} else {
|
|
16388
|
-
const result =
|
|
16810
|
+
const result = invokeOriginal(args);
|
|
16389
16811
|
if (result && typeof result.on === "function") {
|
|
16390
16812
|
const streamResults = [];
|
|
16391
16813
|
let streamFields = null;
|
|
@@ -16393,7 +16815,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16393
16815
|
logger.debug(`[Mysql2Instrumentation] MySQL2 stream query error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16394
16816
|
try {
|
|
16395
16817
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16396
|
-
code: import_src$
|
|
16818
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16397
16819
|
message: error.message
|
|
16398
16820
|
});
|
|
16399
16821
|
} catch (error$1) {
|
|
@@ -16407,7 +16829,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16407
16829
|
logger.debug(`[Mysql2Instrumentation] MySQL2 stream query completed (${SpanUtils.getTraceInfo()})`);
|
|
16408
16830
|
try {
|
|
16409
16831
|
this._addOutputAttributesToSpan(spanInfo, streamResults, streamFields);
|
|
16410
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16832
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16411
16833
|
} catch (error) {
|
|
16412
16834
|
logger.error(`[Mysql2Instrumentation] error ending span:`, error);
|
|
16413
16835
|
}
|
|
@@ -16429,7 +16851,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16429
16851
|
logger.debug(`[Mysql2Instrumentation] MySQL2 Pool getConnection error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16430
16852
|
try {
|
|
16431
16853
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16432
|
-
code: import_src$
|
|
16854
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16433
16855
|
message: error.message
|
|
16434
16856
|
});
|
|
16435
16857
|
} catch (error$1) {
|
|
@@ -16442,7 +16864,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16442
16864
|
connected: true,
|
|
16443
16865
|
hasConnection: !!connection
|
|
16444
16866
|
} });
|
|
16445
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16867
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16446
16868
|
} catch (error$1) {
|
|
16447
16869
|
logger.error(`[Mysql2Instrumentation] error processing getConnection response:`, error$1);
|
|
16448
16870
|
}
|
|
@@ -16457,7 +16879,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16457
16879
|
connected: true,
|
|
16458
16880
|
hasConnection: !!connection
|
|
16459
16881
|
} });
|
|
16460
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16882
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16461
16883
|
} catch (error) {
|
|
16462
16884
|
logger.error(`[Mysql2Instrumentation] error processing getConnection response:`, error);
|
|
16463
16885
|
}
|
|
@@ -16466,7 +16888,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16466
16888
|
logger.debug(`[Mysql2Instrumentation] MySQL2 Pool getConnection error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16467
16889
|
try {
|
|
16468
16890
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16469
|
-
code: import_src$
|
|
16891
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16470
16892
|
message: error.message
|
|
16471
16893
|
});
|
|
16472
16894
|
} catch (error$1) {
|
|
@@ -16509,7 +16931,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16509
16931
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16510
16932
|
return SpanUtils.createAndExecuteSpan(self.mode, () => new OriginalConnection(...args), {
|
|
16511
16933
|
name: `mysql2.connection.create`,
|
|
16512
|
-
kind: import_src$
|
|
16934
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16513
16935
|
submodule: "connectEvent",
|
|
16514
16936
|
packageType: PackageType.MYSQL,
|
|
16515
16937
|
packageName: "mysql2",
|
|
@@ -16524,7 +16946,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16524
16946
|
connected: true,
|
|
16525
16947
|
connectionObj
|
|
16526
16948
|
} });
|
|
16527
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
16949
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$22.SpanStatusCode.OK });
|
|
16528
16950
|
} catch {
|
|
16529
16951
|
logger.error(`[Mysql2Instrumentation] error adding span attributes:`);
|
|
16530
16952
|
}
|
|
@@ -16533,7 +16955,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16533
16955
|
try {
|
|
16534
16956
|
logger.debug(`[Mysql2Instrumentation] Connection error, recording: ${err.message}`);
|
|
16535
16957
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16536
|
-
code: import_src$
|
|
16958
|
+
code: import_src$22.SpanStatusCode.ERROR,
|
|
16537
16959
|
message: err.message
|
|
16538
16960
|
});
|
|
16539
16961
|
} catch {
|
|
@@ -16543,7 +16965,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16543
16965
|
return connection;
|
|
16544
16966
|
});
|
|
16545
16967
|
},
|
|
16546
|
-
spanKind: import_src$
|
|
16968
|
+
spanKind: import_src$22.SpanKind.CLIENT
|
|
16547
16969
|
});
|
|
16548
16970
|
if (self.mode === TuskDriftMode.REPLAY) return handleReplayMode({
|
|
16549
16971
|
noOpRequestHandler: () => {
|
|
@@ -16553,7 +16975,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16553
16975
|
replayModeHandler: () => {
|
|
16554
16976
|
return SpanUtils.createAndExecuteSpan(self.mode, () => new OriginalConnection(...args), {
|
|
16555
16977
|
name: `mysql2.connection.create`,
|
|
16556
|
-
kind: import_src$
|
|
16978
|
+
kind: import_src$22.SpanKind.CLIENT,
|
|
16557
16979
|
submodule: "connectEvent",
|
|
16558
16980
|
packageType: PackageType.MYSQL,
|
|
16559
16981
|
packageName: "mysql2",
|
|
@@ -16591,6 +17013,34 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16591
17013
|
if (event === "error" && !this._isConnectOrErrorEmitted) return this;
|
|
16592
17014
|
return super.on(event, listener);
|
|
16593
17015
|
}
|
|
17016
|
+
once(event, listener) {
|
|
17017
|
+
if (!this._connectEventMock) return super.once(event, listener);
|
|
17018
|
+
if (event === "connect" && !this._isConnectOrErrorEmitted) {
|
|
17019
|
+
this._connectEventMock.getReplayedConnectionEvent(inputValue).then(({ output }) => {
|
|
17020
|
+
if (output !== void 0) process.nextTick(() => {
|
|
17021
|
+
listener.call(this, output);
|
|
17022
|
+
this._isConnectOrErrorEmitted = true;
|
|
17023
|
+
});
|
|
17024
|
+
}).catch((err) => {
|
|
17025
|
+
logger.error(`[Mysql2Instrumentation] Error replaying connection event:`, err);
|
|
17026
|
+
});
|
|
17027
|
+
return this;
|
|
17028
|
+
}
|
|
17029
|
+
if (event === "error" && !this._isConnectOrErrorEmitted) return this;
|
|
17030
|
+
return super.once(event, listener);
|
|
17031
|
+
}
|
|
17032
|
+
connect(callback) {
|
|
17033
|
+
if (!callback) return;
|
|
17034
|
+
this._connectEventMock.getReplayedConnectionEvent(inputValue).then(({ output }) => {
|
|
17035
|
+
if (output !== void 0) process.nextTick(() => {
|
|
17036
|
+
this._isConnectOrErrorEmitted = true;
|
|
17037
|
+
callback(null);
|
|
17038
|
+
});
|
|
17039
|
+
}).catch((err) => {
|
|
17040
|
+
logger.error(`[Mysql2Instrumentation] Error replaying connection event in connect():`, err);
|
|
17041
|
+
process.nextTick(() => callback(err));
|
|
17042
|
+
});
|
|
17043
|
+
}
|
|
16594
17044
|
}
|
|
16595
17045
|
const mockConnection = new MockConnection(...args);
|
|
16596
17046
|
mockConnection.addListener("error", (_err) => {});
|
|
@@ -16618,9 +17068,13 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16618
17068
|
fields: fields || []
|
|
16619
17069
|
};
|
|
16620
17070
|
else if (result.affectedRows !== void 0) outputValue = {
|
|
17071
|
+
fieldCount: result.fieldCount,
|
|
16621
17072
|
affectedRows: result.affectedRows,
|
|
16622
17073
|
insertId: result.insertId,
|
|
16623
|
-
|
|
17074
|
+
info: result.info ?? "",
|
|
17075
|
+
serverStatus: result.serverStatus ?? 0,
|
|
17076
|
+
warningStatus: result.warningStatus ?? 0,
|
|
17077
|
+
changedRows: result.changedRows ?? 0
|
|
16624
17078
|
};
|
|
16625
17079
|
else outputValue = result;
|
|
16626
17080
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
@@ -16632,7 +17086,7 @@ var Mysql2Instrumentation = class extends TdInstrumentationBase {
|
|
|
16632
17086
|
|
|
16633
17087
|
//#endregion
|
|
16634
17088
|
//#region src/instrumentation/libraries/tcp/Instrumentation.ts
|
|
16635
|
-
var import_src$
|
|
17089
|
+
var import_src$21 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
16636
17090
|
/**
|
|
16637
17091
|
* TCP Instrumentation for Tusk Drift
|
|
16638
17092
|
*
|
|
@@ -16719,7 +17173,7 @@ var TcpInstrumentation = class extends TdInstrumentationBase {
|
|
|
16719
17173
|
const currentSpanInfo = SpanUtils.getCurrentSpanInfo();
|
|
16720
17174
|
if (!currentSpanInfo) return originalMethod.apply(socketContext, args);
|
|
16721
17175
|
const callingLibrary = currentSpanInfo.context.getValue(CALLING_LIBRARY_CONTEXT_KEY);
|
|
16722
|
-
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) === import_src$
|
|
17176
|
+
if (currentSpanInfo.context.getValue(SPAN_KIND_CONTEXT_KEY) === import_src$21.SpanKind.SERVER && callingLibrary !== "ProtobufCommunicator") this._logUnpatchedDependency(methodName, currentSpanInfo, socketContext);
|
|
16723
17177
|
return originalMethod.apply(socketContext, args);
|
|
16724
17178
|
}
|
|
16725
17179
|
_isHttpResponseSocket(socketContext) {
|
|
@@ -16729,7 +17183,7 @@ var TcpInstrumentation = class extends TdInstrumentationBase {
|
|
|
16729
17183
|
|
|
16730
17184
|
//#endregion
|
|
16731
17185
|
//#region src/instrumentation/libraries/jsonwebtoken/Instrumentation.ts
|
|
16732
|
-
var import_src$
|
|
17186
|
+
var import_src$20 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
16733
17187
|
var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
16734
17188
|
constructor(config = {}) {
|
|
16735
17189
|
super("jsonwebtoken", config);
|
|
@@ -16809,7 +17263,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16809
17263
|
replayModeHandler: () => {
|
|
16810
17264
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalVerify.apply(this, args), {
|
|
16811
17265
|
name: "jsonwebtoken.verify",
|
|
16812
|
-
kind: import_src$
|
|
17266
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16813
17267
|
submodule: "verify",
|
|
16814
17268
|
packageName: "jsonwebtoken",
|
|
16815
17269
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16825,7 +17279,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16825
17279
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16826
17280
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalVerify.apply(this, args), {
|
|
16827
17281
|
name: "jsonwebtoken.verify",
|
|
16828
|
-
kind: import_src$
|
|
17282
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16829
17283
|
submodule: "verify",
|
|
16830
17284
|
packageName: "jsonwebtoken",
|
|
16831
17285
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16835,7 +17289,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16835
17289
|
return self._handleRecordVerifyInSpan(spanInfo, originalVerify, verifyConfig, args, this);
|
|
16836
17290
|
});
|
|
16837
17291
|
},
|
|
16838
|
-
spanKind: import_src$
|
|
17292
|
+
spanKind: import_src$20.SpanKind.CLIENT
|
|
16839
17293
|
});
|
|
16840
17294
|
else return originalVerify.apply(this, args);
|
|
16841
17295
|
};
|
|
@@ -16873,7 +17327,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16873
17327
|
replayModeHandler: () => {
|
|
16874
17328
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSign.apply(this, args), {
|
|
16875
17329
|
name: "jsonwebtoken.sign",
|
|
16876
|
-
kind: import_src$
|
|
17330
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16877
17331
|
submodule: "sign",
|
|
16878
17332
|
packageName: "jsonwebtoken",
|
|
16879
17333
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16889,7 +17343,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16889
17343
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
16890
17344
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSign.apply(this, args), {
|
|
16891
17345
|
name: "jsonwebtoken.sign",
|
|
16892
|
-
kind: import_src$
|
|
17346
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
16893
17347
|
submodule: "sign",
|
|
16894
17348
|
packageName: "jsonwebtoken",
|
|
16895
17349
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
@@ -16899,7 +17353,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16899
17353
|
return self._handleRecordSignInSpan(spanInfo, originalSign, signConfig, args, this);
|
|
16900
17354
|
});
|
|
16901
17355
|
},
|
|
16902
|
-
spanKind: import_src$
|
|
17356
|
+
spanKind: import_src$20.SpanKind.CLIENT
|
|
16903
17357
|
});
|
|
16904
17358
|
else return originalSign.apply(this, args);
|
|
16905
17359
|
};
|
|
@@ -16938,7 +17392,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16938
17392
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16939
17393
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
16940
17394
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16941
|
-
code: import_src$
|
|
17395
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
16942
17396
|
message: error.message
|
|
16943
17397
|
});
|
|
16944
17398
|
} catch (error$1) {
|
|
@@ -16947,7 +17401,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16947
17401
|
else try {
|
|
16948
17402
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16949
17403
|
this._addOutputAttributesToSpan(spanInfo, decoded);
|
|
16950
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17404
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
16951
17405
|
} catch (error$1) {
|
|
16952
17406
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error$1);
|
|
16953
17407
|
}
|
|
@@ -16965,7 +17419,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16965
17419
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify sync error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16966
17420
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
16967
17421
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16968
|
-
code: import_src$
|
|
17422
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
16969
17423
|
message: error.message
|
|
16970
17424
|
});
|
|
16971
17425
|
} catch (error$1) {
|
|
@@ -16978,7 +17432,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16978
17432
|
try {
|
|
16979
17433
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
16980
17434
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
16981
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17435
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
16982
17436
|
} catch (error) {
|
|
16983
17437
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error);
|
|
16984
17438
|
}
|
|
@@ -16988,7 +17442,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
16988
17442
|
logger.debug(`[JsonwebtokenInstrumentation] JWT verify error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
16989
17443
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
16990
17444
|
SpanUtils.endSpan(spanInfo.span, {
|
|
16991
|
-
code: import_src$
|
|
17445
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
16992
17446
|
message: error.message
|
|
16993
17447
|
});
|
|
16994
17448
|
} catch (error$1) {
|
|
@@ -17005,7 +17459,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17005
17459
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
17006
17460
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
17007
17461
|
SpanUtils.endSpan(spanInfo.span, {
|
|
17008
|
-
code: import_src$
|
|
17462
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
17009
17463
|
message: error.message
|
|
17010
17464
|
});
|
|
17011
17465
|
} catch (error$1) {
|
|
@@ -17014,7 +17468,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17014
17468
|
else try {
|
|
17015
17469
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
17016
17470
|
this._addOutputAttributesToSpan(spanInfo, token);
|
|
17017
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17471
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
17018
17472
|
} catch (error$1) {
|
|
17019
17473
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error$1);
|
|
17020
17474
|
}
|
|
@@ -17031,7 +17485,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17031
17485
|
try {
|
|
17032
17486
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
17033
17487
|
this._addOutputAttributesToSpan(spanInfo, result);
|
|
17034
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
17488
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$20.SpanStatusCode.OK });
|
|
17035
17489
|
} catch (error) {
|
|
17036
17490
|
logger.error(`[JsonwebtokenInstrumentation] error ending span:`, error);
|
|
17037
17491
|
}
|
|
@@ -17041,7 +17495,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17041
17495
|
logger.debug(`[JsonwebtokenInstrumentation] JWT sign error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
17042
17496
|
this._addErrorOutputAttributesToSpan(spanInfo, error);
|
|
17043
17497
|
SpanUtils.endSpan(spanInfo.span, {
|
|
17044
|
-
code: import_src$
|
|
17498
|
+
code: import_src$20.SpanStatusCode.ERROR,
|
|
17045
17499
|
message: error.message
|
|
17046
17500
|
});
|
|
17047
17501
|
} catch (error$1) {
|
|
@@ -17050,9 +17504,9 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17050
17504
|
throw error;
|
|
17051
17505
|
}
|
|
17052
17506
|
}
|
|
17053
|
-
|
|
17507
|
+
handleReplayVerify(verifyConfig, inputValue, spanInfo, stackTrace) {
|
|
17054
17508
|
logger.debug(`[JsonwebtokenInstrumentation] Replaying JWT verify`);
|
|
17055
|
-
const mockData =
|
|
17509
|
+
const mockData = findMockResponseSync({
|
|
17056
17510
|
mockRequestData: {
|
|
17057
17511
|
traceId: spanInfo.traceId,
|
|
17058
17512
|
spanId: spanInfo.spanId,
|
|
@@ -17061,7 +17515,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17061
17515
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
17062
17516
|
submoduleName: "verify",
|
|
17063
17517
|
inputValue,
|
|
17064
|
-
kind: import_src$
|
|
17518
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
17065
17519
|
stackTrace
|
|
17066
17520
|
},
|
|
17067
17521
|
tuskDrift: this.tuskDrift
|
|
@@ -17093,9 +17547,9 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17093
17547
|
return;
|
|
17094
17548
|
} else return result;
|
|
17095
17549
|
}
|
|
17096
|
-
|
|
17550
|
+
handleReplaySign(signConfig, inputValue, spanInfo, stackTrace) {
|
|
17097
17551
|
logger.debug(`[JsonwebtokenInstrumentation] Replaying JWT sign`);
|
|
17098
|
-
const mockData =
|
|
17552
|
+
const mockData = findMockResponseSync({
|
|
17099
17553
|
mockRequestData: {
|
|
17100
17554
|
traceId: spanInfo?.traceId,
|
|
17101
17555
|
spanId: spanInfo?.spanId,
|
|
@@ -17104,7 +17558,7 @@ var JsonwebtokenInstrumentation = class extends TdInstrumentationBase {
|
|
|
17104
17558
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
17105
17559
|
submoduleName: "sign",
|
|
17106
17560
|
inputValue,
|
|
17107
|
-
kind: import_src$
|
|
17561
|
+
kind: import_src$20.SpanKind.CLIENT,
|
|
17108
17562
|
stackTrace
|
|
17109
17563
|
},
|
|
17110
17564
|
tuskDrift: this.tuskDrift
|
|
@@ -17206,7 +17660,7 @@ var JwksRsaInstrumentation = class extends TdInstrumentationBase {
|
|
|
17206
17660
|
|
|
17207
17661
|
//#endregion
|
|
17208
17662
|
//#region src/instrumentation/libraries/fetch/FetchTransformEngine.ts
|
|
17209
|
-
var import_src$
|
|
17663
|
+
var import_src$19 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
17210
17664
|
/**
|
|
17211
17665
|
* Creates an empty FetchInputValue object for dropped spans
|
|
17212
17666
|
*/
|
|
@@ -17281,7 +17735,7 @@ var FetchTransformEngine = class {
|
|
|
17281
17735
|
}
|
|
17282
17736
|
compileMatcher(matcher) {
|
|
17283
17737
|
const checks = [];
|
|
17284
|
-
checks.push((span) => span.kind === import_src$
|
|
17738
|
+
checks.push((span) => span.kind === import_src$19.SpanKind.CLIENT);
|
|
17285
17739
|
if (matcher.method) if (matcher.method.length === 0) {} else {
|
|
17286
17740
|
const methods = matcher.method.map((method) => method.toUpperCase());
|
|
17287
17741
|
checks.push((span) => {
|
|
@@ -17477,7 +17931,7 @@ var FetchTransformEngine = class {
|
|
|
17477
17931
|
|
|
17478
17932
|
//#endregion
|
|
17479
17933
|
//#region src/instrumentation/libraries/fetch/Instrumentation.ts
|
|
17480
|
-
var import_src$
|
|
17934
|
+
var import_src$18 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
17481
17935
|
/**
|
|
17482
17936
|
* Fetch API instrumentation for capturing requests made via fetch()
|
|
17483
17937
|
* This covers libraries like @octokit/rest, axios (when using fetch adapter), etc.
|
|
@@ -17539,7 +17993,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17539
17993
|
replayModeHandler: () => {
|
|
17540
17994
|
return SpanUtils.createAndExecuteSpan(this.mode, () => this.originalFetch(input, init), {
|
|
17541
17995
|
name: url,
|
|
17542
|
-
kind: import_src$
|
|
17996
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17543
17997
|
packageName: "fetch",
|
|
17544
17998
|
packageType: PackageType.HTTP,
|
|
17545
17999
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
@@ -17554,14 +18008,14 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17554
18008
|
else if (this.mode === TuskDriftMode.RECORD) return handleRecordMode({
|
|
17555
18009
|
originalFunctionCall: () => this.originalFetch(input, init),
|
|
17556
18010
|
recordModeHandler: ({ isPreAppStart }) => this._handleRecordFetch(input, inputValue, isPreAppStart, init),
|
|
17557
|
-
spanKind: import_src$
|
|
18011
|
+
spanKind: import_src$18.SpanKind.CLIENT
|
|
17558
18012
|
});
|
|
17559
18013
|
else return this.originalFetch(input, init);
|
|
17560
18014
|
}
|
|
17561
18015
|
_handleRecordFetch(input, inputValue, isPreAppStart, init) {
|
|
17562
18016
|
return SpanUtils.createAndExecuteSpan(this.mode, () => this.originalFetch(input, init), {
|
|
17563
18017
|
name: inputValue.url,
|
|
17564
|
-
kind: import_src$
|
|
18018
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17565
18019
|
packageName: "fetch",
|
|
17566
18020
|
packageType: PackageType.HTTP,
|
|
17567
18021
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
@@ -17590,7 +18044,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17590
18044
|
const spanData = {
|
|
17591
18045
|
traceId: spanInfo.traceId,
|
|
17592
18046
|
spanId: spanInfo.spanId,
|
|
17593
|
-
kind: import_src$
|
|
18047
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17594
18048
|
inputValue,
|
|
17595
18049
|
outputValue
|
|
17596
18050
|
};
|
|
@@ -17608,9 +18062,9 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17608
18062
|
...spanData.transformMetadata && { transformMetadata: spanData.transformMetadata }
|
|
17609
18063
|
});
|
|
17610
18064
|
const status = response.status >= 300 ? {
|
|
17611
|
-
code: import_src$
|
|
18065
|
+
code: import_src$18.SpanStatusCode.ERROR,
|
|
17612
18066
|
message: `HTTP ${response.status}`
|
|
17613
|
-
} : { code: import_src$
|
|
18067
|
+
} : { code: import_src$18.SpanStatusCode.OK };
|
|
17614
18068
|
SpanUtils.endSpan(spanInfo.span, status);
|
|
17615
18069
|
} catch (error) {
|
|
17616
18070
|
logger.error(`[FetchInstrumentation] error processing response body:`, error);
|
|
@@ -17619,7 +18073,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17619
18073
|
}).catch((error) => {
|
|
17620
18074
|
try {
|
|
17621
18075
|
SpanUtils.endSpan(spanInfo.span, {
|
|
17622
|
-
code: import_src$
|
|
18076
|
+
code: import_src$18.SpanStatusCode.ERROR,
|
|
17623
18077
|
message: error.message
|
|
17624
18078
|
});
|
|
17625
18079
|
} catch (error$1) {
|
|
@@ -17640,7 +18094,7 @@ var FetchInstrumentation = class extends TdInstrumentationBase {
|
|
|
17640
18094
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
17641
18095
|
submoduleName: inputValue.method,
|
|
17642
18096
|
inputValue,
|
|
17643
|
-
kind: import_src$
|
|
18097
|
+
kind: import_src$18.SpanKind.CLIENT,
|
|
17644
18098
|
stackTrace
|
|
17645
18099
|
},
|
|
17646
18100
|
tuskDrift: this.tuskDrift,
|
|
@@ -17806,10 +18260,23 @@ function convertValueToJsonable(value) {
|
|
|
17806
18260
|
encoding: BufferEncoding.NONE
|
|
17807
18261
|
};
|
|
17808
18262
|
}
|
|
18263
|
+
/**
|
|
18264
|
+
* Recursively deserialize Buffer objects from JSON representation.
|
|
18265
|
+
* Converts {"type":"Buffer","data":[...]} back to actual Buffer instances.
|
|
18266
|
+
* This handles the format produced by JSON.stringify(Buffer).
|
|
18267
|
+
*/
|
|
18268
|
+
function deserializeBufferValue(value) {
|
|
18269
|
+
if (!value || typeof value !== "object") return value;
|
|
18270
|
+
if (value.type === "Buffer" && Array.isArray(value.data)) return Buffer.from(value.data);
|
|
18271
|
+
if (Array.isArray(value)) return value.map((item) => deserializeBufferValue(item));
|
|
18272
|
+
const result = {};
|
|
18273
|
+
for (const key of Object.keys(value)) result[key] = deserializeBufferValue(value[key]);
|
|
18274
|
+
return result;
|
|
18275
|
+
}
|
|
17809
18276
|
|
|
17810
18277
|
//#endregion
|
|
17811
18278
|
//#region src/instrumentation/libraries/ioredis/Instrumentation.ts
|
|
17812
|
-
var import_src$
|
|
18279
|
+
var import_src$17 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
17813
18280
|
const SUPPORTED_VERSIONS$1 = [">=4.11.0 <5", "5.*"];
|
|
17814
18281
|
var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
17815
18282
|
constructor(config = {}) {
|
|
@@ -17927,7 +18394,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17927
18394
|
replayModeHandler: () => {
|
|
17928
18395
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSendCommand.apply(this, arguments), {
|
|
17929
18396
|
name: `ioredis.${commandName}`,
|
|
17930
|
-
kind: import_src$
|
|
18397
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
17931
18398
|
submodule: commandName,
|
|
17932
18399
|
packageType: PackageType.REDIS,
|
|
17933
18400
|
packageName: "ioredis",
|
|
@@ -17944,7 +18411,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17944
18411
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
17945
18412
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSendCommand.apply(this, arguments), {
|
|
17946
18413
|
name: `ioredis.${commandName}`,
|
|
17947
|
-
kind: import_src$
|
|
18414
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
17948
18415
|
submodule: commandName,
|
|
17949
18416
|
packageType: PackageType.REDIS,
|
|
17950
18417
|
packageName: "ioredis",
|
|
@@ -17955,7 +18422,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17955
18422
|
return self._handleRecordSendCommand(spanInfo, originalSendCommand, cmd, this);
|
|
17956
18423
|
});
|
|
17957
18424
|
},
|
|
17958
|
-
spanKind: import_src$
|
|
18425
|
+
spanKind: import_src$17.SpanKind.CLIENT
|
|
17959
18426
|
});
|
|
17960
18427
|
else return originalSendCommand.apply(this, arguments);
|
|
17961
18428
|
};
|
|
@@ -17980,7 +18447,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17980
18447
|
replayModeHandler: () => {
|
|
17981
18448
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, arguments), {
|
|
17982
18449
|
name: "ioredis.connect",
|
|
17983
|
-
kind: import_src$
|
|
18450
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
17984
18451
|
submodule: "connect",
|
|
17985
18452
|
packageType: PackageType.REDIS,
|
|
17986
18453
|
packageName: "ioredis",
|
|
@@ -17997,7 +18464,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
17997
18464
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
17998
18465
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalConnect.apply(this, arguments), {
|
|
17999
18466
|
name: "ioredis.connect",
|
|
18000
|
-
kind: import_src$
|
|
18467
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18001
18468
|
submodule: "connect",
|
|
18002
18469
|
packageType: PackageType.REDIS,
|
|
18003
18470
|
packageName: "ioredis",
|
|
@@ -18008,7 +18475,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18008
18475
|
return self._handleRecordConnect(spanInfo, originalConnect, this);
|
|
18009
18476
|
});
|
|
18010
18477
|
},
|
|
18011
|
-
spanKind: import_src$
|
|
18478
|
+
spanKind: import_src$17.SpanKind.CLIENT
|
|
18012
18479
|
});
|
|
18013
18480
|
else return originalConnect.apply(this, arguments);
|
|
18014
18481
|
};
|
|
@@ -18056,7 +18523,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18056
18523
|
replayModeHandler: () => {
|
|
18057
18524
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExec.apply(this, args), {
|
|
18058
18525
|
name: "ioredis.pipeline.exec",
|
|
18059
|
-
kind: import_src$
|
|
18526
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18060
18527
|
submodule: "pipeline-exec",
|
|
18061
18528
|
packageType: PackageType.REDIS,
|
|
18062
18529
|
packageName: "ioredis",
|
|
@@ -18073,7 +18540,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18073
18540
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
18074
18541
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalExec.apply(this, args), {
|
|
18075
18542
|
name: "ioredis.pipeline.exec",
|
|
18076
|
-
kind: import_src$
|
|
18543
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18077
18544
|
submodule: "pipeline-exec",
|
|
18078
18545
|
packageType: PackageType.REDIS,
|
|
18079
18546
|
packageName: "ioredis",
|
|
@@ -18084,7 +18551,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18084
18551
|
return self._handleRecordPipelineExec(spanInfo, originalExec, this, args);
|
|
18085
18552
|
});
|
|
18086
18553
|
},
|
|
18087
|
-
spanKind: import_src$
|
|
18554
|
+
spanKind: import_src$17.SpanKind.CLIENT
|
|
18088
18555
|
});
|
|
18089
18556
|
else return originalExec.apply(this, args);
|
|
18090
18557
|
};
|
|
@@ -18097,7 +18564,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18097
18564
|
logger.debug(`[IORedisInstrumentation] IORedis command ${cmd.name} completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
18098
18565
|
const outputValue = this._serializeOutput(result);
|
|
18099
18566
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
18100
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18567
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18101
18568
|
} catch (error) {
|
|
18102
18569
|
logger.error(`[IORedisInstrumentation] error processing command response:`, error);
|
|
18103
18570
|
}
|
|
@@ -18106,7 +18573,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18106
18573
|
try {
|
|
18107
18574
|
logger.debug(`[IORedisInstrumentation] IORedis command ${cmd.name} error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
18108
18575
|
SpanUtils.endSpan(spanInfo.span, {
|
|
18109
|
-
code: import_src$
|
|
18576
|
+
code: import_src$17.SpanStatusCode.ERROR,
|
|
18110
18577
|
message: error.message
|
|
18111
18578
|
});
|
|
18112
18579
|
} catch (spanError) {
|
|
@@ -18127,7 +18594,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18127
18594
|
packageName: "ioredis",
|
|
18128
18595
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
18129
18596
|
submoduleName: cmd.name,
|
|
18130
|
-
kind: import_src$
|
|
18597
|
+
kind: import_src$17.SpanKind.CLIENT,
|
|
18131
18598
|
stackTrace
|
|
18132
18599
|
},
|
|
18133
18600
|
tuskDrift: this.tuskDrift
|
|
@@ -18149,7 +18616,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18149
18616
|
try {
|
|
18150
18617
|
logger.debug(`[IORedisInstrumentation] IORedis connect completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
18151
18618
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
18152
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18619
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18153
18620
|
} catch {
|
|
18154
18621
|
logger.error(`[IORedisInstrumentation] error adding span attributes`);
|
|
18155
18622
|
}
|
|
@@ -18158,7 +18625,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18158
18625
|
try {
|
|
18159
18626
|
logger.debug(`[IORedisInstrumentation] IORedis connect error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
18160
18627
|
SpanUtils.endSpan(spanInfo.span, {
|
|
18161
|
-
code: import_src$
|
|
18628
|
+
code: import_src$17.SpanStatusCode.ERROR,
|
|
18162
18629
|
message: error.message
|
|
18163
18630
|
});
|
|
18164
18631
|
} catch {
|
|
@@ -18169,7 +18636,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18169
18636
|
try {
|
|
18170
18637
|
logger.debug(`[IORedisInstrumentation] IORedis connect completed (synchronous) (${SpanUtils.getTraceInfo()})`);
|
|
18171
18638
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: { connected: true } });
|
|
18172
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18639
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18173
18640
|
} catch {
|
|
18174
18641
|
logger.error(`[IORedisInstrumentation] error adding span attributes`);
|
|
18175
18642
|
}
|
|
@@ -18189,7 +18656,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18189
18656
|
logger.debug(`[IORedisInstrumentation] Pipeline exec completed successfully (${SpanUtils.getTraceInfo()})`);
|
|
18190
18657
|
const outputValue = this._serializePipelineOutput(results);
|
|
18191
18658
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
18192
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
18659
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$17.SpanStatusCode.OK });
|
|
18193
18660
|
} catch {
|
|
18194
18661
|
logger.error(`[IORedisInstrumentation] error adding span attributes`);
|
|
18195
18662
|
}
|
|
@@ -18198,7 +18665,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18198
18665
|
try {
|
|
18199
18666
|
logger.debug(`[IORedisInstrumentation] Pipeline exec error: ${error.message} (${SpanUtils.getTraceInfo()})`);
|
|
18200
18667
|
SpanUtils.endSpan(spanInfo.span, {
|
|
18201
|
-
code: import_src$
|
|
18668
|
+
code: import_src$17.SpanStatusCode.ERROR,
|
|
18202
18669
|
message: error.message
|
|
18203
18670
|
});
|
|
18204
18671
|
} catch {
|
|
@@ -18219,7 +18686,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18219
18686
|
packageName: "ioredis",
|
|
18220
18687
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
18221
18688
|
submoduleName: "pipeline-exec",
|
|
18222
|
-
kind: import_src$
|
|
18689
|
+
kind: import_src$17.SpanKind.CLIENT
|
|
18223
18690
|
},
|
|
18224
18691
|
tuskDrift: this.tuskDrift
|
|
18225
18692
|
});
|
|
@@ -18259,12 +18726,12 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18259
18726
|
}
|
|
18260
18727
|
_deserializePipelineOutput(outputValue) {
|
|
18261
18728
|
if (!outputValue) return [];
|
|
18262
|
-
return outputValue.value || outputValue;
|
|
18729
|
+
return deserializeBufferValue(outputValue.value || outputValue);
|
|
18263
18730
|
}
|
|
18264
18731
|
_deserializeOutput(outputValue) {
|
|
18265
18732
|
if (!outputValue) return;
|
|
18266
|
-
if (typeof outputValue !== "object" || !("value" in outputValue)) return outputValue;
|
|
18267
|
-
return outputValue.value;
|
|
18733
|
+
if (typeof outputValue !== "object" || !("value" in outputValue)) return deserializeBufferValue(outputValue);
|
|
18734
|
+
return deserializeBufferValue(outputValue.value);
|
|
18268
18735
|
}
|
|
18269
18736
|
_wrap(target, propertyName, wrapper) {
|
|
18270
18737
|
wrap(target, propertyName, wrapper);
|
|
@@ -18273,7 +18740,7 @@ var IORedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18273
18740
|
|
|
18274
18741
|
//#endregion
|
|
18275
18742
|
//#region src/instrumentation/libraries/upstash-redis-js/Instrumentation.ts
|
|
18276
|
-
var import_src$
|
|
18743
|
+
var import_src$16 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
18277
18744
|
const SUPPORTED_VERSIONS = [">=1.0.0"];
|
|
18278
18745
|
const REDIS_COMMANDS = [
|
|
18279
18746
|
"get",
|
|
@@ -18530,7 +18997,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18530
18997
|
replayModeHandler: () => {
|
|
18531
18998
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalValue.apply(this === receiver ? target : this, args), {
|
|
18532
18999
|
name: operationName,
|
|
18533
|
-
kind: import_src$
|
|
19000
|
+
kind: import_src$16.SpanKind.CLIENT,
|
|
18534
19001
|
submodule: submoduleName,
|
|
18535
19002
|
packageType: PackageType.REDIS,
|
|
18536
19003
|
packageName: "@upstash/redis",
|
|
@@ -18547,7 +19014,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18547
19014
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
18548
19015
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalValue.apply(this === receiver ? target : this, args), {
|
|
18549
19016
|
name: operationName,
|
|
18550
|
-
kind: import_src$
|
|
19017
|
+
kind: import_src$16.SpanKind.CLIENT,
|
|
18551
19018
|
submodule: submoduleName,
|
|
18552
19019
|
packageType: PackageType.REDIS,
|
|
18553
19020
|
packageName: "@upstash/redis",
|
|
@@ -18559,7 +19026,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18559
19026
|
return self._handleRecordCommand(spanInfo, originalValue, this === receiver ? target : this, args);
|
|
18560
19027
|
});
|
|
18561
19028
|
},
|
|
18562
|
-
spanKind: import_src$
|
|
19029
|
+
spanKind: import_src$16.SpanKind.CLIENT
|
|
18563
19030
|
});
|
|
18564
19031
|
else return originalValue.apply(this === receiver ? target : this, args);
|
|
18565
19032
|
};
|
|
@@ -18574,7 +19041,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18574
19041
|
const outputValue = { result };
|
|
18575
19042
|
try {
|
|
18576
19043
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
18577
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
19044
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$16.SpanStatusCode.OK });
|
|
18578
19045
|
} catch (error) {
|
|
18579
19046
|
logger.error(`[UpstashRedisInstrumentation] Error adding span attributes: ${error}`);
|
|
18580
19047
|
}
|
|
@@ -18582,7 +19049,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18582
19049
|
} catch (error) {
|
|
18583
19050
|
logger.debug(`[UpstashRedisInstrumentation] Command error: ${error}`);
|
|
18584
19051
|
try {
|
|
18585
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
19052
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$16.SpanStatusCode.ERROR });
|
|
18586
19053
|
} catch (error$1) {
|
|
18587
19054
|
logger.error(`[UpstashRedisInstrumentation] Error ending span: ${error$1}`);
|
|
18588
19055
|
}
|
|
@@ -18600,7 +19067,7 @@ var UpstashRedisInstrumentation = class extends TdInstrumentationBase {
|
|
|
18600
19067
|
packageName: "@upstash/redis",
|
|
18601
19068
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
18602
19069
|
submoduleName,
|
|
18603
|
-
kind: import_src$
|
|
19070
|
+
kind: import_src$16.SpanKind.CLIENT,
|
|
18604
19071
|
stackTrace
|
|
18605
19072
|
},
|
|
18606
19073
|
tuskDrift: this.tuskDrift
|
|
@@ -18773,7 +19240,7 @@ function deepClone(obj) {
|
|
|
18773
19240
|
|
|
18774
19241
|
//#endregion
|
|
18775
19242
|
//#region src/instrumentation/libraries/grpc/Instrumentation.ts
|
|
18776
|
-
var import_src$
|
|
19243
|
+
var import_src$15 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
18777
19244
|
const GRPC_MODULE_NAME = "@grpc/grpc-js";
|
|
18778
19245
|
var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBase {
|
|
18779
19246
|
constructor(config = {}) {
|
|
@@ -18835,16 +19302,28 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18835
19302
|
/**
|
|
18836
19303
|
* Helper method to parse optional unary response arguments
|
|
18837
19304
|
*
|
|
18838
|
-
* Handles the following cases:
|
|
18839
|
-
* 1. (
|
|
18840
|
-
* 2. (metadata: Metadata,
|
|
19305
|
+
* Handles the following cases (matching grpc-node's checkOptionalUnaryResponseArguments):
|
|
19306
|
+
* 1. (callback: Function) - callback only, no metadata or options
|
|
19307
|
+
* 2. (metadata: Metadata, callback: Function) - metadata + callback, no options
|
|
19308
|
+
* 3. (options: Object, callback: Function) - options + callback, no metadata
|
|
19309
|
+
* 4. (metadata: Metadata, options: Object, callback: Function) - full signature
|
|
18841
19310
|
*/
|
|
18842
19311
|
parseUnaryCallArguments(MetadataConstructor, arg1, arg2, arg3) {
|
|
19312
|
+
if (typeof arg1 === "function") return {
|
|
19313
|
+
metadata: new MetadataConstructor(),
|
|
19314
|
+
options: {},
|
|
19315
|
+
callback: arg1
|
|
19316
|
+
};
|
|
18843
19317
|
if (arg1 instanceof MetadataConstructor && typeof arg2 === "function") return {
|
|
18844
19318
|
metadata: arg1,
|
|
18845
19319
|
options: {},
|
|
18846
19320
|
callback: arg2
|
|
18847
19321
|
};
|
|
19322
|
+
if (!(arg1 instanceof MetadataConstructor) && typeof arg1 === "object" && arg1 !== null && typeof arg2 === "function") return {
|
|
19323
|
+
metadata: new MetadataConstructor(),
|
|
19324
|
+
options: arg1,
|
|
19325
|
+
callback: arg2
|
|
19326
|
+
};
|
|
18848
19327
|
if (arg1 instanceof MetadataConstructor && arg2 instanceof Object && typeof arg3 === "function") return {
|
|
18849
19328
|
metadata: arg1,
|
|
18850
19329
|
options: arg2,
|
|
@@ -18924,7 +19403,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18924
19403
|
replayModeHandler: () => {
|
|
18925
19404
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
18926
19405
|
name: "grpc.client.unary",
|
|
18927
|
-
kind: import_src$
|
|
19406
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
18928
19407
|
submodule: "client",
|
|
18929
19408
|
packageType: PackageType.GRPC,
|
|
18930
19409
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -18941,7 +19420,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18941
19420
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
18942
19421
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
18943
19422
|
name: "grpc.client.unary",
|
|
18944
|
-
kind: import_src$
|
|
19423
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
18945
19424
|
submodule: "client",
|
|
18946
19425
|
packageType: PackageType.GRPC,
|
|
18947
19426
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -18952,7 +19431,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
18952
19431
|
return self._handleRecordUnaryRequest(spanInfo, original, this, parsedParams, callback);
|
|
18953
19432
|
});
|
|
18954
19433
|
},
|
|
18955
|
-
spanKind: import_src$
|
|
19434
|
+
spanKind: import_src$15.SpanKind.CLIENT
|
|
18956
19435
|
});
|
|
18957
19436
|
else return original.apply(this, args);
|
|
18958
19437
|
};
|
|
@@ -19018,7 +19497,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19018
19497
|
replayModeHandler: () => {
|
|
19019
19498
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
19020
19499
|
name: "grpc.client.server_stream",
|
|
19021
|
-
kind: import_src$
|
|
19500
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
19022
19501
|
submodule: "client",
|
|
19023
19502
|
packageType: PackageType.GRPC,
|
|
19024
19503
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -19035,7 +19514,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19035
19514
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19036
19515
|
return SpanUtils.createAndExecuteSpan(self.mode, () => original.apply(this, args), {
|
|
19037
19516
|
name: "grpc.client.server_stream",
|
|
19038
|
-
kind: import_src$
|
|
19517
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
19039
19518
|
submodule: "client",
|
|
19040
19519
|
packageType: PackageType.GRPC,
|
|
19041
19520
|
packageName: GRPC_MODULE_NAME,
|
|
@@ -19046,7 +19525,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19046
19525
|
return self._handleRecordServerStreamRequest(spanInfo, original, this, parsedParams);
|
|
19047
19526
|
});
|
|
19048
19527
|
},
|
|
19049
|
-
spanKind: import_src$
|
|
19528
|
+
spanKind: import_src$15.SpanKind.CLIENT
|
|
19050
19529
|
});
|
|
19051
19530
|
else return original.apply(this, args);
|
|
19052
19531
|
};
|
|
@@ -19129,7 +19608,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19129
19608
|
status,
|
|
19130
19609
|
bufferMap: responseBufferMap,
|
|
19131
19610
|
jsonableStringMap: responseJsonableStringMap
|
|
19132
|
-
}, import_src$
|
|
19611
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19133
19612
|
else if (isStatusEmitted && hasErrorOccurred) completeSpan({
|
|
19134
19613
|
error: {
|
|
19135
19614
|
message: serviceError.message,
|
|
@@ -19138,7 +19617,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19138
19617
|
},
|
|
19139
19618
|
status,
|
|
19140
19619
|
metadata: responseMetadataInitial
|
|
19141
|
-
}, import_src$
|
|
19620
|
+
}, import_src$15.SpanStatusCode.ERROR, serviceError.message);
|
|
19142
19621
|
} catch (e) {
|
|
19143
19622
|
logger.error(`[GrpcInstrumentation] Error in patchedCallback:`, e);
|
|
19144
19623
|
}
|
|
@@ -19170,7 +19649,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19170
19649
|
status,
|
|
19171
19650
|
bufferMap: responseBufferMap,
|
|
19172
19651
|
jsonableStringMap: responseJsonableStringMap
|
|
19173
|
-
}, import_src$
|
|
19652
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19174
19653
|
else if (hasErrorOccurred) completeSpan({
|
|
19175
19654
|
error: {
|
|
19176
19655
|
message: serviceError.message,
|
|
@@ -19179,7 +19658,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19179
19658
|
},
|
|
19180
19659
|
status,
|
|
19181
19660
|
metadata: responseMetadataInitial
|
|
19182
|
-
}, import_src$
|
|
19661
|
+
}, import_src$15.SpanStatusCode.ERROR, serviceError.message);
|
|
19183
19662
|
});
|
|
19184
19663
|
return result;
|
|
19185
19664
|
}
|
|
@@ -19203,7 +19682,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19203
19682
|
packageType: PackageType.GRPC,
|
|
19204
19683
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
19205
19684
|
submoduleName: "client",
|
|
19206
|
-
kind: import_src$
|
|
19685
|
+
kind: import_src$15.SpanKind.CLIENT,
|
|
19207
19686
|
stackTrace
|
|
19208
19687
|
},
|
|
19209
19688
|
tuskDrift: this.tuskDrift
|
|
@@ -19307,14 +19786,14 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19307
19786
|
status,
|
|
19308
19787
|
bufferMap: {},
|
|
19309
19788
|
jsonableStringMap: {}
|
|
19310
|
-
}, import_src$
|
|
19789
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19311
19790
|
else if (!hasErrorOccurred && streamResponses.length === 0) completeSpan({
|
|
19312
19791
|
body: [],
|
|
19313
19792
|
metadata: responseMetadataInitial,
|
|
19314
19793
|
status,
|
|
19315
19794
|
bufferMap: {},
|
|
19316
19795
|
jsonableStringMap: {}
|
|
19317
|
-
}, import_src$
|
|
19796
|
+
}, import_src$15.SpanStatusCode.OK);
|
|
19318
19797
|
else if (hasErrorOccurred) completeSpan({
|
|
19319
19798
|
error: {
|
|
19320
19799
|
message: serviceError.message,
|
|
@@ -19323,7 +19802,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19323
19802
|
},
|
|
19324
19803
|
status,
|
|
19325
19804
|
metadata: responseMetadataInitial
|
|
19326
|
-
}, import_src$
|
|
19805
|
+
}, import_src$15.SpanStatusCode.ERROR, serviceError.message);
|
|
19327
19806
|
});
|
|
19328
19807
|
return stream;
|
|
19329
19808
|
}
|
|
@@ -19348,7 +19827,7 @@ var GrpcInstrumentation = class GrpcInstrumentation extends TdInstrumentationBas
|
|
|
19348
19827
|
packageType: PackageType.GRPC,
|
|
19349
19828
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
19350
19829
|
submoduleName: "client",
|
|
19351
|
-
kind: import_src$
|
|
19830
|
+
kind: import_src$15.SpanKind.CLIENT
|
|
19352
19831
|
},
|
|
19353
19832
|
tuskDrift: this.tuskDrift
|
|
19354
19833
|
}).then((mockData) => {
|
|
@@ -19620,7 +20099,7 @@ var TdFirestoreWriteResultMock = class {
|
|
|
19620
20099
|
|
|
19621
20100
|
//#endregion
|
|
19622
20101
|
//#region src/instrumentation/libraries/firestore/Instrumentation.ts
|
|
19623
|
-
var import_src$
|
|
20102
|
+
var import_src$14 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
19624
20103
|
const FIRESTORE_VERSION = "7.*";
|
|
19625
20104
|
const PACKAGE_NAME = "@google-cloud/firestore";
|
|
19626
20105
|
var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
@@ -19728,7 +20207,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19728
20207
|
replayModeHandler: () => {
|
|
19729
20208
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
19730
20209
|
name: "firestore.document.get",
|
|
19731
|
-
kind: import_src$
|
|
20210
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19732
20211
|
submodule: "document",
|
|
19733
20212
|
packageType: PackageType.FIRESTORE,
|
|
19734
20213
|
packageName: PACKAGE_NAME,
|
|
@@ -19746,7 +20225,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19746
20225
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19747
20226
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
19748
20227
|
name: "firestore.document.get",
|
|
19749
|
-
kind: import_src$
|
|
20228
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19750
20229
|
submodule: "document",
|
|
19751
20230
|
packageType: PackageType.FIRESTORE,
|
|
19752
20231
|
packageName: PACKAGE_NAME,
|
|
@@ -19758,7 +20237,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19758
20237
|
return self._handleRecordDocumentGet(spanInfo, originalGet, this);
|
|
19759
20238
|
});
|
|
19760
20239
|
},
|
|
19761
|
-
spanKind: import_src$
|
|
20240
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19762
20241
|
});
|
|
19763
20242
|
else return originalGet.call(this);
|
|
19764
20243
|
};
|
|
@@ -19786,7 +20265,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19786
20265
|
};
|
|
19787
20266
|
try {
|
|
19788
20267
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: documentResult });
|
|
19789
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20268
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
19790
20269
|
} catch {
|
|
19791
20270
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for document.get`);
|
|
19792
20271
|
}
|
|
@@ -19803,7 +20282,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19803
20282
|
packageName: PACKAGE_NAME,
|
|
19804
20283
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
19805
20284
|
submoduleName: "document",
|
|
19806
|
-
kind: import_src$
|
|
20285
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
19807
20286
|
},
|
|
19808
20287
|
tuskDrift: this.tuskDrift
|
|
19809
20288
|
});
|
|
@@ -19835,7 +20314,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19835
20314
|
replayModeHandler: () => {
|
|
19836
20315
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCreate.call(this, data), {
|
|
19837
20316
|
name: "firestore.document.create",
|
|
19838
|
-
kind: import_src$
|
|
20317
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19839
20318
|
submodule: "document",
|
|
19840
20319
|
packageType: PackageType.FIRESTORE,
|
|
19841
20320
|
packageName: PACKAGE_NAME,
|
|
@@ -19853,7 +20332,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19853
20332
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19854
20333
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalCreate.call(this, data), {
|
|
19855
20334
|
name: "firestore.document.create",
|
|
19856
|
-
kind: import_src$
|
|
20335
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19857
20336
|
submodule: "document",
|
|
19858
20337
|
packageType: PackageType.FIRESTORE,
|
|
19859
20338
|
packageName: PACKAGE_NAME,
|
|
@@ -19865,7 +20344,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19865
20344
|
return self._handleRecordDocumentWrite(spanInfo, originalCreate, this, data);
|
|
19866
20345
|
});
|
|
19867
20346
|
},
|
|
19868
|
-
spanKind: import_src$
|
|
20347
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19869
20348
|
});
|
|
19870
20349
|
else return originalCreate.call(this, data);
|
|
19871
20350
|
};
|
|
@@ -19893,7 +20372,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19893
20372
|
replayModeHandler: () => {
|
|
19894
20373
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSet.call(this, data, options), {
|
|
19895
20374
|
name: "firestore.document.set",
|
|
19896
|
-
kind: import_src$
|
|
20375
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19897
20376
|
submodule: "document",
|
|
19898
20377
|
packageType: PackageType.FIRESTORE,
|
|
19899
20378
|
packageName: PACKAGE_NAME,
|
|
@@ -19911,7 +20390,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19911
20390
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19912
20391
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalSet.call(this, data, options), {
|
|
19913
20392
|
name: "firestore.document.set",
|
|
19914
|
-
kind: import_src$
|
|
20393
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19915
20394
|
submodule: "document",
|
|
19916
20395
|
packageType: PackageType.FIRESTORE,
|
|
19917
20396
|
packageName: PACKAGE_NAME,
|
|
@@ -19923,7 +20402,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19923
20402
|
return self._handleRecordDocumentWrite(spanInfo, originalSet, this, data, options);
|
|
19924
20403
|
});
|
|
19925
20404
|
},
|
|
19926
|
-
spanKind: import_src$
|
|
20405
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19927
20406
|
});
|
|
19928
20407
|
else return originalSet.call(this, data, options);
|
|
19929
20408
|
};
|
|
@@ -19950,7 +20429,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19950
20429
|
replayModeHandler: () => {
|
|
19951
20430
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalUpdate.apply(this, args), {
|
|
19952
20431
|
name: "firestore.document.update",
|
|
19953
|
-
kind: import_src$
|
|
20432
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19954
20433
|
submodule: "document",
|
|
19955
20434
|
packageType: PackageType.FIRESTORE,
|
|
19956
20435
|
packageName: PACKAGE_NAME,
|
|
@@ -19968,7 +20447,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19968
20447
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
19969
20448
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalUpdate.apply(this, args), {
|
|
19970
20449
|
name: "firestore.document.update",
|
|
19971
|
-
kind: import_src$
|
|
20450
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
19972
20451
|
submodule: "document",
|
|
19973
20452
|
packageType: PackageType.FIRESTORE,
|
|
19974
20453
|
packageName: PACKAGE_NAME,
|
|
@@ -19980,7 +20459,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
19980
20459
|
return self._handleRecordDocumentWrite(spanInfo, originalUpdate, this, ...args);
|
|
19981
20460
|
});
|
|
19982
20461
|
},
|
|
19983
|
-
spanKind: import_src$
|
|
20462
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
19984
20463
|
});
|
|
19985
20464
|
else return originalUpdate.apply(this, args);
|
|
19986
20465
|
};
|
|
@@ -20007,7 +20486,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20007
20486
|
replayModeHandler: () => {
|
|
20008
20487
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalDelete.call(this, precondition), {
|
|
20009
20488
|
name: "firestore.document.delete",
|
|
20010
|
-
kind: import_src$
|
|
20489
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20011
20490
|
submodule: "document",
|
|
20012
20491
|
packageType: PackageType.FIRESTORE,
|
|
20013
20492
|
packageName: PACKAGE_NAME,
|
|
@@ -20025,7 +20504,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20025
20504
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20026
20505
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalDelete.call(this, precondition), {
|
|
20027
20506
|
name: "firestore.document.delete",
|
|
20028
|
-
kind: import_src$
|
|
20507
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20029
20508
|
submodule: "document",
|
|
20030
20509
|
packageType: PackageType.FIRESTORE,
|
|
20031
20510
|
packageName: PACKAGE_NAME,
|
|
@@ -20037,7 +20516,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20037
20516
|
return self._handleRecordDocumentWrite(spanInfo, originalDelete, this, precondition);
|
|
20038
20517
|
});
|
|
20039
20518
|
},
|
|
20040
|
-
spanKind: import_src$
|
|
20519
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20041
20520
|
});
|
|
20042
20521
|
else return originalDelete.call(this, precondition);
|
|
20043
20522
|
};
|
|
@@ -20051,7 +20530,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20051
20530
|
} : void 0 };
|
|
20052
20531
|
try {
|
|
20053
20532
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: result });
|
|
20054
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20533
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20055
20534
|
} catch {
|
|
20056
20535
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for document.write`);
|
|
20057
20536
|
}
|
|
@@ -20068,7 +20547,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20068
20547
|
packageName: PACKAGE_NAME,
|
|
20069
20548
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20070
20549
|
submoduleName: "document",
|
|
20071
|
-
kind: import_src$
|
|
20550
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20072
20551
|
},
|
|
20073
20552
|
tuskDrift: this.tuskDrift
|
|
20074
20553
|
});
|
|
@@ -20100,7 +20579,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20100
20579
|
replayModeHandler: () => {
|
|
20101
20580
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalAdd.call(this, data), {
|
|
20102
20581
|
name: "firestore.collection.add",
|
|
20103
|
-
kind: import_src$
|
|
20582
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20104
20583
|
submodule: "collection",
|
|
20105
20584
|
packageType: PackageType.FIRESTORE,
|
|
20106
20585
|
packageName: PACKAGE_NAME,
|
|
@@ -20118,7 +20597,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20118
20597
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20119
20598
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalAdd.call(this, data), {
|
|
20120
20599
|
name: "firestore.collection.add",
|
|
20121
|
-
kind: import_src$
|
|
20600
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20122
20601
|
submodule: "collection",
|
|
20123
20602
|
packageType: PackageType.FIRESTORE,
|
|
20124
20603
|
packageName: PACKAGE_NAME,
|
|
@@ -20130,7 +20609,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20130
20609
|
return self._handleRecordCollectionAdd(spanInfo, originalAdd, this, data);
|
|
20131
20610
|
});
|
|
20132
20611
|
},
|
|
20133
|
-
spanKind: import_src$
|
|
20612
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20134
20613
|
});
|
|
20135
20614
|
else return originalAdd.call(this, data);
|
|
20136
20615
|
};
|
|
@@ -20144,7 +20623,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20144
20623
|
};
|
|
20145
20624
|
try {
|
|
20146
20625
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: result });
|
|
20147
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20626
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20148
20627
|
} catch {
|
|
20149
20628
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for collection.add`);
|
|
20150
20629
|
}
|
|
@@ -20161,7 +20640,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20161
20640
|
packageName: PACKAGE_NAME,
|
|
20162
20641
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20163
20642
|
submoduleName: "collection",
|
|
20164
|
-
kind: import_src$
|
|
20643
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20165
20644
|
},
|
|
20166
20645
|
tuskDrift: this.tuskDrift
|
|
20167
20646
|
});
|
|
@@ -20194,7 +20673,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20194
20673
|
replayModeHandler: () => {
|
|
20195
20674
|
return SpanUtils.createAndExecuteSpan(self.mode, () => documentPath ? originalDoc.call(this, documentPath) : originalDoc.call(this), {
|
|
20196
20675
|
name: "firestore.collection.doc",
|
|
20197
|
-
kind: import_src$
|
|
20676
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20198
20677
|
submodule: "collection",
|
|
20199
20678
|
packageType: PackageType.FIRESTORE,
|
|
20200
20679
|
packageName: PACKAGE_NAME,
|
|
@@ -20212,7 +20691,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20212
20691
|
packageName: PACKAGE_NAME,
|
|
20213
20692
|
instrumentationName: self.INSTRUMENTATION_NAME,
|
|
20214
20693
|
submoduleName: "collection",
|
|
20215
|
-
kind: import_src$
|
|
20694
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20216
20695
|
},
|
|
20217
20696
|
tuskDrift: self.tuskDrift
|
|
20218
20697
|
});
|
|
@@ -20233,7 +20712,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20233
20712
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20234
20713
|
return SpanUtils.createAndExecuteSpan(self.mode, () => documentPath ? originalDoc.call(this, documentPath) : originalDoc.call(this), {
|
|
20235
20714
|
name: "firestore.collection.doc",
|
|
20236
|
-
kind: import_src$
|
|
20715
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20237
20716
|
submodule: "collection",
|
|
20238
20717
|
packageType: PackageType.FIRESTORE,
|
|
20239
20718
|
packageName: PACKAGE_NAME,
|
|
@@ -20249,14 +20728,14 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20249
20728
|
};
|
|
20250
20729
|
try {
|
|
20251
20730
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: result });
|
|
20252
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20731
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20253
20732
|
} catch {
|
|
20254
20733
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for collection.doc`);
|
|
20255
20734
|
}
|
|
20256
20735
|
return docRef;
|
|
20257
20736
|
});
|
|
20258
20737
|
},
|
|
20259
|
-
spanKind: import_src$
|
|
20738
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20260
20739
|
});
|
|
20261
20740
|
else return documentPath ? originalDoc.call(this, documentPath) : originalDoc.call(this);
|
|
20262
20741
|
};
|
|
@@ -20282,7 +20761,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20282
20761
|
replayModeHandler: () => {
|
|
20283
20762
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
20284
20763
|
name: "firestore.query.get",
|
|
20285
|
-
kind: import_src$
|
|
20764
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20286
20765
|
submodule: "query",
|
|
20287
20766
|
packageType: PackageType.FIRESTORE,
|
|
20288
20767
|
packageName: PACKAGE_NAME,
|
|
@@ -20300,7 +20779,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20300
20779
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20301
20780
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalGet.call(this), {
|
|
20302
20781
|
name: "firestore.query.get",
|
|
20303
|
-
kind: import_src$
|
|
20782
|
+
kind: import_src$14.SpanKind.CLIENT,
|
|
20304
20783
|
submodule: "query",
|
|
20305
20784
|
packageType: PackageType.FIRESTORE,
|
|
20306
20785
|
packageName: PACKAGE_NAME,
|
|
@@ -20312,7 +20791,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20312
20791
|
return self._handleRecordQueryGet(spanInfo, originalGet, this);
|
|
20313
20792
|
});
|
|
20314
20793
|
},
|
|
20315
|
-
spanKind: import_src$
|
|
20794
|
+
spanKind: import_src$14.SpanKind.CLIENT
|
|
20316
20795
|
});
|
|
20317
20796
|
else return originalGet.call(this);
|
|
20318
20797
|
};
|
|
@@ -20348,7 +20827,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20348
20827
|
};
|
|
20349
20828
|
try {
|
|
20350
20829
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue: queryResult });
|
|
20351
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
20830
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$14.SpanStatusCode.OK });
|
|
20352
20831
|
} catch {
|
|
20353
20832
|
logger.error(`[FirestoreInstrumentation] Error updating span attributes for query.get`);
|
|
20354
20833
|
}
|
|
@@ -20365,7 +20844,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20365
20844
|
packageName: PACKAGE_NAME,
|
|
20366
20845
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20367
20846
|
submoduleName: "query",
|
|
20368
|
-
kind: import_src$
|
|
20847
|
+
kind: import_src$14.SpanKind.CLIENT
|
|
20369
20848
|
},
|
|
20370
20849
|
tuskDrift: this.tuskDrift
|
|
20371
20850
|
});
|
|
@@ -20388,7 +20867,7 @@ var FirestoreInstrumentation = class extends TdInstrumentationBase {
|
|
|
20388
20867
|
|
|
20389
20868
|
//#endregion
|
|
20390
20869
|
//#region src/instrumentation/libraries/nextjs/Instrumentation.ts
|
|
20391
|
-
var import_src$
|
|
20870
|
+
var import_src$13 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
20392
20871
|
var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
20393
20872
|
constructor(config = {}) {
|
|
20394
20873
|
super("nextjs", config);
|
|
@@ -20474,10 +20953,10 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20474
20953
|
logger.debug(`[NextjsInstrumentation] Setting replay trace id`, replayTraceId);
|
|
20475
20954
|
const ctxWithReplayTraceId = SpanUtils.setCurrentReplayTraceId(replayTraceId);
|
|
20476
20955
|
if (!ctxWithReplayTraceId) throw new Error("Error setting current replay trace id");
|
|
20477
|
-
return import_src$
|
|
20956
|
+
return import_src$13.context.with(ctxWithReplayTraceId, () => {
|
|
20478
20957
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalHandleRequest.call(this, req, res, parsedUrl), {
|
|
20479
20958
|
name: url,
|
|
20480
|
-
kind: import_src$
|
|
20959
|
+
kind: import_src$13.SpanKind.SERVER,
|
|
20481
20960
|
packageName: "nextjs",
|
|
20482
20961
|
submodule: method,
|
|
20483
20962
|
packageType: PackageType.HTTP,
|
|
@@ -20513,7 +20992,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20513
20992
|
};
|
|
20514
20993
|
return SpanUtils.createAndExecuteSpan(self.mode, () => originalHandleRequest.call(this, req, res, parsedUrl), {
|
|
20515
20994
|
name: url,
|
|
20516
|
-
kind: import_src$
|
|
20995
|
+
kind: import_src$13.SpanKind.SERVER,
|
|
20517
20996
|
packageName: "nextjs",
|
|
20518
20997
|
packageType: PackageType.HTTP,
|
|
20519
20998
|
submodule: method,
|
|
@@ -20533,7 +21012,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20533
21012
|
});
|
|
20534
21013
|
});
|
|
20535
21014
|
},
|
|
20536
|
-
spanKind: import_src$
|
|
21015
|
+
spanKind: import_src$13.SpanKind.SERVER
|
|
20537
21016
|
});
|
|
20538
21017
|
} else return originalHandleRequest.call(this, req, res, parsedUrl);
|
|
20539
21018
|
};
|
|
@@ -20541,8 +21020,8 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20541
21020
|
}
|
|
20542
21021
|
async _handleNextjsRequestInSpan({ req, res, parsedUrl, originalHandleRequest, spanInfo, inputValue, thisContext }) {
|
|
20543
21022
|
const self = this;
|
|
20544
|
-
import_src$
|
|
20545
|
-
import_src$
|
|
21023
|
+
import_src$13.context.bind(spanInfo.context, req);
|
|
21024
|
+
import_src$13.context.bind(spanInfo.context, res);
|
|
20546
21025
|
let completeInputValue = inputValue;
|
|
20547
21026
|
this._captureRequestBody(req, spanInfo, inputValue, (updatedInputValue) => {
|
|
20548
21027
|
completeInputValue = updatedInputValue;
|
|
@@ -20583,7 +21062,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20583
21062
|
logger.error(`[NextjsInstrumentation] Error in Next.js request: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
20584
21063
|
try {
|
|
20585
21064
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20586
|
-
code: import_src$
|
|
21065
|
+
code: import_src$13.SpanStatusCode.ERROR,
|
|
20587
21066
|
message: error instanceof Error ? error.message : "Unknown error"
|
|
20588
21067
|
});
|
|
20589
21068
|
} catch (e) {
|
|
@@ -20629,9 +21108,9 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20629
21108
|
}
|
|
20630
21109
|
});
|
|
20631
21110
|
const status = (capturedStatusCode || 200) >= 300 ? {
|
|
20632
|
-
code: import_src$
|
|
21111
|
+
code: import_src$13.SpanStatusCode.ERROR,
|
|
20633
21112
|
message: `HTTP ${capturedStatusCode}`
|
|
20634
|
-
} : { code: import_src$
|
|
21113
|
+
} : { code: import_src$13.SpanStatusCode.OK };
|
|
20635
21114
|
SpanUtils.setStatus(spanInfo.span, status);
|
|
20636
21115
|
const decodedType = getDecodedType(outputValue.headers?.["content-type"] || "");
|
|
20637
21116
|
if (decodedType && !ACCEPTABLE_CONTENT_TYPES.has(decodedType)) {
|
|
@@ -20673,7 +21152,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20673
21152
|
outputSchemaHash: JsonSchemaHelper.generateDeterministicHash(outputSchema),
|
|
20674
21153
|
inputValueHash,
|
|
20675
21154
|
outputValueHash,
|
|
20676
|
-
kind: import_src$
|
|
21155
|
+
kind: import_src$13.SpanKind.SERVER,
|
|
20677
21156
|
packageType: PackageType.HTTP,
|
|
20678
21157
|
status: {
|
|
20679
21158
|
code: (capturedStatusCode || 200) >= 300 ? StatusCode.ERROR : StatusCode.OK,
|
|
@@ -20699,7 +21178,7 @@ var NextjsInstrumentation = class extends TdInstrumentationBase {
|
|
|
20699
21178
|
logger.error(`[NextjsInstrumentation] Error in Next.js request: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
20700
21179
|
try {
|
|
20701
21180
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20702
|
-
code: import_src$
|
|
21181
|
+
code: import_src$13.SpanStatusCode.ERROR,
|
|
20703
21182
|
message: error instanceof Error ? error.message : "Unknown error"
|
|
20704
21183
|
});
|
|
20705
21184
|
} catch (e) {
|
|
@@ -20793,7 +21272,7 @@ let PrismaErrorClassName = /* @__PURE__ */ function(PrismaErrorClassName$1) {
|
|
|
20793
21272
|
|
|
20794
21273
|
//#endregion
|
|
20795
21274
|
//#region src/instrumentation/libraries/prisma/Instrumentation.ts
|
|
20796
|
-
var import_src$
|
|
21275
|
+
var import_src$12 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
20797
21276
|
var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
20798
21277
|
constructor(config = {}) {
|
|
20799
21278
|
super("@prisma/client", config);
|
|
@@ -20879,7 +21358,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20879
21358
|
recordModeHandler: ({ isPreAppStart }) => {
|
|
20880
21359
|
return SpanUtils.createAndExecuteSpan(this.mode, () => query(args), {
|
|
20881
21360
|
name: `prisma.${operation}`,
|
|
20882
|
-
kind: import_src$
|
|
21361
|
+
kind: import_src$12.SpanKind.CLIENT,
|
|
20883
21362
|
submodule: model,
|
|
20884
21363
|
packageType: PackageType.PRISMA,
|
|
20885
21364
|
packageName: "@prisma/client",
|
|
@@ -20890,7 +21369,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20890
21369
|
return this._handleRecordPrismaOperation(spanInfo, query, args);
|
|
20891
21370
|
});
|
|
20892
21371
|
},
|
|
20893
|
-
spanKind: import_src$
|
|
21372
|
+
spanKind: import_src$12.SpanKind.CLIENT
|
|
20894
21373
|
});
|
|
20895
21374
|
else if (this.mode === TuskDriftMode.REPLAY) {
|
|
20896
21375
|
const stackTrace = captureStackTrace(["PrismaInstrumentation"]);
|
|
@@ -20900,7 +21379,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20900
21379
|
replayModeHandler: () => {
|
|
20901
21380
|
return SpanUtils.createAndExecuteSpan(this.mode, () => query(args), {
|
|
20902
21381
|
name: `prisma.${operation}`,
|
|
20903
|
-
kind: import_src$
|
|
21382
|
+
kind: import_src$12.SpanKind.CLIENT,
|
|
20904
21383
|
submodule: model,
|
|
20905
21384
|
packageType: PackageType.PRISMA,
|
|
20906
21385
|
packageName: "@prisma/client",
|
|
@@ -20924,7 +21403,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20924
21403
|
};
|
|
20925
21404
|
try {
|
|
20926
21405
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
20927
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
21406
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$12.SpanStatusCode.OK });
|
|
20928
21407
|
} catch (spanError) {
|
|
20929
21408
|
logger.error(`[PrismaInstrumentation] error adding span attributes:`, spanError);
|
|
20930
21409
|
}
|
|
@@ -20941,7 +21420,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20941
21420
|
};
|
|
20942
21421
|
SpanUtils.addSpanAttributes(spanInfo.span, { outputValue });
|
|
20943
21422
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20944
|
-
code: import_src$
|
|
21423
|
+
code: import_src$12.SpanStatusCode.ERROR,
|
|
20945
21424
|
message: error.message
|
|
20946
21425
|
});
|
|
20947
21426
|
} catch (spanError) {
|
|
@@ -20960,7 +21439,7 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20960
21439
|
packageName: "@prisma/client",
|
|
20961
21440
|
instrumentationName: this.INSTRUMENTATION_NAME,
|
|
20962
21441
|
submoduleName: inputValue.model,
|
|
20963
|
-
kind: import_src$
|
|
21442
|
+
kind: import_src$12.SpanKind.CLIENT,
|
|
20964
21443
|
stackTrace
|
|
20965
21444
|
},
|
|
20966
21445
|
tuskDrift: this.tuskDrift
|
|
@@ -20978,12 +21457,12 @@ var PrismaInstrumentation = class extends TdInstrumentationBase {
|
|
|
20978
21457
|
if (errorClass) Object.setPrototypeOf(errorObj, errorClass.prototype);
|
|
20979
21458
|
}
|
|
20980
21459
|
SpanUtils.endSpan(spanInfo.span, {
|
|
20981
|
-
code: import_src$
|
|
21460
|
+
code: import_src$12.SpanStatusCode.ERROR,
|
|
20982
21461
|
message: errorObj.message || "Prisma error"
|
|
20983
21462
|
});
|
|
20984
21463
|
throw errorObj;
|
|
20985
21464
|
}
|
|
20986
|
-
SpanUtils.endSpan(spanInfo.span, { code: import_src$
|
|
21465
|
+
SpanUtils.endSpan(spanInfo.span, { code: import_src$12.SpanStatusCode.OK });
|
|
20987
21466
|
return outputValue.prismaResult;
|
|
20988
21467
|
}
|
|
20989
21468
|
_getPrismaErrorClassName(error) {
|
|
@@ -25144,8 +25623,8 @@ var require_src$6 = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/co
|
|
|
25144
25623
|
|
|
25145
25624
|
//#endregion
|
|
25146
25625
|
//#region src/core/tracing/SpanTransformer.ts
|
|
25147
|
-
var import_src$
|
|
25148
|
-
var import_src$
|
|
25626
|
+
var import_src$10 = /* @__PURE__ */ __toESM(require_src$6(), 1);
|
|
25627
|
+
var import_src$11 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
25149
25628
|
/**
|
|
25150
25629
|
* Utility class for transforming OpenTelemetry spans to CleanSpanData
|
|
25151
25630
|
*/
|
|
@@ -25156,7 +25635,7 @@ var SpanTransformer = class SpanTransformer {
|
|
|
25156
25635
|
* We use JSON because serialized protobuf is extremely verbose and not readable.
|
|
25157
25636
|
*/
|
|
25158
25637
|
static transformSpanToCleanJSON(span, environment) {
|
|
25159
|
-
const isRootSpan =
|
|
25638
|
+
const isRootSpan = span.kind === import_src$11.SpanKind.SERVER;
|
|
25160
25639
|
const attributes = span.attributes;
|
|
25161
25640
|
const packageName = SpanTransformer.extractPackageName(attributes);
|
|
25162
25641
|
const instrumentationName = SpanTransformer.extractInstrumentationName(span, attributes);
|
|
@@ -25276,11 +25755,11 @@ var FilesystemSpanAdapter = class {
|
|
|
25276
25755
|
fs$1.appendFileSync(filePath, jsonLine, "utf8");
|
|
25277
25756
|
}
|
|
25278
25757
|
logger.debug(`Exported ${spans.length} span(s) to trace-specific files in ${this.baseDirectory}`);
|
|
25279
|
-
return { code: import_src$
|
|
25758
|
+
return { code: import_src$10.ExportResultCode.SUCCESS };
|
|
25280
25759
|
} catch (error) {
|
|
25281
25760
|
logger.error(`Failed to export spans to local files:`, error);
|
|
25282
25761
|
return {
|
|
25283
|
-
code: import_src$
|
|
25762
|
+
code: import_src$10.ExportResultCode.FAILED,
|
|
25284
25763
|
error: error instanceof Error ? error : /* @__PURE__ */ new Error("Filesystem export failed")
|
|
25285
25764
|
};
|
|
25286
25765
|
}
|
|
@@ -25635,9 +26114,9 @@ var require_commonjs = /* @__PURE__ */ __commonJS({ "node_modules/@protobuf-ts/t
|
|
|
25635
26114
|
|
|
25636
26115
|
//#endregion
|
|
25637
26116
|
//#region src/core/tracing/adapters/ApiSpanAdapter.ts
|
|
25638
|
-
var import_src$
|
|
26117
|
+
var import_src$8 = /* @__PURE__ */ __toESM(require_src$6(), 1);
|
|
25639
26118
|
var import_commonjs$2 = /* @__PURE__ */ __toESM(require_commonjs(), 1);
|
|
25640
|
-
var import_src$
|
|
26119
|
+
var import_src$9 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
25641
26120
|
const DRIFT_API_PATH = "/api/drift";
|
|
25642
26121
|
/**
|
|
25643
26122
|
* Exports spans to Tusk backend API via protobuf
|
|
@@ -25671,11 +26150,11 @@ var ApiSpanAdapter = class {
|
|
|
25671
26150
|
const response = await this.spanExportClient.exportSpans(request);
|
|
25672
26151
|
if (!response.response.success) throw new Error(`Remote export failed: ${response.response.message}`);
|
|
25673
26152
|
logger.debug(`Successfully exported ${spans.length} spans to remote endpoint`);
|
|
25674
|
-
return { code: import_src$
|
|
26153
|
+
return { code: import_src$8.ExportResultCode.SUCCESS };
|
|
25675
26154
|
} catch (error) {
|
|
25676
26155
|
logger.error(`Failed to export spans to remote:`, error);
|
|
25677
26156
|
return {
|
|
25678
|
-
code: import_src$
|
|
26157
|
+
code: import_src$8.ExportResultCode.FAILED,
|
|
25679
26158
|
error: error instanceof Error ? error : /* @__PURE__ */ new Error("API export failed")
|
|
25680
26159
|
};
|
|
25681
26160
|
}
|
|
@@ -25716,12 +26195,12 @@ var ApiSpanAdapter = class {
|
|
|
25716
26195
|
}
|
|
25717
26196
|
mapSpanKind(kind) {
|
|
25718
26197
|
switch (kind) {
|
|
25719
|
-
case import_src$
|
|
25720
|
-
case import_src$
|
|
25721
|
-
case import_src$
|
|
25722
|
-
case import_src$
|
|
25723
|
-
case import_src$
|
|
25724
|
-
default: return SpanKind$
|
|
26198
|
+
case import_src$9.SpanKind.CLIENT: return SpanKind$2.CLIENT;
|
|
26199
|
+
case import_src$9.SpanKind.SERVER: return SpanKind$2.SERVER;
|
|
26200
|
+
case import_src$9.SpanKind.PRODUCER: return SpanKind$2.PRODUCER;
|
|
26201
|
+
case import_src$9.SpanKind.CONSUMER: return SpanKind$2.CONSUMER;
|
|
26202
|
+
case import_src$9.SpanKind.INTERNAL: return SpanKind$2.INTERNAL;
|
|
26203
|
+
default: return SpanKind$2.UNSPECIFIED;
|
|
25725
26204
|
}
|
|
25726
26205
|
}
|
|
25727
26206
|
async shutdown() {
|
|
@@ -25732,6 +26211,8 @@ var ApiSpanAdapter = class {
|
|
|
25732
26211
|
//#endregion
|
|
25733
26212
|
//#region src/core/tracing/TdSpanExporter.ts
|
|
25734
26213
|
var import_src$5 = /* @__PURE__ */ __toESM(require_src$6(), 1);
|
|
26214
|
+
var import_src$6 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
26215
|
+
var import_src$7 = /* @__PURE__ */ __toESM(require_src$7(), 1);
|
|
25735
26216
|
var TdSpanExporter = class {
|
|
25736
26217
|
constructor(config) {
|
|
25737
26218
|
this.adapters = [];
|
|
@@ -25784,15 +26265,13 @@ var TdSpanExporter = class {
|
|
|
25784
26265
|
logger.debug("All adapters cleared");
|
|
25785
26266
|
}
|
|
25786
26267
|
/**
|
|
25787
|
-
* Set the mode for determining which adapters to run
|
|
25788
|
-
*/
|
|
25789
|
-
setMode(mode) {
|
|
25790
|
-
this.mode = mode;
|
|
25791
|
-
}
|
|
25792
|
-
/**
|
|
25793
26268
|
* Export spans using all configured adapters
|
|
25794
26269
|
*/
|
|
25795
26270
|
export(spans, resultCallback) {
|
|
26271
|
+
if (this.mode !== TuskDriftMode.RECORD) {
|
|
26272
|
+
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
26273
|
+
return;
|
|
26274
|
+
}
|
|
25796
26275
|
logger.debug(`TdSpanExporter.export() called with ${spans.length} span(s)`);
|
|
25797
26276
|
const traceBlockingManager = TraceBlockingManager.getInstance();
|
|
25798
26277
|
const filteredSpansBasedOnLibraryName = spans.filter((span) => {
|
|
@@ -25808,6 +26287,11 @@ var TdSpanExporter = class {
|
|
|
25808
26287
|
logger.debug(`Skipping span '${span.name}' (${span.spanContext().spanId}) - trace ${traceId} is blocked`);
|
|
25809
26288
|
return false;
|
|
25810
26289
|
}
|
|
26290
|
+
if (span.kind === import_src$7.SpanKind.SERVER && span.status.code === import_src$6.SpanStatusCode.ERROR) {
|
|
26291
|
+
traceBlockingManager.blockTrace(traceId);
|
|
26292
|
+
logger.debug(`Blocking trace ${traceId} - server span has error status`);
|
|
26293
|
+
return false;
|
|
26294
|
+
}
|
|
25811
26295
|
const inputValueString = span.attributes[TdSpanAttributes.INPUT_VALUE] || "";
|
|
25812
26296
|
const outputValueString = span.attributes[TdSpanAttributes.OUTPUT_VALUE] || "";
|
|
25813
26297
|
const estimatedTotalSize = Buffer.byteLength(inputValueString, "utf8") + Buffer.byteLength(outputValueString, "utf8") + 5e4;
|
|
@@ -25826,21 +26310,16 @@ var TdSpanExporter = class {
|
|
|
25826
26310
|
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
25827
26311
|
return;
|
|
25828
26312
|
}
|
|
25829
|
-
|
|
25830
|
-
if (activeAdapters.length === 0) {
|
|
26313
|
+
if (this.adapters.length === 0) {
|
|
25831
26314
|
logger.debug(`No active adapters for mode: ${this.mode}`);
|
|
25832
26315
|
resultCallback({ code: import_src$5.ExportResultCode.SUCCESS });
|
|
25833
26316
|
return;
|
|
25834
26317
|
}
|
|
25835
|
-
Promise.all(
|
|
26318
|
+
Promise.all(this.adapters.map((adapter) => adapter.exportSpans(cleanSpans))).then(() => resultCallback({ code: import_src$5.ExportResultCode.SUCCESS })).catch((error) => resultCallback({
|
|
25836
26319
|
code: import_src$5.ExportResultCode.FAILED,
|
|
25837
26320
|
error
|
|
25838
26321
|
}));
|
|
25839
26322
|
}
|
|
25840
|
-
getActiveAdapters() {
|
|
25841
|
-
if (this.mode !== TuskDriftMode.RECORD) return this.adapters.filter((adapter) => adapter.name === "in-memory" || adapter.name === "callback");
|
|
25842
|
-
return this.adapters;
|
|
25843
|
-
}
|
|
25844
26323
|
/**
|
|
25845
26324
|
* Shutdown all adapters
|
|
25846
26325
|
*/
|
|
@@ -32971,7 +33450,7 @@ var require_src = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/sdk-
|
|
|
32971
33450
|
//#endregion
|
|
32972
33451
|
//#region package.json
|
|
32973
33452
|
var import_src$1 = /* @__PURE__ */ __toESM(require_src(), 1);
|
|
32974
|
-
var version = "0.1.
|
|
33453
|
+
var version = "0.1.22";
|
|
32975
33454
|
|
|
32976
33455
|
//#endregion
|
|
32977
33456
|
//#region src/version.ts
|
|
@@ -34870,14 +35349,8 @@ var TuskDriftCore = class TuskDriftCore {
|
|
|
34870
35349
|
logger.debug(`Using TCP connection to CLI: ${mockHost}:${mockPort}`);
|
|
34871
35350
|
} else {
|
|
34872
35351
|
const socketPath = mockSocket || path.join(os.tmpdir(), "tusk-connect.sock");
|
|
34873
|
-
|
|
34874
|
-
|
|
34875
|
-
if (!fs.statSync(socketPath).isSocket()) throw new Error(`Path exists but is not a socket: ${socketPath}`);
|
|
34876
|
-
logger.debug("Socket found and verified at", socketPath);
|
|
34877
|
-
} catch (error) {
|
|
34878
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") throw new Error(`Socket not found at ${socketPath}. Make sure Tusk CLI is running.`);
|
|
34879
|
-
throw new Error(`Socket check failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
34880
|
-
}
|
|
35352
|
+
if (!fs.existsSync(socketPath)) throw new Error(`Socket not found at ${socketPath}. Make sure Tusk CLI is running.`);
|
|
35353
|
+
logger.debug("Socket found at", socketPath);
|
|
34881
35354
|
connectionInfo = { socketPath };
|
|
34882
35355
|
}
|
|
34883
35356
|
this.cliConnectionPromise = this.communicator.connect(connectionInfo, this.config.service?.id || "unknown").then(() => {
|