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,9 +1,9 @@
|
|
|
1
|
-
import { createTraceContext, getContextStorage, getActiveContextWithBaggage } from './chunk-SR35DG5A.js';
|
|
2
1
|
import { setSpanName } from './chunk-B3ZHLLMP.js';
|
|
3
2
|
import { validateEvent, runInOperationContext } from './chunk-WD4RP6IV.js';
|
|
4
|
-
import { getOrCreateCorrelationId } from './chunk-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { getOrCreateCorrelationId } from './chunk-S4OFEXLA.js';
|
|
4
|
+
import { createTraceContext, getActiveContextWithBaggage, getContextStorage, enterOrRun } from './chunk-BBBWDIYQ.js';
|
|
5
|
+
import { getValidationConfig, isInitialized, warnIfNotInitialized, getConfig as getConfig$1, getEventsConfig, getLogger, getSdk } from './chunk-MNBAXRVG.js';
|
|
6
|
+
import { AlwaysSampler, AUTOTEL_SAMPLING_TAIL_KEEP, AUTOTEL_SAMPLING_TAIL_EVALUATED } from './chunk-VYA6QDNA.js';
|
|
7
7
|
import { getConfig } from './chunk-J5QENANM.js';
|
|
8
8
|
import { trace, SpanStatusCode, context, propagation } from '@opentelemetry/api';
|
|
9
9
|
import { readFileSync } from 'fs';
|
|
@@ -1076,113 +1076,119 @@ function wrapWithTracing(fnFactory, options, variableName) {
|
|
|
1076
1076
|
if (options.spanKind !== void 0) {
|
|
1077
1077
|
spanOptions.kind = options.spanKind;
|
|
1078
1078
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1093
|
-
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1094
|
-
success,
|
|
1095
|
-
duration,
|
|
1096
|
-
error
|
|
1097
|
-
});
|
|
1098
|
-
span2.setAttribute("sampling.tail.keep", shouldKeepSpan);
|
|
1099
|
-
span2.setAttribute("sampling.tail.evaluated", true);
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
1102
|
-
const onSuccess = async (result) => {
|
|
1103
|
-
const duration = performance.now() - startTime;
|
|
1104
|
-
callCounter?.add(1, {
|
|
1105
|
-
operation: spanName,
|
|
1106
|
-
status: "success"
|
|
1107
|
-
});
|
|
1108
|
-
durationHistogram?.record(duration, {
|
|
1109
|
-
operation: spanName,
|
|
1110
|
-
status: "success"
|
|
1111
|
-
});
|
|
1112
|
-
const resultAttributes = options.attributesFromResult ? options.attributesFromResult(result) : {};
|
|
1113
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1114
|
-
span2.setAttributes({
|
|
1115
|
-
...argsAttributes,
|
|
1116
|
-
...resultAttributes,
|
|
1117
|
-
"operation.name": spanName,
|
|
1118
|
-
"code.function": spanName,
|
|
1119
|
-
"operation.duration": duration,
|
|
1120
|
-
"operation.success": true
|
|
1121
|
-
});
|
|
1122
|
-
handleTailSampling(true, duration);
|
|
1123
|
-
span2.end();
|
|
1124
|
-
await flushIfNeeded();
|
|
1125
|
-
return result;
|
|
1126
|
-
};
|
|
1127
|
-
const onError = async (error) => {
|
|
1128
|
-
const duration = performance.now() - startTime;
|
|
1129
|
-
callCounter?.add(1, {
|
|
1130
|
-
operation: spanName,
|
|
1131
|
-
status: "error"
|
|
1132
|
-
});
|
|
1133
|
-
durationHistogram?.record(duration, {
|
|
1134
|
-
operation: spanName,
|
|
1135
|
-
status: "error"
|
|
1136
|
-
});
|
|
1137
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1138
|
-
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1139
|
-
span2.setStatus({
|
|
1140
|
-
code: SpanStatusCode.ERROR,
|
|
1141
|
-
message: truncatedMessage
|
|
1142
|
-
});
|
|
1143
|
-
span2.setAttributes({
|
|
1144
|
-
...argsAttributes,
|
|
1145
|
-
"operation.name": spanName,
|
|
1146
|
-
"code.function": spanName,
|
|
1147
|
-
"operation.duration": duration,
|
|
1148
|
-
"operation.success": false,
|
|
1149
|
-
error: true,
|
|
1150
|
-
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1151
|
-
"exception.message": truncatedMessage
|
|
1152
|
-
});
|
|
1153
|
-
if (error instanceof Error && error.stack) {
|
|
1154
|
-
span2.setAttribute(
|
|
1155
|
-
"exception.stack",
|
|
1156
|
-
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1157
|
-
);
|
|
1079
|
+
const parentContext = getActiveContextWithBaggage();
|
|
1080
|
+
return tracer.startActiveSpan(
|
|
1081
|
+
spanName,
|
|
1082
|
+
spanOptions,
|
|
1083
|
+
parentContext,
|
|
1084
|
+
async (span2) => {
|
|
1085
|
+
return runInOperationContext(spanName, async () => {
|
|
1086
|
+
let shouldKeepSpan = true;
|
|
1087
|
+
setSpanName(span2, spanName);
|
|
1088
|
+
const initialContext = context.active();
|
|
1089
|
+
const contextStorage = getContextStorage();
|
|
1090
|
+
if (!contextStorage.getStore()) {
|
|
1091
|
+
enterOrRun(contextStorage, initialContext);
|
|
1158
1092
|
}
|
|
1159
|
-
span2
|
|
1160
|
-
|
|
1161
|
-
);
|
|
1162
|
-
handleTailSampling(
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1093
|
+
const ctxValue = createTraceContext(span2);
|
|
1094
|
+
const fn = fnFactory(ctxValue);
|
|
1095
|
+
const argsAttributes = options.attributesFromArgs ? options.attributesFromArgs(args) : {};
|
|
1096
|
+
const handleTailSampling = (success, duration, error) => {
|
|
1097
|
+
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1098
|
+
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1099
|
+
success,
|
|
1100
|
+
duration,
|
|
1101
|
+
error
|
|
1102
|
+
});
|
|
1103
|
+
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
1104
|
+
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
const onSuccess = async (result) => {
|
|
1108
|
+
const duration = performance.now() - startTime;
|
|
1109
|
+
callCounter?.add(1, {
|
|
1110
|
+
operation: spanName,
|
|
1111
|
+
status: "success"
|
|
1112
|
+
});
|
|
1113
|
+
durationHistogram?.record(duration, {
|
|
1114
|
+
operation: spanName,
|
|
1115
|
+
status: "success"
|
|
1116
|
+
});
|
|
1117
|
+
const resultAttributes = options.attributesFromResult ? options.attributesFromResult(result) : {};
|
|
1118
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1119
|
+
span2.setAttributes({
|
|
1120
|
+
...argsAttributes,
|
|
1121
|
+
...resultAttributes,
|
|
1122
|
+
"operation.name": spanName,
|
|
1123
|
+
"code.function": spanName,
|
|
1124
|
+
"operation.duration": duration,
|
|
1125
|
+
"operation.success": true
|
|
1176
1126
|
});
|
|
1127
|
+
handleTailSampling(true, duration);
|
|
1128
|
+
span2.end();
|
|
1129
|
+
await flushIfNeeded();
|
|
1130
|
+
return result;
|
|
1177
1131
|
};
|
|
1178
|
-
const
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1132
|
+
const onError = async (error) => {
|
|
1133
|
+
const duration = performance.now() - startTime;
|
|
1134
|
+
callCounter?.add(1, {
|
|
1135
|
+
operation: spanName,
|
|
1136
|
+
status: "error"
|
|
1137
|
+
});
|
|
1138
|
+
durationHistogram?.record(duration, {
|
|
1139
|
+
operation: spanName,
|
|
1140
|
+
status: "error"
|
|
1141
|
+
});
|
|
1142
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1143
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1144
|
+
span2.setStatus({
|
|
1145
|
+
code: SpanStatusCode.ERROR,
|
|
1146
|
+
message: truncatedMessage
|
|
1147
|
+
});
|
|
1148
|
+
span2.setAttributes({
|
|
1149
|
+
...argsAttributes,
|
|
1150
|
+
"operation.name": spanName,
|
|
1151
|
+
"code.function": spanName,
|
|
1152
|
+
"operation.duration": duration,
|
|
1153
|
+
"operation.success": false,
|
|
1154
|
+
error: true,
|
|
1155
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1156
|
+
"exception.message": truncatedMessage
|
|
1157
|
+
});
|
|
1158
|
+
if (error instanceof Error && error.stack) {
|
|
1159
|
+
span2.setAttribute(
|
|
1160
|
+
"exception.stack",
|
|
1161
|
+
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
span2.recordException(
|
|
1165
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1166
|
+
);
|
|
1167
|
+
handleTailSampling(false, duration, error);
|
|
1168
|
+
span2.end();
|
|
1169
|
+
await flushIfNeeded();
|
|
1170
|
+
throw error;
|
|
1171
|
+
};
|
|
1172
|
+
try {
|
|
1173
|
+
callCounter?.add(1, {
|
|
1174
|
+
operation: spanName,
|
|
1175
|
+
status: "started"
|
|
1176
|
+
});
|
|
1177
|
+
const executeWithContext = async () => {
|
|
1178
|
+
const currentContext = getActiveContextWithBaggage();
|
|
1179
|
+
return context.with(currentContext, async () => {
|
|
1180
|
+
return fn.call(this, ...args);
|
|
1181
|
+
});
|
|
1182
|
+
};
|
|
1183
|
+
const result = await executeWithContext();
|
|
1184
|
+
return await onSuccess(result);
|
|
1185
|
+
} catch (error) {
|
|
1186
|
+
await onError(error);
|
|
1187
|
+
throw error;
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
);
|
|
1186
1192
|
};
|
|
1187
1193
|
wrappedFunction[INSTRUMENTED_SYMBOL] = true;
|
|
1188
1194
|
Object.defineProperty(wrappedFunction, "name", {
|
|
@@ -1274,98 +1280,104 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
|
|
|
1274
1280
|
if (options.spanKind !== void 0) {
|
|
1275
1281
|
spanOptions.kind = options.spanKind;
|
|
1276
1282
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1283
|
+
const parentContext = getActiveContextWithBaggage();
|
|
1284
|
+
return tracer.startActiveSpan(
|
|
1285
|
+
spanName,
|
|
1286
|
+
spanOptions,
|
|
1287
|
+
parentContext,
|
|
1288
|
+
(span2) => {
|
|
1289
|
+
return runInOperationContext(spanName, () => {
|
|
1290
|
+
let shouldKeepSpan = true;
|
|
1291
|
+
setSpanName(span2, spanName);
|
|
1292
|
+
const ctxValue = createTraceContext(span2);
|
|
1293
|
+
const fn = fnFactory(ctxValue);
|
|
1294
|
+
const argsAttributes = options.attributesFromArgs ? options.attributesFromArgs(args) : {};
|
|
1295
|
+
const handleTailSampling = (success, duration, error) => {
|
|
1296
|
+
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1297
|
+
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1298
|
+
success,
|
|
1299
|
+
duration,
|
|
1300
|
+
error
|
|
1301
|
+
});
|
|
1302
|
+
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
1303
|
+
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1306
|
+
const onSuccess = (result) => {
|
|
1307
|
+
const duration = performance.now() - startTime;
|
|
1308
|
+
callCounter?.add(1, {
|
|
1309
|
+
operation: spanName,
|
|
1310
|
+
status: "success"
|
|
1290
1311
|
});
|
|
1291
|
-
|
|
1292
|
-
|
|
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
|
-
error
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
operation: spanName,
|
|
1357
|
-
status: "started"
|
|
1358
|
-
});
|
|
1359
|
-
const result = fn.call(this, ...args);
|
|
1360
|
-
if (result instanceof Promise) {
|
|
1361
|
-
return result.then(onSuccess, onError);
|
|
1312
|
+
durationHistogram?.record(duration, {
|
|
1313
|
+
operation: spanName,
|
|
1314
|
+
status: "success"
|
|
1315
|
+
});
|
|
1316
|
+
const resultAttributes = options.attributesFromResult ? options.attributesFromResult(result) : {};
|
|
1317
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1318
|
+
span2.setAttributes({
|
|
1319
|
+
...argsAttributes,
|
|
1320
|
+
...resultAttributes,
|
|
1321
|
+
"operation.name": spanName,
|
|
1322
|
+
"code.function": spanName,
|
|
1323
|
+
"operation.duration": duration,
|
|
1324
|
+
"operation.success": true
|
|
1325
|
+
});
|
|
1326
|
+
handleTailSampling(true, duration);
|
|
1327
|
+
span2.end();
|
|
1328
|
+
void flushIfNeeded();
|
|
1329
|
+
return result;
|
|
1330
|
+
};
|
|
1331
|
+
const onError = (error) => {
|
|
1332
|
+
const duration = performance.now() - startTime;
|
|
1333
|
+
callCounter?.add(1, {
|
|
1334
|
+
operation: spanName,
|
|
1335
|
+
status: "error"
|
|
1336
|
+
});
|
|
1337
|
+
durationHistogram?.record(duration, {
|
|
1338
|
+
operation: spanName,
|
|
1339
|
+
status: "error"
|
|
1340
|
+
});
|
|
1341
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1342
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1343
|
+
span2.setStatus({
|
|
1344
|
+
code: SpanStatusCode.ERROR,
|
|
1345
|
+
message: truncatedMessage
|
|
1346
|
+
});
|
|
1347
|
+
span2.setAttributes({
|
|
1348
|
+
...argsAttributes,
|
|
1349
|
+
"operation.name": spanName,
|
|
1350
|
+
"code.function": spanName,
|
|
1351
|
+
"operation.duration": duration,
|
|
1352
|
+
"operation.success": false,
|
|
1353
|
+
error: true,
|
|
1354
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1355
|
+
"exception.message": truncatedMessage
|
|
1356
|
+
});
|
|
1357
|
+
span2.recordException(
|
|
1358
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1359
|
+
);
|
|
1360
|
+
handleTailSampling(false, duration, error);
|
|
1361
|
+
span2.end();
|
|
1362
|
+
void flushIfNeeded();
|
|
1363
|
+
throw error;
|
|
1364
|
+
};
|
|
1365
|
+
try {
|
|
1366
|
+
callCounter?.add(1, {
|
|
1367
|
+
operation: spanName,
|
|
1368
|
+
status: "started"
|
|
1369
|
+
});
|
|
1370
|
+
const result = fn.call(this, ...args);
|
|
1371
|
+
if (result instanceof Promise) {
|
|
1372
|
+
return result.then(onSuccess, onError);
|
|
1373
|
+
}
|
|
1374
|
+
return onSuccess(result);
|
|
1375
|
+
} catch (error) {
|
|
1376
|
+
return onError(error);
|
|
1362
1377
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
}
|
|
1367
|
-
});
|
|
1368
|
-
});
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
);
|
|
1369
1381
|
}
|
|
1370
1382
|
wrappedFunction[INSTRUMENTED_SYMBOL] = true;
|
|
1371
1383
|
Object.defineProperty(wrappedFunction, "name", {
|
|
@@ -1444,159 +1456,165 @@ function executeImmediately(fn, options) {
|
|
|
1444
1456
|
if (options.spanKind !== void 0) {
|
|
1445
1457
|
spanOptions.kind = options.spanKind;
|
|
1446
1458
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1459
|
+
const parentContext = getActiveContextWithBaggage();
|
|
1460
|
+
return tracer.startActiveSpan(
|
|
1461
|
+
spanName,
|
|
1462
|
+
spanOptions,
|
|
1463
|
+
parentContext,
|
|
1464
|
+
(span2) => {
|
|
1465
|
+
return runInOperationContext(spanName, () => {
|
|
1466
|
+
let shouldKeepSpan = true;
|
|
1467
|
+
setSpanName(span2, spanName);
|
|
1468
|
+
const ctxValue = createTraceContext(span2);
|
|
1469
|
+
const handleTailSampling = (success, duration, error) => {
|
|
1470
|
+
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
1471
|
+
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
1472
|
+
success,
|
|
1473
|
+
duration,
|
|
1474
|
+
error
|
|
1475
|
+
});
|
|
1476
|
+
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
1477
|
+
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
const onSuccessSync = (result) => {
|
|
1481
|
+
const duration = performance.now() - startTime;
|
|
1482
|
+
callCounter?.add(1, {
|
|
1483
|
+
operation: spanName,
|
|
1484
|
+
status: "success"
|
|
1458
1485
|
});
|
|
1459
|
-
|
|
1460
|
-
|
|
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
|
-
"exception.message": truncatedMessage
|
|
1509
|
-
});
|
|
1510
|
-
if (error instanceof Error && error.stack) {
|
|
1511
|
-
span2.setAttribute(
|
|
1512
|
-
"exception.stack",
|
|
1513
|
-
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1486
|
+
durationHistogram?.record(duration, {
|
|
1487
|
+
operation: spanName,
|
|
1488
|
+
status: "success"
|
|
1489
|
+
});
|
|
1490
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1491
|
+
span2.setAttributes({
|
|
1492
|
+
"operation.name": spanName,
|
|
1493
|
+
"code.function": spanName,
|
|
1494
|
+
"operation.duration": duration,
|
|
1495
|
+
"operation.success": true
|
|
1496
|
+
});
|
|
1497
|
+
handleTailSampling(true, duration);
|
|
1498
|
+
span2.end();
|
|
1499
|
+
void flushIfNeeded();
|
|
1500
|
+
return result;
|
|
1501
|
+
};
|
|
1502
|
+
const onErrorSync = (error) => {
|
|
1503
|
+
const duration = performance.now() - startTime;
|
|
1504
|
+
callCounter?.add(1, {
|
|
1505
|
+
operation: spanName,
|
|
1506
|
+
status: "error"
|
|
1507
|
+
});
|
|
1508
|
+
durationHistogram?.record(duration, {
|
|
1509
|
+
operation: spanName,
|
|
1510
|
+
status: "error"
|
|
1511
|
+
});
|
|
1512
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1513
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1514
|
+
span2.setStatus({
|
|
1515
|
+
code: SpanStatusCode.ERROR,
|
|
1516
|
+
message: truncatedMessage
|
|
1517
|
+
});
|
|
1518
|
+
span2.setAttributes({
|
|
1519
|
+
"operation.name": spanName,
|
|
1520
|
+
"code.function": spanName,
|
|
1521
|
+
"operation.duration": duration,
|
|
1522
|
+
"operation.success": false,
|
|
1523
|
+
error: true,
|
|
1524
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1525
|
+
"exception.message": truncatedMessage
|
|
1526
|
+
});
|
|
1527
|
+
if (error instanceof Error && error.stack) {
|
|
1528
|
+
span2.setAttribute(
|
|
1529
|
+
"exception.stack",
|
|
1530
|
+
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
span2.recordException(
|
|
1534
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1514
1535
|
);
|
|
1515
|
-
|
|
1516
|
-
|
|
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
|
-
error
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
error
|
|
1536
|
+
handleTailSampling(false, duration, error);
|
|
1537
|
+
span2.end();
|
|
1538
|
+
void flushIfNeeded();
|
|
1539
|
+
throw error;
|
|
1540
|
+
};
|
|
1541
|
+
const onSuccessAsync = async (result) => {
|
|
1542
|
+
const duration = performance.now() - startTime;
|
|
1543
|
+
callCounter?.add(1, {
|
|
1544
|
+
operation: spanName,
|
|
1545
|
+
status: "success"
|
|
1546
|
+
});
|
|
1547
|
+
durationHistogram?.record(duration, {
|
|
1548
|
+
operation: spanName,
|
|
1549
|
+
status: "success"
|
|
1550
|
+
});
|
|
1551
|
+
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1552
|
+
span2.setAttributes({
|
|
1553
|
+
"operation.name": spanName,
|
|
1554
|
+
"code.function": spanName,
|
|
1555
|
+
"operation.duration": duration,
|
|
1556
|
+
"operation.success": true
|
|
1557
|
+
});
|
|
1558
|
+
handleTailSampling(true, duration);
|
|
1559
|
+
span2.end();
|
|
1560
|
+
await flushIfNeeded();
|
|
1561
|
+
return result;
|
|
1562
|
+
};
|
|
1563
|
+
const onErrorAsync = async (error) => {
|
|
1564
|
+
const duration = performance.now() - startTime;
|
|
1565
|
+
callCounter?.add(1, {
|
|
1566
|
+
operation: spanName,
|
|
1567
|
+
status: "error"
|
|
1568
|
+
});
|
|
1569
|
+
durationHistogram?.record(duration, {
|
|
1570
|
+
operation: spanName,
|
|
1571
|
+
status: "error"
|
|
1572
|
+
});
|
|
1573
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1574
|
+
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
1575
|
+
span2.setStatus({
|
|
1576
|
+
code: SpanStatusCode.ERROR,
|
|
1577
|
+
message: truncatedMessage
|
|
1578
|
+
});
|
|
1579
|
+
span2.setAttributes({
|
|
1580
|
+
"operation.name": spanName,
|
|
1581
|
+
"code.function": spanName,
|
|
1582
|
+
"operation.duration": duration,
|
|
1583
|
+
"operation.success": false,
|
|
1584
|
+
error: true,
|
|
1585
|
+
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1586
|
+
"exception.message": truncatedMessage
|
|
1587
|
+
});
|
|
1588
|
+
if (error instanceof Error && error.stack) {
|
|
1589
|
+
span2.setAttribute(
|
|
1590
|
+
"exception.stack",
|
|
1591
|
+
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
span2.recordException(
|
|
1595
|
+
error instanceof Error ? error : new Error(String(error))
|
|
1575
1596
|
);
|
|
1597
|
+
handleTailSampling(false, duration, error);
|
|
1598
|
+
span2.end();
|
|
1599
|
+
await flushIfNeeded();
|
|
1600
|
+
throw error;
|
|
1601
|
+
};
|
|
1602
|
+
try {
|
|
1603
|
+
callCounter?.add(1, {
|
|
1604
|
+
operation: spanName,
|
|
1605
|
+
status: "started"
|
|
1606
|
+
});
|
|
1607
|
+
const result = fn(ctxValue);
|
|
1608
|
+
if (result instanceof Promise) {
|
|
1609
|
+
return result.then(onSuccessAsync, onErrorAsync);
|
|
1610
|
+
}
|
|
1611
|
+
return onSuccessSync(result);
|
|
1612
|
+
} catch (error) {
|
|
1613
|
+
return onErrorSync(error);
|
|
1576
1614
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
handleTailSampling(false, duration, error);
|
|
1581
|
-
span2.end();
|
|
1582
|
-
await flushIfNeeded();
|
|
1583
|
-
throw error;
|
|
1584
|
-
};
|
|
1585
|
-
try {
|
|
1586
|
-
callCounter?.add(1, {
|
|
1587
|
-
operation: spanName,
|
|
1588
|
-
status: "started"
|
|
1589
|
-
});
|
|
1590
|
-
const result = fn(ctxValue);
|
|
1591
|
-
if (result instanceof Promise) {
|
|
1592
|
-
return result.then(onSuccessAsync, onErrorAsync);
|
|
1593
|
-
}
|
|
1594
|
-
return onSuccessSync(result);
|
|
1595
|
-
} catch (error) {
|
|
1596
|
-
return onErrorSync(error);
|
|
1597
|
-
}
|
|
1598
|
-
});
|
|
1599
|
-
});
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
);
|
|
1600
1618
|
}
|
|
1601
1619
|
function trace2(fnOrNameOrOptions, maybeFn) {
|
|
1602
1620
|
if (typeof fnOrNameOrOptions === "function") {
|
|
@@ -1728,7 +1746,8 @@ function span(options, fn) {
|
|
|
1728
1746
|
}
|
|
1729
1747
|
});
|
|
1730
1748
|
};
|
|
1731
|
-
const
|
|
1749
|
+
const parentContext = getActiveContextWithBaggage();
|
|
1750
|
+
const result = tracer.startActiveSpan(name, {}, parentContext, executeSpan);
|
|
1732
1751
|
if (result instanceof Promise) {
|
|
1733
1752
|
return result;
|
|
1734
1753
|
}
|
|
@@ -1764,7 +1783,7 @@ function withBaggage(options) {
|
|
|
1764
1783
|
const newContext = propagation.setBaggage(currentContext, updatedBaggage);
|
|
1765
1784
|
const ctxStorage = getContextStorage();
|
|
1766
1785
|
const previousStored = ctxStorage.getStore();
|
|
1767
|
-
const baggageEnrichedStored = previousStored ? propagation.setBaggage(previousStored, updatedBaggage) : newContext;
|
|
1786
|
+
const baggageEnrichedStored = previousStored ? { value: propagation.setBaggage(previousStored.value, updatedBaggage) } : { value: newContext };
|
|
1768
1787
|
const result = previousStored ? ctxStorage.run(baggageEnrichedStored, () => context.with(newContext, fn)) : context.with(newContext, fn);
|
|
1769
1788
|
if (result instanceof Promise) {
|
|
1770
1789
|
return result.then(
|
|
@@ -1788,5 +1807,5 @@ function withBaggage(options) {
|
|
|
1788
1807
|
}
|
|
1789
1808
|
|
|
1790
1809
|
export { ctx, getEventQueue, instrument, resetEventQueue, span, trace2 as trace, track, withBaggage, withNewContext, withTracing };
|
|
1791
|
-
//# sourceMappingURL=chunk-
|
|
1792
|
-
//# sourceMappingURL=chunk-
|
|
1810
|
+
//# sourceMappingURL=chunk-OPTGXEVN.js.map
|
|
1811
|
+
//# sourceMappingURL=chunk-OPTGXEVN.js.map
|