autotel 2.25.2 → 2.25.4
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/README.md +152 -1
- package/dist/attributes.d.cts +2 -2
- package/dist/attributes.d.ts +2 -2
- package/dist/auto.cjs +6 -6
- package/dist/auto.js +4 -4
- package/dist/{chunk-BGVKKL2N.cjs → chunk-7FIGORWI.cjs} +46 -2
- package/dist/chunk-7FIGORWI.cjs.map +1 -0
- package/dist/{chunk-4KGC5N3J.cjs → chunk-A5ZUL2RZ.cjs} +16 -16
- package/dist/{chunk-4KGC5N3J.cjs.map → chunk-A5ZUL2RZ.cjs.map} +1 -1
- package/dist/{chunk-SR35DG5A.js → chunk-BBBWDIYQ.js} +27 -13
- package/dist/chunk-BBBWDIYQ.js.map +1 -0
- package/dist/{chunk-QUW4I2OI.js → chunk-CMUM4JQI.js} +3 -3
- package/dist/{chunk-QUW4I2OI.js.map → chunk-CMUM4JQI.js.map} +1 -1
- package/dist/{chunk-MNMLCLHH.cjs → chunk-EEJGUBWV.cjs} +5 -5
- package/dist/{chunk-MNMLCLHH.cjs.map → chunk-EEJGUBWV.cjs.map} +1 -1
- package/dist/{chunk-W4EUTSB2.cjs → chunk-HZ3FYBJG.cjs} +27 -12
- package/dist/chunk-HZ3FYBJG.cjs.map +1 -0
- package/dist/{chunk-L627YSSP.cjs → chunk-I6JPSD4R.cjs} +9 -9
- package/dist/{chunk-L627YSSP.cjs.map → chunk-I6JPSD4R.cjs.map} +1 -1
- package/dist/{chunk-JVICEM6W.cjs → chunk-ITYASFHQ.cjs} +91 -19
- package/dist/chunk-ITYASFHQ.cjs.map +1 -0
- package/dist/{chunk-XRKAL7WJ.cjs → chunk-JSNUWSBH.cjs} +6 -6
- package/dist/chunk-JSNUWSBH.cjs.map +1 -0
- package/dist/{chunk-GVLK7YUU.cjs → chunk-KZEC4CHV.cjs} +6 -4
- package/dist/chunk-KZEC4CHV.cjs.map +1 -0
- package/dist/{chunk-UKUYBUFQ.cjs → chunk-MN6PZ4AN.cjs} +7 -7
- package/dist/{chunk-UKUYBUFQ.cjs.map → chunk-MN6PZ4AN.cjs.map} +1 -1
- package/dist/{chunk-VXLEJWLY.js → chunk-MNBAXRVG.js} +89 -17
- package/dist/chunk-MNBAXRVG.js.map +1 -0
- package/dist/{chunk-6YIDHH2S.cjs → chunk-OFPZULMQ.cjs} +32 -10
- package/dist/chunk-OFPZULMQ.cjs.map +1 -0
- package/dist/{chunk-IKRHEUS7.js → chunk-OPTGXEVN.js} +370 -351
- package/dist/chunk-OPTGXEVN.js.map +1 -0
- package/dist/{chunk-77PLEJ54.js → chunk-QDREXAD7.js} +4 -4
- package/dist/{chunk-77PLEJ54.js.map → chunk-QDREXAD7.js.map} +1 -1
- package/dist/{chunk-RWOVNF3V.cjs → chunk-QQLP4M6W.cjs} +400 -381
- package/dist/chunk-QQLP4M6W.cjs.map +1 -0
- package/dist/{chunk-YTGF4L2C.js → chunk-RUD7KS4R.js} +27 -5
- package/dist/chunk-RUD7KS4R.js.map +1 -0
- package/dist/{chunk-USSL3D6L.js → chunk-S4OFEXLA.js} +6 -6
- package/dist/chunk-S4OFEXLA.js.map +1 -0
- package/dist/{chunk-XND7WBVX.js → chunk-VYA6QDNA.js} +43 -3
- package/dist/chunk-VYA6QDNA.js.map +1 -0
- package/dist/{chunk-KUSYIHW7.js → chunk-WYP6OOCT.js} +3 -3
- package/dist/{chunk-KUSYIHW7.js.map → chunk-WYP6OOCT.js.map} +1 -1
- package/dist/{chunk-4SCBD22Z.js → chunk-XB2GITM5.js} +4 -4
- package/dist/{chunk-4SCBD22Z.js.map → chunk-XB2GITM5.js.map} +1 -1
- package/dist/{chunk-X4RMFFMR.js → chunk-XDKK53OL.js} +6 -4
- package/dist/chunk-XDKK53OL.js.map +1 -0
- package/dist/correlation-id.cjs +10 -9
- package/dist/correlation-id.d.cts +4 -1
- package/dist/correlation-id.d.ts +4 -1
- package/dist/correlation-id.js +2 -1
- package/dist/decorators.cjs +8 -8
- package/dist/decorators.js +7 -7
- package/dist/event.cjs +10 -9
- package/dist/event.js +7 -6
- package/dist/functional.cjs +14 -14
- package/dist/functional.js +7 -7
- package/dist/http.cjs +2 -2
- package/dist/http.js +1 -1
- package/dist/index.cjs +85 -65
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +16 -16
- package/dist/{init-Q4uIQKbq.d.cts → init-CIzpC5kZ.d.cts} +9 -2
- package/dist/{init-ls4xSZe5.d.ts → init-C_PiC_Su.d.ts} +9 -2
- package/dist/instrumentation.cjs +12 -12
- package/dist/instrumentation.cjs.map +1 -1
- package/dist/instrumentation.js +4 -4
- package/dist/instrumentation.js.map +1 -1
- package/dist/messaging-adapters.d.cts +1 -1
- package/dist/messaging-adapters.d.ts +1 -1
- package/dist/messaging.cjs +11 -11
- package/dist/messaging.d.cts +1 -1
- package/dist/messaging.d.ts +1 -1
- package/dist/messaging.js +8 -8
- package/dist/metric-helpers.d.cts +1 -1
- package/dist/metric-helpers.d.ts +1 -1
- package/dist/sampling.cjs +26 -10
- package/dist/sampling.d.cts +49 -1
- package/dist/sampling.d.ts +49 -1
- package/dist/sampling.js +1 -1
- package/dist/semantic-helpers.cjs +12 -12
- package/dist/semantic-helpers.js +8 -8
- package/dist/tail-sampling-processor.cjs +6 -2
- package/dist/tail-sampling-processor.d.cts +2 -2
- package/dist/tail-sampling-processor.d.ts +2 -2
- package/dist/tail-sampling-processor.js +5 -1
- package/dist/trace-helpers.d.cts +1 -1
- package/dist/trace-helpers.d.ts +1 -1
- package/dist/{utils-D1trOLNm.d.ts → utils-Buel3cj0.d.ts} +1 -1
- package/dist/{utils-DuNJfXSH.d.cts → utils-CbUkl8r1.d.cts} +1 -1
- package/dist/webhook.cjs +8 -8
- package/dist/webhook.js +7 -7
- package/dist/workflow-distributed.cjs +9 -9
- package/dist/workflow-distributed.js +7 -7
- package/dist/workflow.cjs +12 -12
- package/dist/workflow.js +8 -8
- package/dist/yaml-config.cjs +5 -5
- package/dist/yaml-config.d.cts +5 -4
- package/dist/yaml-config.d.ts +5 -4
- package/dist/yaml-config.js +2 -2
- package/package.json +1 -1
- package/src/correlation-id.ts +10 -5
- package/src/env-config.test.ts +77 -0
- package/src/env-config.ts +106 -0
- package/src/functional.ts +447 -421
- package/src/index.ts +6 -0
- package/src/init.customization.test.ts +61 -0
- package/src/init.integrations.test.ts +6 -1
- package/src/init.ts +23 -13
- package/src/instrumentation.ts +1 -1
- package/src/sampling.test.ts +96 -3
- package/src/sampling.ts +90 -0
- package/src/tail-sampling-processor.test.ts +26 -22
- package/src/tail-sampling-processor.ts +8 -4
- package/src/trace-context.test.ts +73 -0
- package/src/trace-context.ts +44 -12
- package/src/yaml-config.test.ts +71 -0
- package/src/yaml-config.ts +32 -2
- package/dist/chunk-6YIDHH2S.cjs.map +0 -1
- package/dist/chunk-BGVKKL2N.cjs.map +0 -1
- package/dist/chunk-GVLK7YUU.cjs.map +0 -1
- package/dist/chunk-IKRHEUS7.js.map +0 -1
- package/dist/chunk-JVICEM6W.cjs.map +0 -1
- package/dist/chunk-RWOVNF3V.cjs.map +0 -1
- package/dist/chunk-SR35DG5A.js.map +0 -1
- package/dist/chunk-USSL3D6L.js.map +0 -1
- package/dist/chunk-VXLEJWLY.js.map +0 -1
- package/dist/chunk-W4EUTSB2.cjs.map +0 -1
- package/dist/chunk-X4RMFFMR.js.map +0 -1
- package/dist/chunk-XND7WBVX.js.map +0 -1
- package/dist/chunk-XRKAL7WJ.cjs.map +0 -1
- package/dist/chunk-YTGF4L2C.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkW4EUTSB2_cjs = require('./chunk-W4EUTSB2.cjs');
|
|
4
3
|
var chunkGML3FBOT_cjs = require('./chunk-GML3FBOT.cjs');
|
|
5
4
|
var chunkD5LMF53P_cjs = require('./chunk-D5LMF53P.cjs');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
5
|
+
var chunkJSNUWSBH_cjs = require('./chunk-JSNUWSBH.cjs');
|
|
6
|
+
var chunkHZ3FYBJG_cjs = require('./chunk-HZ3FYBJG.cjs');
|
|
7
|
+
var chunkITYASFHQ_cjs = require('./chunk-ITYASFHQ.cjs');
|
|
8
|
+
var chunk7FIGORWI_cjs = require('./chunk-7FIGORWI.cjs');
|
|
9
9
|
var chunkESLWRGAG_cjs = require('./chunk-ESLWRGAG.cjs');
|
|
10
10
|
var api = require('@opentelemetry/api');
|
|
11
11
|
var fs = require('fs');
|
|
@@ -222,7 +222,7 @@ var EventQueue = class {
|
|
|
222
222
|
}
|
|
223
223
|
this.metrics?.dropped.add(1, attrs);
|
|
224
224
|
const logLevel = reason === "payload_invalid" ? "error" : "warn";
|
|
225
|
-
const logger =
|
|
225
|
+
const logger = chunkITYASFHQ_cjs.getLogger();
|
|
226
226
|
if (logLevel === "error") {
|
|
227
227
|
logger.error(
|
|
228
228
|
{
|
|
@@ -254,7 +254,7 @@ var EventQueue = class {
|
|
|
254
254
|
recordFailed(event, subscriberName, error) {
|
|
255
255
|
this.metrics?.failed.add(1, { subscriber: subscriberName });
|
|
256
256
|
this.subscriberHealthy.set(subscriberName, false);
|
|
257
|
-
|
|
257
|
+
chunkITYASFHQ_cjs.getLogger().error(
|
|
258
258
|
{
|
|
259
259
|
eventName: event.name,
|
|
260
260
|
subscriber: subscriberName,
|
|
@@ -295,7 +295,7 @@ var EventQueue = class {
|
|
|
295
295
|
if (this.queue.length >= this.config.maxSize) {
|
|
296
296
|
const droppedEvent = this.queue.shift();
|
|
297
297
|
this.recordDropped("rate_limit", droppedEvent);
|
|
298
|
-
|
|
298
|
+
chunkITYASFHQ_cjs.getLogger().warn(
|
|
299
299
|
{
|
|
300
300
|
droppedEvent: droppedEvent?.name
|
|
301
301
|
},
|
|
@@ -304,7 +304,7 @@ var EventQueue = class {
|
|
|
304
304
|
}
|
|
305
305
|
const enrichedEvent = {
|
|
306
306
|
...event,
|
|
307
|
-
_correlationId: event._correlationId ||
|
|
307
|
+
_correlationId: event._correlationId || chunkJSNUWSBH_cjs.getOrCreateCorrelationId()
|
|
308
308
|
};
|
|
309
309
|
this.queue.push(enrichedEvent);
|
|
310
310
|
this.scheduleBatchFlush();
|
|
@@ -391,7 +391,7 @@ var EventQueue = class {
|
|
|
391
391
|
const failedSubscriberNames = [
|
|
392
392
|
...new Set(failedDeliveries.map((f) => f.subscriberName))
|
|
393
393
|
];
|
|
394
|
-
|
|
394
|
+
chunkITYASFHQ_cjs.getLogger().error(
|
|
395
395
|
{
|
|
396
396
|
failedSubscribers: failedSubscriberNames,
|
|
397
397
|
retriesAttempted: this.config.maxRetries
|
|
@@ -544,9 +544,9 @@ var EventQueue = class {
|
|
|
544
544
|
// src/track.ts
|
|
545
545
|
var eventsQueue = null;
|
|
546
546
|
function buildAutotelContext(span2) {
|
|
547
|
-
const eventsConfig =
|
|
548
|
-
const config =
|
|
549
|
-
const correlationId =
|
|
547
|
+
const eventsConfig = chunkITYASFHQ_cjs.getEventsConfig();
|
|
548
|
+
const config = chunkITYASFHQ_cjs.getConfig();
|
|
549
|
+
const correlationId = chunkJSNUWSBH_cjs.getOrCreateCorrelationId();
|
|
550
550
|
if (!eventsConfig?.includeTraceContext) {
|
|
551
551
|
return {
|
|
552
552
|
correlation_id: correlationId
|
|
@@ -599,12 +599,12 @@ function buildAutotelContext(span2) {
|
|
|
599
599
|
return autotelContext;
|
|
600
600
|
}
|
|
601
601
|
function getOrCreateQueue() {
|
|
602
|
-
if (!
|
|
603
|
-
|
|
602
|
+
if (!chunkITYASFHQ_cjs.isInitialized()) {
|
|
603
|
+
chunkITYASFHQ_cjs.warnIfNotInitialized("track()");
|
|
604
604
|
return null;
|
|
605
605
|
}
|
|
606
606
|
if (!eventsQueue) {
|
|
607
|
-
const config =
|
|
607
|
+
const config = chunkITYASFHQ_cjs.getConfig();
|
|
608
608
|
if (!config?.subscribers || config.subscribers.length === 0) {
|
|
609
609
|
return null;
|
|
610
610
|
}
|
|
@@ -615,7 +615,7 @@ function getOrCreateQueue() {
|
|
|
615
615
|
function track(event, data) {
|
|
616
616
|
const queue = getOrCreateQueue();
|
|
617
617
|
if (!queue) return;
|
|
618
|
-
const validationConfig =
|
|
618
|
+
const validationConfig = chunkITYASFHQ_cjs.getValidationConfig();
|
|
619
619
|
const validated = chunkD5LMF53P_cjs.validateEvent(event, data, validationConfig || void 0);
|
|
620
620
|
const span2 = api.trace.getActiveSpan();
|
|
621
621
|
const enrichedData = span2 ? {
|
|
@@ -969,7 +969,7 @@ function shouldSkip(key, fn, skip) {
|
|
|
969
969
|
function getCtxValue() {
|
|
970
970
|
const activeSpan = api.trace.getActiveSpan();
|
|
971
971
|
if (!activeSpan) return null;
|
|
972
|
-
return
|
|
972
|
+
return chunkHZ3FYBJG_cjs.createTraceContext(activeSpan);
|
|
973
973
|
}
|
|
974
974
|
var ctx = new Proxy(
|
|
975
975
|
{},
|
|
@@ -1009,7 +1009,7 @@ function wrapWithTracing(fnFactory, options, variableName) {
|
|
|
1009
1009
|
const config = chunkESLWRGAG_cjs.getConfig();
|
|
1010
1010
|
const tracer = config.tracer;
|
|
1011
1011
|
const meter = config.meter;
|
|
1012
|
-
const sampler = options.sampler || new
|
|
1012
|
+
const sampler = options.sampler || new chunk7FIGORWI_cjs.AlwaysSampler();
|
|
1013
1013
|
const tempFn = fnFactory(createDummyCtx());
|
|
1014
1014
|
const spanName = getSpanName(options, tempFn, variableName);
|
|
1015
1015
|
const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
|
|
@@ -1034,8 +1034,8 @@ function wrapWithTracing(fnFactory, options, variableName) {
|
|
|
1034
1034
|
}
|
|
1035
1035
|
const startTime = performance.now();
|
|
1036
1036
|
const isRootSpan = options.startNewRoot || api.trace.getActiveSpan() === void 0;
|
|
1037
|
-
const shouldAutoFlush = options.flushOnRootSpanEnd ??
|
|
1038
|
-
const shouldAutoFlushSpans =
|
|
1037
|
+
const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunkITYASFHQ_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
|
|
1038
|
+
const shouldAutoFlushSpans = chunkITYASFHQ_cjs.getConfig()?.forceFlushOnShutdown ?? false;
|
|
1039
1039
|
const flushIfNeeded = async () => {
|
|
1040
1040
|
if (!shouldAutoFlush || !isRootSpan) return;
|
|
1041
1041
|
try {
|
|
@@ -1044,7 +1044,7 @@ function wrapWithTracing(fnFactory, options, variableName) {
|
|
|
1044
1044
|
await queue.flush();
|
|
1045
1045
|
}
|
|
1046
1046
|
if (shouldAutoFlushSpans) {
|
|
1047
|
-
const sdk =
|
|
1047
|
+
const sdk = chunkITYASFHQ_cjs.getSdk();
|
|
1048
1048
|
if (sdk) {
|
|
1049
1049
|
try {
|
|
1050
1050
|
const sdkAny = sdk;
|
|
@@ -1059,7 +1059,7 @@ function wrapWithTracing(fnFactory, options, variableName) {
|
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
1061
|
} catch (error) {
|
|
1062
|
-
const initConfig =
|
|
1062
|
+
const initConfig = chunkITYASFHQ_cjs.getConfig();
|
|
1063
1063
|
const logger = initConfig?.logger;
|
|
1064
1064
|
if (logger?.error) {
|
|
1065
1065
|
logger.error(
|
|
@@ -1078,113 +1078,119 @@ function wrapWithTracing(fnFactory, options, variableName) {
|
|
|
1078
1078
|
if (options.spanKind !== void 0) {
|
|
1079
1079
|
spanOptions.kind = options.spanKind;
|
|
1080
1080
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1095
|
-
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1096
|
-
success,
|
|
1097
|
-
duration,
|
|
1098
|
-
error
|
|
1099
|
-
});
|
|
1100
|
-
span2.setAttribute("sampling.tail.keep", shouldKeepSpan);
|
|
1101
|
-
span2.setAttribute("sampling.tail.evaluated", true);
|
|
1081
|
+
const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
|
|
1082
|
+
return tracer.startActiveSpan(
|
|
1083
|
+
spanName,
|
|
1084
|
+
spanOptions,
|
|
1085
|
+
parentContext,
|
|
1086
|
+
async (span2) => {
|
|
1087
|
+
return chunkD5LMF53P_cjs.runInOperationContext(spanName, async () => {
|
|
1088
|
+
let shouldKeepSpan = true;
|
|
1089
|
+
chunkGML3FBOT_cjs.setSpanName(span2, spanName);
|
|
1090
|
+
const initialContext = api.context.active();
|
|
1091
|
+
const contextStorage = chunkHZ3FYBJG_cjs.getContextStorage();
|
|
1092
|
+
if (!contextStorage.getStore()) {
|
|
1093
|
+
chunkHZ3FYBJG_cjs.enterOrRun(contextStorage, initialContext);
|
|
1102
1094
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
operation: spanName,
|
|
1137
|
-
status: "error"
|
|
1138
|
-
});
|
|
1139
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1140
|
-
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1141
|
-
span2.setStatus({
|
|
1142
|
-
code: api.SpanStatusCode.ERROR,
|
|
1143
|
-
message: truncatedMessage
|
|
1144
|
-
});
|
|
1145
|
-
span2.setAttributes({
|
|
1146
|
-
...argsAttributes,
|
|
1147
|
-
"operation.name": spanName,
|
|
1148
|
-
"code.function": spanName,
|
|
1149
|
-
"operation.duration": duration,
|
|
1150
|
-
"operation.success": false,
|
|
1151
|
-
error: true,
|
|
1152
|
-
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1153
|
-
"exception.message": truncatedMessage
|
|
1154
|
-
});
|
|
1155
|
-
if (error instanceof Error && error.stack) {
|
|
1156
|
-
span2.setAttribute(
|
|
1157
|
-
"exception.stack",
|
|
1158
|
-
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1159
|
-
);
|
|
1160
|
-
}
|
|
1161
|
-
span2.recordException(
|
|
1162
|
-
error instanceof Error ? error : new Error(String(error))
|
|
1163
|
-
);
|
|
1164
|
-
handleTailSampling(false, duration, error);
|
|
1165
|
-
span2.end();
|
|
1166
|
-
await flushIfNeeded();
|
|
1167
|
-
throw error;
|
|
1168
|
-
};
|
|
1169
|
-
try {
|
|
1170
|
-
callCounter?.add(1, {
|
|
1171
|
-
operation: spanName,
|
|
1172
|
-
status: "started"
|
|
1173
|
-
});
|
|
1174
|
-
const executeWithContext = async () => {
|
|
1175
|
-
const currentContext = chunkW4EUTSB2_cjs.getActiveContextWithBaggage();
|
|
1176
|
-
return api.context.with(currentContext, async () => {
|
|
1177
|
-
return fn.call(this, ...args);
|
|
1095
|
+
const ctxValue = chunkHZ3FYBJG_cjs.createTraceContext(span2);
|
|
1096
|
+
const fn = fnFactory(ctxValue);
|
|
1097
|
+
const argsAttributes = options.attributesFromArgs ? options.attributesFromArgs(args) : {};
|
|
1098
|
+
const handleTailSampling = (success, duration, error) => {
|
|
1099
|
+
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1100
|
+
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1101
|
+
success,
|
|
1102
|
+
duration,
|
|
1103
|
+
error
|
|
1104
|
+
});
|
|
1105
|
+
span2.setAttribute(chunk7FIGORWI_cjs.AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
1106
|
+
span2.setAttribute(chunk7FIGORWI_cjs.AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
const onSuccess = async (result) => {
|
|
1110
|
+
const duration = performance.now() - startTime;
|
|
1111
|
+
callCounter?.add(1, {
|
|
1112
|
+
operation: spanName,
|
|
1113
|
+
status: "success"
|
|
1114
|
+
});
|
|
1115
|
+
durationHistogram?.record(duration, {
|
|
1116
|
+
operation: spanName,
|
|
1117
|
+
status: "success"
|
|
1118
|
+
});
|
|
1119
|
+
const resultAttributes = options.attributesFromResult ? options.attributesFromResult(result) : {};
|
|
1120
|
+
span2.setStatus({ code: api.SpanStatusCode.OK });
|
|
1121
|
+
span2.setAttributes({
|
|
1122
|
+
...argsAttributes,
|
|
1123
|
+
...resultAttributes,
|
|
1124
|
+
"operation.name": spanName,
|
|
1125
|
+
"code.function": spanName,
|
|
1126
|
+
"operation.duration": duration,
|
|
1127
|
+
"operation.success": true
|
|
1178
1128
|
});
|
|
1129
|
+
handleTailSampling(true, duration);
|
|
1130
|
+
span2.end();
|
|
1131
|
+
await flushIfNeeded();
|
|
1132
|
+
return result;
|
|
1179
1133
|
};
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1134
|
+
const onError = async (error) => {
|
|
1135
|
+
const duration = performance.now() - startTime;
|
|
1136
|
+
callCounter?.add(1, {
|
|
1137
|
+
operation: spanName,
|
|
1138
|
+
status: "error"
|
|
1139
|
+
});
|
|
1140
|
+
durationHistogram?.record(duration, {
|
|
1141
|
+
operation: spanName,
|
|
1142
|
+
status: "error"
|
|
1143
|
+
});
|
|
1144
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1145
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1146
|
+
span2.setStatus({
|
|
1147
|
+
code: api.SpanStatusCode.ERROR,
|
|
1148
|
+
message: truncatedMessage
|
|
1149
|
+
});
|
|
1150
|
+
span2.setAttributes({
|
|
1151
|
+
...argsAttributes,
|
|
1152
|
+
"operation.name": spanName,
|
|
1153
|
+
"code.function": spanName,
|
|
1154
|
+
"operation.duration": duration,
|
|
1155
|
+
"operation.success": false,
|
|
1156
|
+
error: true,
|
|
1157
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1158
|
+
"exception.message": truncatedMessage
|
|
1159
|
+
});
|
|
1160
|
+
if (error instanceof Error && error.stack) {
|
|
1161
|
+
span2.setAttribute(
|
|
1162
|
+
"exception.stack",
|
|
1163
|
+
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
span2.recordException(
|
|
1167
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1168
|
+
);
|
|
1169
|
+
handleTailSampling(false, duration, error);
|
|
1170
|
+
span2.end();
|
|
1171
|
+
await flushIfNeeded();
|
|
1172
|
+
throw error;
|
|
1173
|
+
};
|
|
1174
|
+
try {
|
|
1175
|
+
callCounter?.add(1, {
|
|
1176
|
+
operation: spanName,
|
|
1177
|
+
status: "started"
|
|
1178
|
+
});
|
|
1179
|
+
const executeWithContext = async () => {
|
|
1180
|
+
const currentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
|
|
1181
|
+
return api.context.with(currentContext, async () => {
|
|
1182
|
+
return fn.call(this, ...args);
|
|
1183
|
+
});
|
|
1184
|
+
};
|
|
1185
|
+
const result = await executeWithContext();
|
|
1186
|
+
return await onSuccess(result);
|
|
1187
|
+
} catch (error) {
|
|
1188
|
+
await onError(error);
|
|
1189
|
+
throw error;
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
);
|
|
1188
1194
|
};
|
|
1189
1195
|
wrappedFunction[INSTRUMENTED_SYMBOL] = true;
|
|
1190
1196
|
Object.defineProperty(wrappedFunction, "name", {
|
|
@@ -1198,7 +1204,7 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
|
|
|
1198
1204
|
const config = chunkESLWRGAG_cjs.getConfig();
|
|
1199
1205
|
const tracer = config.tracer;
|
|
1200
1206
|
const meter = config.meter;
|
|
1201
|
-
const sampler = options.sampler || new
|
|
1207
|
+
const sampler = options.sampler || new chunk7FIGORWI_cjs.AlwaysSampler();
|
|
1202
1208
|
const tempFn = fnFactory(createDummyCtx());
|
|
1203
1209
|
const spanName = getSpanName(options, tempFn, variableName);
|
|
1204
1210
|
const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
|
|
@@ -1223,14 +1229,14 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
|
|
|
1223
1229
|
}
|
|
1224
1230
|
const startTime = performance.now();
|
|
1225
1231
|
const isRootSpan = options.startNewRoot || api.trace.getActiveSpan() === void 0;
|
|
1226
|
-
const shouldAutoFlush = options.flushOnRootSpanEnd ??
|
|
1227
|
-
const shouldAutoFlushSpans =
|
|
1232
|
+
const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunkITYASFHQ_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
|
|
1233
|
+
const shouldAutoFlushSpans = chunkITYASFHQ_cjs.getConfig()?.forceFlushOnShutdown ?? false;
|
|
1228
1234
|
const flushIfNeeded = () => {
|
|
1229
1235
|
if (!shouldAutoFlush || !isRootSpan) return;
|
|
1230
1236
|
const queue = getEventQueue();
|
|
1231
1237
|
if (queue && queue.size() > 0) {
|
|
1232
1238
|
void queue.flush().catch((error) => {
|
|
1233
|
-
const initConfig =
|
|
1239
|
+
const initConfig = chunkITYASFHQ_cjs.getConfig();
|
|
1234
1240
|
const logger = initConfig?.logger;
|
|
1235
1241
|
if (logger?.error) {
|
|
1236
1242
|
logger.error(
|
|
@@ -1243,7 +1249,7 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
|
|
|
1243
1249
|
});
|
|
1244
1250
|
}
|
|
1245
1251
|
if (shouldAutoFlushSpans) {
|
|
1246
|
-
const sdk =
|
|
1252
|
+
const sdk = chunkITYASFHQ_cjs.getSdk();
|
|
1247
1253
|
if (sdk) {
|
|
1248
1254
|
try {
|
|
1249
1255
|
const sdkAny = sdk;
|
|
@@ -1251,7 +1257,7 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
|
|
|
1251
1257
|
const tracerProvider = sdkAny.getTracerProvider();
|
|
1252
1258
|
if (tracerProvider && typeof tracerProvider.forceFlush === "function") {
|
|
1253
1259
|
void tracerProvider.forceFlush().catch((error) => {
|
|
1254
|
-
const initConfig =
|
|
1260
|
+
const initConfig = chunkITYASFHQ_cjs.getConfig();
|
|
1255
1261
|
const logger = initConfig?.logger;
|
|
1256
1262
|
if (logger?.error) {
|
|
1257
1263
|
logger.error(
|
|
@@ -1276,98 +1282,104 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
|
|
|
1276
1282
|
if (options.spanKind !== void 0) {
|
|
1277
1283
|
spanOptions.kind = options.spanKind;
|
|
1278
1284
|
}
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1285
|
+
const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
|
|
1286
|
+
return tracer.startActiveSpan(
|
|
1287
|
+
spanName,
|
|
1288
|
+
spanOptions,
|
|
1289
|
+
parentContext,
|
|
1290
|
+
(span2) => {
|
|
1291
|
+
return chunkD5LMF53P_cjs.runInOperationContext(spanName, () => {
|
|
1292
|
+
let shouldKeepSpan = true;
|
|
1293
|
+
chunkGML3FBOT_cjs.setSpanName(span2, spanName);
|
|
1294
|
+
const ctxValue = chunkHZ3FYBJG_cjs.createTraceContext(span2);
|
|
1295
|
+
const fn = fnFactory(ctxValue);
|
|
1296
|
+
const argsAttributes = options.attributesFromArgs ? options.attributesFromArgs(args) : {};
|
|
1297
|
+
const handleTailSampling = (success, duration, error) => {
|
|
1298
|
+
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1299
|
+
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1300
|
+
success,
|
|
1301
|
+
duration,
|
|
1302
|
+
error
|
|
1303
|
+
});
|
|
1304
|
+
span2.setAttribute(chunk7FIGORWI_cjs.AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
1305
|
+
span2.setAttribute(chunk7FIGORWI_cjs.AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
const onSuccess = (result) => {
|
|
1309
|
+
const duration = performance.now() - startTime;
|
|
1310
|
+
callCounter?.add(1, {
|
|
1311
|
+
operation: spanName,
|
|
1312
|
+
status: "success"
|
|
1292
1313
|
});
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
error
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
operation: spanName,
|
|
1359
|
-
status: "started"
|
|
1360
|
-
});
|
|
1361
|
-
const result = fn.call(this, ...args);
|
|
1362
|
-
if (result instanceof Promise) {
|
|
1363
|
-
return result.then(onSuccess, onError);
|
|
1314
|
+
durationHistogram?.record(duration, {
|
|
1315
|
+
operation: spanName,
|
|
1316
|
+
status: "success"
|
|
1317
|
+
});
|
|
1318
|
+
const resultAttributes = options.attributesFromResult ? options.attributesFromResult(result) : {};
|
|
1319
|
+
span2.setStatus({ code: api.SpanStatusCode.OK });
|
|
1320
|
+
span2.setAttributes({
|
|
1321
|
+
...argsAttributes,
|
|
1322
|
+
...resultAttributes,
|
|
1323
|
+
"operation.name": spanName,
|
|
1324
|
+
"code.function": spanName,
|
|
1325
|
+
"operation.duration": duration,
|
|
1326
|
+
"operation.success": true
|
|
1327
|
+
});
|
|
1328
|
+
handleTailSampling(true, duration);
|
|
1329
|
+
span2.end();
|
|
1330
|
+
void flushIfNeeded();
|
|
1331
|
+
return result;
|
|
1332
|
+
};
|
|
1333
|
+
const onError = (error) => {
|
|
1334
|
+
const duration = performance.now() - startTime;
|
|
1335
|
+
callCounter?.add(1, {
|
|
1336
|
+
operation: spanName,
|
|
1337
|
+
status: "error"
|
|
1338
|
+
});
|
|
1339
|
+
durationHistogram?.record(duration, {
|
|
1340
|
+
operation: spanName,
|
|
1341
|
+
status: "error"
|
|
1342
|
+
});
|
|
1343
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1344
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1345
|
+
span2.setStatus({
|
|
1346
|
+
code: api.SpanStatusCode.ERROR,
|
|
1347
|
+
message: truncatedMessage
|
|
1348
|
+
});
|
|
1349
|
+
span2.setAttributes({
|
|
1350
|
+
...argsAttributes,
|
|
1351
|
+
"operation.name": spanName,
|
|
1352
|
+
"code.function": spanName,
|
|
1353
|
+
"operation.duration": duration,
|
|
1354
|
+
"operation.success": false,
|
|
1355
|
+
error: true,
|
|
1356
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1357
|
+
"exception.message": truncatedMessage
|
|
1358
|
+
});
|
|
1359
|
+
span2.recordException(
|
|
1360
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1361
|
+
);
|
|
1362
|
+
handleTailSampling(false, duration, error);
|
|
1363
|
+
span2.end();
|
|
1364
|
+
void flushIfNeeded();
|
|
1365
|
+
throw error;
|
|
1366
|
+
};
|
|
1367
|
+
try {
|
|
1368
|
+
callCounter?.add(1, {
|
|
1369
|
+
operation: spanName,
|
|
1370
|
+
status: "started"
|
|
1371
|
+
});
|
|
1372
|
+
const result = fn.call(this, ...args);
|
|
1373
|
+
if (result instanceof Promise) {
|
|
1374
|
+
return result.then(onSuccess, onError);
|
|
1375
|
+
}
|
|
1376
|
+
return onSuccess(result);
|
|
1377
|
+
} catch (error) {
|
|
1378
|
+
return onError(error);
|
|
1364
1379
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1369
|
-
});
|
|
1370
|
-
});
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
);
|
|
1371
1383
|
}
|
|
1372
1384
|
wrappedFunction[INSTRUMENTED_SYMBOL] = true;
|
|
1373
1385
|
Object.defineProperty(wrappedFunction, "name", {
|
|
@@ -1380,7 +1392,7 @@ function executeImmediately(fn, options) {
|
|
|
1380
1392
|
const config = chunkESLWRGAG_cjs.getConfig();
|
|
1381
1393
|
const tracer = config.tracer;
|
|
1382
1394
|
const meter = config.meter;
|
|
1383
|
-
const sampler = options.sampler || new
|
|
1395
|
+
const sampler = options.sampler || new chunk7FIGORWI_cjs.AlwaysSampler();
|
|
1384
1396
|
const spanName = options.name || "anonymous";
|
|
1385
1397
|
const samplingContext = {
|
|
1386
1398
|
operationName: spanName,
|
|
@@ -1394,8 +1406,8 @@ function executeImmediately(fn, options) {
|
|
|
1394
1406
|
}
|
|
1395
1407
|
const startTime = performance.now();
|
|
1396
1408
|
const isRootSpan = options.startNewRoot || api.trace.getActiveSpan() === void 0;
|
|
1397
|
-
const shouldAutoFlush = options.flushOnRootSpanEnd ??
|
|
1398
|
-
const shouldAutoFlushSpans =
|
|
1409
|
+
const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunkITYASFHQ_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
|
|
1410
|
+
const shouldAutoFlushSpans = chunkITYASFHQ_cjs.getConfig()?.forceFlushOnShutdown ?? false;
|
|
1399
1411
|
const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
|
|
1400
1412
|
description: `Call count for ${spanName}`,
|
|
1401
1413
|
unit: "1"
|
|
@@ -1412,7 +1424,7 @@ function executeImmediately(fn, options) {
|
|
|
1412
1424
|
await queue.flush();
|
|
1413
1425
|
}
|
|
1414
1426
|
if (shouldAutoFlushSpans) {
|
|
1415
|
-
const sdk =
|
|
1427
|
+
const sdk = chunkITYASFHQ_cjs.getSdk();
|
|
1416
1428
|
if (sdk) {
|
|
1417
1429
|
try {
|
|
1418
1430
|
const sdkAny = sdk;
|
|
@@ -1427,7 +1439,7 @@ function executeImmediately(fn, options) {
|
|
|
1427
1439
|
}
|
|
1428
1440
|
}
|
|
1429
1441
|
} catch (error) {
|
|
1430
|
-
const initConfig =
|
|
1442
|
+
const initConfig = chunkITYASFHQ_cjs.getConfig();
|
|
1431
1443
|
const logger = initConfig?.logger;
|
|
1432
1444
|
if (logger?.error) {
|
|
1433
1445
|
logger.error(
|
|
@@ -1446,159 +1458,165 @@ function executeImmediately(fn, options) {
|
|
|
1446
1458
|
if (options.spanKind !== void 0) {
|
|
1447
1459
|
spanOptions.kind = options.spanKind;
|
|
1448
1460
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1461
|
+
const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
|
|
1462
|
+
return tracer.startActiveSpan(
|
|
1463
|
+
spanName,
|
|
1464
|
+
spanOptions,
|
|
1465
|
+
parentContext,
|
|
1466
|
+
(span2) => {
|
|
1467
|
+
return chunkD5LMF53P_cjs.runInOperationContext(spanName, () => {
|
|
1468
|
+
let shouldKeepSpan = true;
|
|
1469
|
+
chunkGML3FBOT_cjs.setSpanName(span2, spanName);
|
|
1470
|
+
const ctxValue = chunkHZ3FYBJG_cjs.createTraceContext(span2);
|
|
1471
|
+
const handleTailSampling = (success, duration, error) => {
|
|
1472
|
+
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1473
|
+
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1474
|
+
success,
|
|
1475
|
+
duration,
|
|
1476
|
+
error
|
|
1477
|
+
});
|
|
1478
|
+
span2.setAttribute(chunk7FIGORWI_cjs.AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
1479
|
+
span2.setAttribute(chunk7FIGORWI_cjs.AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
const onSuccessSync = (result) => {
|
|
1483
|
+
const duration = performance.now() - startTime;
|
|
1484
|
+
callCounter?.add(1, {
|
|
1485
|
+
operation: spanName,
|
|
1486
|
+
status: "success"
|
|
1460
1487
|
});
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
"exception.message": truncatedMessage
|
|
1511
|
-
});
|
|
1512
|
-
if (error instanceof Error && error.stack) {
|
|
1513
|
-
span2.setAttribute(
|
|
1514
|
-
"exception.stack",
|
|
1515
|
-
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1488
|
+
durationHistogram?.record(duration, {
|
|
1489
|
+
operation: spanName,
|
|
1490
|
+
status: "success"
|
|
1491
|
+
});
|
|
1492
|
+
span2.setStatus({ code: api.SpanStatusCode.OK });
|
|
1493
|
+
span2.setAttributes({
|
|
1494
|
+
"operation.name": spanName,
|
|
1495
|
+
"code.function": spanName,
|
|
1496
|
+
"operation.duration": duration,
|
|
1497
|
+
"operation.success": true
|
|
1498
|
+
});
|
|
1499
|
+
handleTailSampling(true, duration);
|
|
1500
|
+
span2.end();
|
|
1501
|
+
void flushIfNeeded();
|
|
1502
|
+
return result;
|
|
1503
|
+
};
|
|
1504
|
+
const onErrorSync = (error) => {
|
|
1505
|
+
const duration = performance.now() - startTime;
|
|
1506
|
+
callCounter?.add(1, {
|
|
1507
|
+
operation: spanName,
|
|
1508
|
+
status: "error"
|
|
1509
|
+
});
|
|
1510
|
+
durationHistogram?.record(duration, {
|
|
1511
|
+
operation: spanName,
|
|
1512
|
+
status: "error"
|
|
1513
|
+
});
|
|
1514
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1515
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1516
|
+
span2.setStatus({
|
|
1517
|
+
code: api.SpanStatusCode.ERROR,
|
|
1518
|
+
message: truncatedMessage
|
|
1519
|
+
});
|
|
1520
|
+
span2.setAttributes({
|
|
1521
|
+
"operation.name": spanName,
|
|
1522
|
+
"code.function": spanName,
|
|
1523
|
+
"operation.duration": duration,
|
|
1524
|
+
"operation.success": false,
|
|
1525
|
+
error: true,
|
|
1526
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1527
|
+
"exception.message": truncatedMessage
|
|
1528
|
+
});
|
|
1529
|
+
if (error instanceof Error && error.stack) {
|
|
1530
|
+
span2.setAttribute(
|
|
1531
|
+
"exception.stack",
|
|
1532
|
+
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1533
|
+
);
|
|
1534
|
+
}
|
|
1535
|
+
span2.recordException(
|
|
1536
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1516
1537
|
);
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
error
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
error
|
|
1538
|
+
handleTailSampling(false, duration, error);
|
|
1539
|
+
span2.end();
|
|
1540
|
+
void flushIfNeeded();
|
|
1541
|
+
throw error;
|
|
1542
|
+
};
|
|
1543
|
+
const onSuccessAsync = async (result) => {
|
|
1544
|
+
const duration = performance.now() - startTime;
|
|
1545
|
+
callCounter?.add(1, {
|
|
1546
|
+
operation: spanName,
|
|
1547
|
+
status: "success"
|
|
1548
|
+
});
|
|
1549
|
+
durationHistogram?.record(duration, {
|
|
1550
|
+
operation: spanName,
|
|
1551
|
+
status: "success"
|
|
1552
|
+
});
|
|
1553
|
+
span2.setStatus({ code: api.SpanStatusCode.OK });
|
|
1554
|
+
span2.setAttributes({
|
|
1555
|
+
"operation.name": spanName,
|
|
1556
|
+
"code.function": spanName,
|
|
1557
|
+
"operation.duration": duration,
|
|
1558
|
+
"operation.success": true
|
|
1559
|
+
});
|
|
1560
|
+
handleTailSampling(true, duration);
|
|
1561
|
+
span2.end();
|
|
1562
|
+
await flushIfNeeded();
|
|
1563
|
+
return result;
|
|
1564
|
+
};
|
|
1565
|
+
const onErrorAsync = async (error) => {
|
|
1566
|
+
const duration = performance.now() - startTime;
|
|
1567
|
+
callCounter?.add(1, {
|
|
1568
|
+
operation: spanName,
|
|
1569
|
+
status: "error"
|
|
1570
|
+
});
|
|
1571
|
+
durationHistogram?.record(duration, {
|
|
1572
|
+
operation: spanName,
|
|
1573
|
+
status: "error"
|
|
1574
|
+
});
|
|
1575
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1576
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1577
|
+
span2.setStatus({
|
|
1578
|
+
code: api.SpanStatusCode.ERROR,
|
|
1579
|
+
message: truncatedMessage
|
|
1580
|
+
});
|
|
1581
|
+
span2.setAttributes({
|
|
1582
|
+
"operation.name": spanName,
|
|
1583
|
+
"code.function": spanName,
|
|
1584
|
+
"operation.duration": duration,
|
|
1585
|
+
"operation.success": false,
|
|
1586
|
+
error: true,
|
|
1587
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1588
|
+
"exception.message": truncatedMessage
|
|
1589
|
+
});
|
|
1590
|
+
if (error instanceof Error && error.stack) {
|
|
1591
|
+
span2.setAttribute(
|
|
1592
|
+
"exception.stack",
|
|
1593
|
+
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1596
|
+
span2.recordException(
|
|
1597
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1577
1598
|
);
|
|
1599
|
+
handleTailSampling(false, duration, error);
|
|
1600
|
+
span2.end();
|
|
1601
|
+
await flushIfNeeded();
|
|
1602
|
+
throw error;
|
|
1603
|
+
};
|
|
1604
|
+
try {
|
|
1605
|
+
callCounter?.add(1, {
|
|
1606
|
+
operation: spanName,
|
|
1607
|
+
status: "started"
|
|
1608
|
+
});
|
|
1609
|
+
const result = fn(ctxValue);
|
|
1610
|
+
if (result instanceof Promise) {
|
|
1611
|
+
return result.then(onSuccessAsync, onErrorAsync);
|
|
1612
|
+
}
|
|
1613
|
+
return onSuccessSync(result);
|
|
1614
|
+
} catch (error) {
|
|
1615
|
+
return onErrorSync(error);
|
|
1578
1616
|
}
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
handleTailSampling(false, duration, error);
|
|
1583
|
-
span2.end();
|
|
1584
|
-
await flushIfNeeded();
|
|
1585
|
-
throw error;
|
|
1586
|
-
};
|
|
1587
|
-
try {
|
|
1588
|
-
callCounter?.add(1, {
|
|
1589
|
-
operation: spanName,
|
|
1590
|
-
status: "started"
|
|
1591
|
-
});
|
|
1592
|
-
const result = fn(ctxValue);
|
|
1593
|
-
if (result instanceof Promise) {
|
|
1594
|
-
return result.then(onSuccessAsync, onErrorAsync);
|
|
1595
|
-
}
|
|
1596
|
-
return onSuccessSync(result);
|
|
1597
|
-
} catch (error) {
|
|
1598
|
-
return onErrorSync(error);
|
|
1599
|
-
}
|
|
1600
|
-
});
|
|
1601
|
-
});
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
);
|
|
1602
1620
|
}
|
|
1603
1621
|
function trace2(fnOrNameOrOptions, maybeFn) {
|
|
1604
1622
|
if (typeof fnOrNameOrOptions === "function") {
|
|
@@ -1730,7 +1748,8 @@ function span(options, fn) {
|
|
|
1730
1748
|
}
|
|
1731
1749
|
});
|
|
1732
1750
|
};
|
|
1733
|
-
const
|
|
1751
|
+
const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
|
|
1752
|
+
const result = tracer.startActiveSpan(name, {}, parentContext, executeSpan);
|
|
1734
1753
|
if (result instanceof Promise) {
|
|
1735
1754
|
return result;
|
|
1736
1755
|
}
|
|
@@ -1764,9 +1783,9 @@ function withBaggage(options) {
|
|
|
1764
1783
|
updatedBaggage = updatedBaggage.setEntry(key, { value });
|
|
1765
1784
|
}
|
|
1766
1785
|
const newContext = api.propagation.setBaggage(currentContext, updatedBaggage);
|
|
1767
|
-
const ctxStorage =
|
|
1786
|
+
const ctxStorage = chunkHZ3FYBJG_cjs.getContextStorage();
|
|
1768
1787
|
const previousStored = ctxStorage.getStore();
|
|
1769
|
-
const baggageEnrichedStored = previousStored ? api.propagation.setBaggage(previousStored, updatedBaggage) : newContext;
|
|
1788
|
+
const baggageEnrichedStored = previousStored ? { value: api.propagation.setBaggage(previousStored.value, updatedBaggage) } : { value: newContext };
|
|
1770
1789
|
const result = previousStored ? ctxStorage.run(baggageEnrichedStored, () => api.context.with(newContext, fn)) : api.context.with(newContext, fn);
|
|
1771
1790
|
if (result instanceof Promise) {
|
|
1772
1791
|
return result.then(
|
|
@@ -1799,5 +1818,5 @@ exports.track = track;
|
|
|
1799
1818
|
exports.withBaggage = withBaggage;
|
|
1800
1819
|
exports.withNewContext = withNewContext;
|
|
1801
1820
|
exports.withTracing = withTracing;
|
|
1802
|
-
//# sourceMappingURL=chunk-
|
|
1803
|
-
//# sourceMappingURL=chunk-
|
|
1821
|
+
//# sourceMappingURL=chunk-QQLP4M6W.cjs.map
|
|
1822
|
+
//# sourceMappingURL=chunk-QQLP4M6W.cjs.map
|