autotel 6.4.1 → 7.0.0
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 +30 -23
- package/dist/{attribute-redacting-processor-Pk7lAzWd.d.cts → attribute-redacting-processor-CvBE0z1p.d.cts} +33 -1
- package/dist/{attribute-redacting-processor-Pk7lAzWd.d.ts → attribute-redacting-processor-CvBE0z1p.d.ts} +33 -1
- package/dist/attribute-redacting-processor.cjs +34 -32
- package/dist/attribute-redacting-processor.d.cts +1 -1
- package/dist/attribute-redacting-processor.d.ts +1 -1
- package/dist/attribute-redacting-processor.js +35 -32
- package/dist/{attributes-aDmJYral.cjs → attributes-Cxys8tgr.cjs} +34 -35
- package/dist/{attributes-B7wix2VG.js → attributes-Dt4YUYbP.js} +34 -35
- package/dist/attributes.cjs +1 -1
- package/dist/attributes.d.cts +1 -1
- package/dist/attributes.d.ts +1 -1
- package/dist/attributes.js +1 -1
- package/dist/auto.cjs +1 -1
- package/dist/auto.js +1 -1
- package/dist/business-baggage.cjs +19 -12
- package/dist/business-baggage.d.cts +8 -3
- package/dist/business-baggage.d.ts +8 -3
- package/dist/business-baggage.js +19 -12
- package/dist/{canonical-log-line-processor-DxtBGZIi.cjs → canonical-log-line-processor-DolzdawH.cjs} +43 -32
- package/dist/{canonical-log-line-processor-B4WgG-VS.d.cts → canonical-log-line-processor-cPB4Axk-.d.ts} +4 -3
- package/dist/{canonical-log-line-processor-B0vq_QR6.js → canonical-log-line-processor-hFUmS__K.js} +43 -32
- package/dist/{canonical-log-line-processor-CL_J7gb5.d.ts → canonical-log-line-processor-l0Aqe6yp.d.cts} +4 -3
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{correlated-events-kSwLo3mi.cjs → correlated-events-CcuknWnU.cjs} +2 -1
- package/dist/{correlated-events-Bzh5y-UB.js → correlated-events-DwMMbItg.js} +3 -1
- package/dist/correlation-id.cjs +1 -1
- package/dist/correlation-id.js +1 -1
- package/dist/db.cjs +34 -19
- package/dist/db.js +34 -19
- package/dist/decorators.cjs +4 -2
- package/dist/decorators.d.cts +16 -11
- package/dist/decorators.d.ts +16 -11
- package/dist/decorators.js +4 -2
- package/dist/{define-event-CGG048HE.d.cts → define-event-BNeuKUPv.d.cts} +1 -1
- package/dist/{define-event-B2z1SBe7.d.ts → define-event-Bd8f8mST.d.ts} +1 -1
- package/dist/diagnostics.cjs +18 -16
- package/dist/diagnostics.d.cts +14 -10
- package/dist/diagnostics.d.ts +14 -10
- package/dist/diagnostics.js +18 -16
- package/dist/{event-subscriber-CWh8sTGh.d.cts → event-subscriber-DMACQA-1.d.cts} +19 -9
- package/dist/{event-subscriber-CWh8sTGh.d.ts → event-subscriber-DMACQA-1.d.ts} +19 -9
- package/dist/event-subscriber.d.cts +2 -2
- package/dist/event-subscriber.d.ts +2 -2
- package/dist/{event-testing-D0qWfqAy.d.cts → event-testing-CBtnJXE5.d.cts} +1 -1
- package/dist/{event-testing-CA2mIx1E.d.ts → event-testing-CkPgV3Ii.d.ts} +1 -1
- package/dist/event-testing.d.cts +1 -1
- package/dist/event-testing.d.ts +1 -1
- package/dist/event.cjs +1 -1
- package/dist/event.d.cts +5 -5
- package/dist/event.d.ts +5 -5
- package/dist/event.js +1 -1
- package/dist/exception-fingerprint.cjs +133 -0
- package/dist/exception-fingerprint.d.cts +51 -0
- package/dist/exception-fingerprint.d.ts +51 -0
- package/dist/exception-fingerprint.js +126 -0
- package/dist/{functional-AT22vCw6.d.ts → functional-CJn2zY4o.d.cts} +96 -39
- package/dist/{functional-e6jw5zQj.d.cts → functional-DXy1cHFF.d.ts} +96 -39
- package/dist/{functional-qZxRcIBp.cjs → functional-Da6Yv64r.cjs} +27 -15
- package/dist/{functional-0o9xSedq.js → functional-uSbNnnxK.js} +27 -15
- package/dist/functional.cjs +1 -1
- package/dist/functional.d.cts +2 -2
- package/dist/functional.d.ts +2 -2
- package/dist/functional.js +1 -1
- package/dist/http.cjs +11 -8
- package/dist/http.js +11 -8
- package/dist/{index-DolOVX6F.d.ts → index-CwrNAsgk.d.ts} +22 -26
- package/dist/{index-BPcxVucm.d.cts → index-DQHf4cNl.d.cts} +22 -26
- package/dist/index.cjs +41 -35
- package/dist/index.d.cts +45 -30
- package/dist/index.d.ts +45 -30
- package/dist/index.js +41 -35
- package/dist/{init-CsODvlau.d.ts → init-BgnYi2sm.d.ts} +94 -90
- package/dist/{init-BnxHAi2M.cjs → init-D4m5rCmD.cjs} +142 -123
- package/dist/{init-Cc7-vvzj.d.cts → init-DrlL1eis.d.cts} +94 -90
- package/dist/{init-BxfZ3Vbw.js → init-JtX-KKz_.js} +137 -124
- package/dist/instrumentation.cjs +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{logger-D3Ej3DII.js → logger-DdPp__xW.js} +63 -54
- package/dist/{logger-CN4xpzMd.d.cts → logger-S1Fgl0g3.d.cts} +0 -20
- package/dist/{logger-CN4xpzMd.d.ts → logger-S1Fgl0g3.d.ts} +0 -20
- package/dist/{logger-thMPLpOG.cjs → logger-Sm66cjKl.cjs} +63 -54
- package/dist/logger.cjs +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +1 -1
- package/dist/messaging-adapters.cjs +26 -12
- package/dist/messaging-adapters.d.cts +0 -30
- package/dist/messaging-adapters.d.ts +0 -30
- package/dist/messaging-adapters.js +26 -12
- package/dist/messaging.cjs +37 -34
- package/dist/messaging.d.cts +21 -62
- package/dist/messaging.d.ts +21 -62
- package/dist/messaging.js +37 -34
- package/dist/{metric-testing-CpvP3ZIa.d.cts → metric-testing-86WO1wan.d.cts} +1 -1
- package/dist/{metric-testing-CWm6UhaR.d.ts → metric-testing-CbCxdPBp.d.ts} +1 -1
- package/dist/metric-testing.d.cts +1 -1
- package/dist/metric-testing.d.ts +1 -1
- package/dist/metric.d.cts +3 -3
- package/dist/metric.d.ts +3 -3
- package/dist/{node-require-vROmTeJ8.js → node-require-DSPjaw_l.js} +3 -2
- package/dist/{node-require-PFqDihze.cjs → node-require-EifOMikz.cjs} +3 -2
- package/dist/parse-error.cjs +18 -12
- package/dist/parse-error.d.cts +2 -1
- package/dist/parse-error.d.ts +2 -1
- package/dist/parse-error.js +19 -12
- package/dist/policy.cjs +0 -0
- package/dist/policy.js +0 -0
- package/dist/processors.cjs +1 -1
- package/dist/processors.d.cts +1 -1
- package/dist/processors.d.ts +1 -1
- package/dist/processors.js +1 -1
- package/dist/{sampling-BR9fkSwx.d.cts → sampling-CM5S2Lp3.d.ts} +5 -6
- package/dist/{sampling-CP3e7-Yr.d.ts → sampling-CmRdnXUi.d.cts} +5 -6
- package/dist/sampling.cjs +3 -2
- package/dist/sampling.d.cts +1 -1
- package/dist/sampling.d.ts +1 -1
- package/dist/sampling.js +3 -2
- package/dist/semantic-helpers.cjs +9 -9
- package/dist/semantic-helpers.d.cts +1 -1
- package/dist/semantic-helpers.d.ts +1 -1
- package/dist/semantic-helpers.js +9 -9
- package/dist/{stable-hash-ChFBIhNt.js → stable-hash-BkoAYVks.js} +4 -3
- package/dist/{stable-hash-CS9BxvVQ.cjs → stable-hash-C0pOegH_.cjs} +4 -3
- package/dist/{structured-error-CHg7DoIQ.cjs → structured-error--_wXpd_C.cjs} +34 -25
- package/dist/{structured-error-9--cxBay.js → structured-error-YIuka-FE.js} +34 -25
- package/dist/test-span-collector.cjs +15 -8
- package/dist/test-span-collector.js +15 -8
- package/dist/testing.cjs +16 -18
- package/dist/testing.d.cts +7 -6
- package/dist/testing.d.ts +7 -6
- package/dist/testing.js +16 -18
- package/dist/{trace-context-IuyoPyNq.d.cts → trace-context-C1Cn1q0y.d.cts} +8 -7
- package/dist/{trace-context-IuyoPyNq.d.ts → trace-context-f89xPJbK.d.ts} +8 -7
- package/dist/trace-helpers.cjs +16 -13
- package/dist/trace-helpers.d.cts +9 -4
- package/dist/trace-helpers.d.ts +9 -4
- package/dist/trace-helpers.js +16 -13
- package/dist/tracer-provider.cjs +8 -12
- package/dist/tracer-provider.js +8 -12
- package/dist/validate.cjs +22 -20
- package/dist/validate.d.cts +3 -2
- package/dist/validate.d.ts +3 -2
- package/dist/validate.js +22 -20
- package/dist/values-BenyvWKz.js +141 -0
- package/dist/values-CeMH-mYG.d.cts +8 -0
- package/dist/values-CeMH-mYG.d.ts +8 -0
- package/dist/values-DApyq53y.cjs +267 -0
- package/dist/webhook.cjs +3 -3
- package/dist/webhook.d.cts +1 -1
- package/dist/webhook.d.ts +1 -1
- package/dist/webhook.js +3 -3
- package/dist/workflow-distributed.cjs +9 -7
- package/dist/workflow-distributed.d.cts +9 -8
- package/dist/workflow-distributed.d.ts +9 -8
- package/dist/workflow-distributed.js +9 -7
- package/dist/workflow.cjs +26 -17
- package/dist/workflow.d.cts +1 -28
- package/dist/workflow.d.ts +1 -28
- package/dist/workflow.js +26 -17
- package/dist/yaml-config.cjs +26 -11
- package/dist/yaml-config.d.cts +9 -3
- package/dist/yaml-config.d.ts +9 -3
- package/dist/yaml-config.js +26 -11
- package/package.json +6 -1
package/dist/messaging.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_values = require('./values-DApyq53y.cjs');
|
|
2
3
|
const require_sampling = require('./sampling.cjs');
|
|
3
|
-
const require_functional = require('./functional-
|
|
4
|
-
const require_correlated_events = require('./correlated-events-
|
|
4
|
+
const require_functional = require('./functional-Da6Yv64r.cjs');
|
|
5
|
+
const require_correlated_events = require('./correlated-events-CcuknWnU.cjs');
|
|
5
6
|
const require_trace_factory_validation = require('./trace-factory-validation-Dc8epn87.cjs');
|
|
6
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
7
8
|
|
|
@@ -91,10 +92,22 @@ let _opentelemetry_api = require("@opentelemetry/api");
|
|
|
91
92
|
* });
|
|
92
93
|
* ```
|
|
93
94
|
*/
|
|
95
|
+
/** The Error an onError callback expects, wrapping a non-Error rejection. */
|
|
96
|
+
function toError(cause) {
|
|
97
|
+
return cause instanceof Error ? cause : new Error(String(cause));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Check a config a JavaScript caller may have built by hand. TypeScript has
|
|
101
|
+
* already checked it for everyone else, so this only has to catch the shapes
|
|
102
|
+
* that reach here untyped.
|
|
103
|
+
*/
|
|
104
|
+
function assertMessagingConfig(fn, config) {
|
|
105
|
+
const record = require_values.asRecord(config);
|
|
106
|
+
if (!record) throw new TypeError(`${fn}: config must be an object`);
|
|
107
|
+
for (const field of ["system", "destination"]) if (require_values.nonEmptyString(record[field]) === void 0) throw new TypeError(`${fn}: config.${field} must be a non-empty string`);
|
|
108
|
+
}
|
|
94
109
|
function traceProducer(config) {
|
|
95
|
-
|
|
96
|
-
if (typeof config.system !== "string" || config.system.trim() === "") throw new TypeError("traceProducer: config.system must be a non-empty string");
|
|
97
|
-
if (typeof config.destination !== "string" || config.destination.trim() === "") throw new TypeError("traceProducer: config.destination must be a non-empty string");
|
|
110
|
+
assertMessagingConfig("traceProducer", config);
|
|
98
111
|
const spanName = `publish ${config.destination}`;
|
|
99
112
|
return (fnFactory) => {
|
|
100
113
|
require_trace_factory_validation.assertTraceFactory("traceProducer", fnFactory);
|
|
@@ -114,7 +127,7 @@ function traceProducer(config) {
|
|
|
114
127
|
const userFn = fnFactory(ctx);
|
|
115
128
|
require_trace_factory_validation.assertTraceFactory("traceProducer", userFn, "result");
|
|
116
129
|
return Promise.resolve(userFn(...args)).catch((error) => {
|
|
117
|
-
if (config.onError) config.onError(error, ctx);
|
|
130
|
+
if (config.onError) config.onError(toError(error), ctx);
|
|
118
131
|
throw error;
|
|
119
132
|
});
|
|
120
133
|
};
|
|
@@ -189,10 +202,9 @@ function traceProducer(config) {
|
|
|
189
202
|
* });
|
|
190
203
|
* ```
|
|
191
204
|
*/
|
|
192
|
-
function traceConsumer(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (typeof config.destination !== "string" || config.destination.trim() === "") throw new TypeError("traceConsumer: config.destination must be a non-empty string");
|
|
205
|
+
function traceConsumer(typedConfig) {
|
|
206
|
+
const config = typedConfig;
|
|
207
|
+
assertMessagingConfig("traceConsumer", config);
|
|
196
208
|
const spanName = `${config.batchMode ? "receive" : "process"} ${config.destination}`;
|
|
197
209
|
return (fnFactory) => {
|
|
198
210
|
require_trace_factory_validation.assertTraceFactory("traceConsumer", fnFactory);
|
|
@@ -209,15 +221,16 @@ function traceConsumer(config) {
|
|
|
209
221
|
outOfOrderInfo: null
|
|
210
222
|
};
|
|
211
223
|
const groupTracking = config.consumerGroupTracking;
|
|
212
|
-
const
|
|
213
|
-
memberId:
|
|
214
|
-
groupInstanceId:
|
|
224
|
+
const groupState = {
|
|
225
|
+
memberId: require_values.resolveValue(groupTracking?.memberId) ?? null,
|
|
226
|
+
groupInstanceId: require_values.resolveValue(groupTracking?.groupInstanceId) ?? null,
|
|
215
227
|
assignedPartitions: [],
|
|
216
228
|
generation: null,
|
|
217
229
|
isActive: true,
|
|
218
230
|
lastHeartbeat: null,
|
|
219
231
|
state: null
|
|
220
|
-
}
|
|
232
|
+
};
|
|
233
|
+
const ctx = extendContextForConsumer(baseCtx, config, linkStorage, orderingState, groupState);
|
|
221
234
|
setConsumerAttributes(ctx, config);
|
|
222
235
|
return async (...args) => {
|
|
223
236
|
await extractAndAddLinks(ctx, config, args, linkStorage);
|
|
@@ -234,7 +247,7 @@ function traceConsumer(config) {
|
|
|
234
247
|
const userFn = fnFactory(ctx);
|
|
235
248
|
require_trace_factory_validation.assertTraceFactory("traceConsumer", userFn, "result");
|
|
236
249
|
return Promise.resolve(userFn(...args)).catch((error) => {
|
|
237
|
-
if (config.onError) config.onError(error, ctx);
|
|
250
|
+
if (config.onError) config.onError(toError(error), ctx);
|
|
238
251
|
throw error;
|
|
239
252
|
});
|
|
240
253
|
};
|
|
@@ -307,12 +320,8 @@ function extendContextForConsumer(baseCtx, config, linkStorage, orderingState, g
|
|
|
307
320
|
const consumerCtx = {
|
|
308
321
|
...baseCtx,
|
|
309
322
|
recordDLQ(reason, dlqNameOrOptions, optionsParam) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (typeof dlqNameOrOptions === "string") {
|
|
313
|
-
dlqName = dlqNameOrOptions;
|
|
314
|
-
options = optionsParam;
|
|
315
|
-
} else if (typeof dlqNameOrOptions === "object") options = dlqNameOrOptions;
|
|
323
|
+
const { name: dlqName, options: inlineOptions } = require_values.splitNameOrOptions(dlqNameOrOptions);
|
|
324
|
+
const options = dlqName === void 0 ? inlineOptions : optionsParam;
|
|
316
325
|
const linkToProducer = options?.linkToProducer ?? true;
|
|
317
326
|
baseCtx.setAttribute("messaging.dlq.reason", reason);
|
|
318
327
|
if (dlqName) baseCtx.setAttribute("messaging.dlq.name", dlqName);
|
|
@@ -605,29 +614,23 @@ async function extractLagMetrics(ctx, lagConfig, args) {
|
|
|
605
614
|
* Extract headers from message using config
|
|
606
615
|
*/
|
|
607
616
|
function extractHeaders(headersFrom, msg) {
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
-
const value = msg[headersFrom];
|
|
611
|
-
if (typeof value === "object" && value !== null) return value;
|
|
612
|
-
}
|
|
617
|
+
if (require_values.isFunction(headersFrom)) return headersFrom(msg);
|
|
618
|
+
return require_values.asRecord(require_values.readProperty(msg, headersFrom));
|
|
613
619
|
}
|
|
614
620
|
/**
|
|
615
621
|
* Extract value from arguments using config
|
|
616
622
|
*/
|
|
617
623
|
function extractValue(extractor, args) {
|
|
618
|
-
|
|
619
|
-
const firstArg = args[0];
|
|
620
|
-
if (typeof firstArg === "object" && firstArg !== null) return firstArg[extractor];
|
|
624
|
+
return require_values.isFunction(extractor) ? extractor(args) : require_values.asScalar(require_values.readProperty(args[0], extractor));
|
|
621
625
|
}
|
|
622
626
|
/**
|
|
623
627
|
* Set custom attributes on context, handling non-primitive values
|
|
624
628
|
*/
|
|
625
629
|
function setCustomAttributes(ctx, attributes) {
|
|
626
|
-
for (const [key, value] of Object.entries(attributes))
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
} else ctx.setAttribute(key, JSON.stringify(value));
|
|
630
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
631
|
+
const attribute = require_values.toAttributeValue(value);
|
|
632
|
+
if (attribute !== void 0) ctx.setAttribute(key, attribute);
|
|
633
|
+
}
|
|
631
634
|
}
|
|
632
635
|
/**
|
|
633
636
|
* Extract and process ordering information from message
|
package/dist/messaging.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TraceContext } from "./trace-context-
|
|
1
|
+
import { n as TraceContext } from "./trace-context-C1Cn1q0y.cjs";
|
|
2
2
|
import { Attributes, Link, SpanContext } from "@opentelemetry/api";
|
|
3
3
|
//#region src/messaging.d.ts
|
|
4
4
|
/**
|
|
@@ -83,7 +83,7 @@ interface ProducerConfig {
|
|
|
83
83
|
/**
|
|
84
84
|
* Configuration for consumer tracing
|
|
85
85
|
*/
|
|
86
|
-
interface ConsumerConfig {
|
|
86
|
+
interface ConsumerConfig<TMessage = unknown> {
|
|
87
87
|
/** Messaging system (kafka, rabbitmq, sqs, etc.) */
|
|
88
88
|
system: MessagingSystem;
|
|
89
89
|
/** Destination name (topic/queue) */
|
|
@@ -91,7 +91,7 @@ interface ConsumerConfig {
|
|
|
91
91
|
/** Consumer group name */
|
|
92
92
|
consumerGroup?: string;
|
|
93
93
|
/** Extract headers from message for link creation */
|
|
94
|
-
headersFrom?: string | ((msg:
|
|
94
|
+
headersFrom?: string | ((msg: TMessage) => Record<string, string> | undefined);
|
|
95
95
|
/** Enable batch mode - extract links from all messages */
|
|
96
96
|
batchMode?: boolean;
|
|
97
97
|
/** Extract baggage from message headers */
|
|
@@ -99,7 +99,7 @@ interface ConsumerConfig {
|
|
|
99
99
|
/** Additional attributes to set on span */
|
|
100
100
|
attributes?: Attributes;
|
|
101
101
|
/** Consumer lag metrics extraction */
|
|
102
|
-
lagMetrics?: LagMetricsConfig
|
|
102
|
+
lagMetrics?: LagMetricsConfig<TMessage>;
|
|
103
103
|
/** Callback when message goes to DLQ */
|
|
104
104
|
onDLQ?: (ctx: ConsumerContext, reason: string) => void;
|
|
105
105
|
/** Callback on error */
|
|
@@ -121,7 +121,7 @@ interface ConsumerConfig {
|
|
|
121
121
|
* }
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
|
-
ordering?: OrderingConfig
|
|
124
|
+
ordering?: OrderingConfig<TMessage>;
|
|
125
125
|
/**
|
|
126
126
|
* Consumer group tracking configuration
|
|
127
127
|
*
|
|
@@ -168,7 +168,7 @@ interface ConsumerConfig {
|
|
|
168
168
|
* })
|
|
169
169
|
* ```
|
|
170
170
|
*/
|
|
171
|
-
customAttributes?: (ctx: ConsumerContext, msg:
|
|
171
|
+
customAttributes?: (ctx: ConsumerContext, msg: TMessage) => Attributes;
|
|
172
172
|
/**
|
|
173
173
|
* Hook for custom context extraction (beyond W3C traceparent)
|
|
174
174
|
*
|
|
@@ -209,20 +209,20 @@ interface ConsumerConfig {
|
|
|
209
209
|
/**
|
|
210
210
|
* Configuration for consumer lag metrics
|
|
211
211
|
*/
|
|
212
|
-
interface LagMetricsConfig {
|
|
212
|
+
interface LagMetricsConfig<TMessage = unknown> {
|
|
213
213
|
/** Get current message offset */
|
|
214
|
-
getCurrentOffset?: (msg:
|
|
214
|
+
getCurrentOffset?: (msg: TMessage) => number | undefined;
|
|
215
215
|
/** Get end offset (high watermark) - can be async */
|
|
216
216
|
getEndOffset?: () => number | Promise<number>;
|
|
217
217
|
/** Get committed offset - can be async */
|
|
218
218
|
getCommittedOffset?: () => number | Promise<number>;
|
|
219
219
|
/** Get partition from message */
|
|
220
|
-
getPartition?: (msg:
|
|
220
|
+
getPartition?: (msg: TMessage) => number | undefined;
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* Configuration for message ordering tracking
|
|
224
224
|
*/
|
|
225
|
-
interface OrderingConfig {
|
|
225
|
+
interface OrderingConfig<TMessage = unknown> {
|
|
226
226
|
/**
|
|
227
227
|
* Extract sequence number from message
|
|
228
228
|
*
|
|
@@ -233,7 +233,7 @@ interface OrderingConfig {
|
|
|
233
233
|
* sequenceFrom: (msg) => msg.offset
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
|
-
sequenceFrom?: (msg:
|
|
236
|
+
sequenceFrom?: (msg: TMessage) => number | undefined;
|
|
237
237
|
/**
|
|
238
238
|
* Extract partition key from message
|
|
239
239
|
*
|
|
@@ -244,7 +244,7 @@ interface OrderingConfig {
|
|
|
244
244
|
* partitionKeyFrom: (msg) => msg.key
|
|
245
245
|
* ```
|
|
246
246
|
*/
|
|
247
|
-
partitionKeyFrom?: (msg:
|
|
247
|
+
partitionKeyFrom?: (msg: TMessage) => string | undefined;
|
|
248
248
|
/**
|
|
249
249
|
* Extract message ID for deduplication
|
|
250
250
|
*
|
|
@@ -255,7 +255,7 @@ interface OrderingConfig {
|
|
|
255
255
|
* messageIdFrom: (msg) => msg.headers['idempotency-key']
|
|
256
256
|
* ```
|
|
257
257
|
*/
|
|
258
|
-
messageIdFrom?: (msg:
|
|
258
|
+
messageIdFrom?: (msg: TMessage) => string | undefined;
|
|
259
259
|
/**
|
|
260
260
|
* Enable out-of-order detection
|
|
261
261
|
*
|
|
@@ -499,6 +499,11 @@ interface DLQReplayOptions {
|
|
|
499
499
|
/**
|
|
500
500
|
* Extended trace context for producers with header injection
|
|
501
501
|
*/
|
|
502
|
+
/** The W3C trace context headers a producer attaches to a message. */
|
|
503
|
+
interface TraceHeaders {
|
|
504
|
+
traceparent: string;
|
|
505
|
+
tracestate?: string;
|
|
506
|
+
}
|
|
502
507
|
interface ProducerContext extends TraceContext {
|
|
503
508
|
/**
|
|
504
509
|
* Get W3C trace context headers to inject into message
|
|
@@ -514,10 +519,7 @@ interface ProducerContext extends TraceContext {
|
|
|
514
519
|
* });
|
|
515
520
|
* ```
|
|
516
521
|
*/
|
|
517
|
-
getTraceHeaders():
|
|
518
|
-
traceparent: string;
|
|
519
|
-
tracestate?: string;
|
|
520
|
-
};
|
|
522
|
+
getTraceHeaders(): TraceHeaders;
|
|
521
523
|
/**
|
|
522
524
|
* Get all propagation headers including baggage if enabled
|
|
523
525
|
*
|
|
@@ -700,49 +702,6 @@ interface ConsumerContext extends TraceContext {
|
|
|
700
702
|
*/
|
|
701
703
|
getAssignedPartitions(): PartitionAssignment[];
|
|
702
704
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Create a traced message producer function
|
|
705
|
-
*
|
|
706
|
-
* Sets SpanKind.PRODUCER, OTel messaging semantic attributes,
|
|
707
|
-
* and provides context injection helpers.
|
|
708
|
-
*
|
|
709
|
-
* @param config - Producer configuration
|
|
710
|
-
* @returns Factory function that wraps your producer logic
|
|
711
|
-
*
|
|
712
|
-
* @example Kafka producer
|
|
713
|
-
* ```typescript
|
|
714
|
-
* export const publishUserEvent = traceProducer({
|
|
715
|
-
* system: 'kafka',
|
|
716
|
-
* destination: 'user-events',
|
|
717
|
-
* messageIdFrom: (args) => args[0]?.eventId,
|
|
718
|
-
* })(ctx => async (event: UserEvent) => {
|
|
719
|
-
* const headers = ctx.getTraceHeaders();
|
|
720
|
-
* await producer.send({
|
|
721
|
-
* topic: 'user-events',
|
|
722
|
-
* messages: [{
|
|
723
|
-
* key: event.userId,
|
|
724
|
-
* value: JSON.stringify(event),
|
|
725
|
-
* headers,
|
|
726
|
-
* }]
|
|
727
|
-
* });
|
|
728
|
-
* });
|
|
729
|
-
* ```
|
|
730
|
-
*
|
|
731
|
-
* @example SQS producer
|
|
732
|
-
* ```typescript
|
|
733
|
-
* export const sendToSQS = traceProducer({
|
|
734
|
-
* system: 'sqs',
|
|
735
|
-
* destination: 'orders-queue',
|
|
736
|
-
* })(ctx => async (order: Order) => {
|
|
737
|
-
* const headers = ctx.getAllPropagationHeaders();
|
|
738
|
-
* await sqs.sendMessage({
|
|
739
|
-
* QueueUrl: QUEUE_URL,
|
|
740
|
-
* MessageBody: JSON.stringify(order),
|
|
741
|
-
* MessageAttributes: headersToSQSAttributes(headers),
|
|
742
|
-
* });
|
|
743
|
-
* });
|
|
744
|
-
* ```
|
|
745
|
-
*/
|
|
746
705
|
declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ProducerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
747
706
|
/**
|
|
748
707
|
* Create a traced message consumer function
|
|
@@ -812,10 +771,10 @@ declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[]
|
|
|
812
771
|
* });
|
|
813
772
|
* ```
|
|
814
773
|
*/
|
|
815
|
-
declare function traceConsumer(
|
|
774
|
+
declare function traceConsumer<TMessage = unknown>(typedConfig: ConsumerConfig<TMessage>): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ConsumerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
816
775
|
/**
|
|
817
776
|
* Clear sequence tracking state (useful for testing)
|
|
818
777
|
*/
|
|
819
778
|
declare function clearOrderingState(): void;
|
|
820
779
|
//#endregion
|
|
821
|
-
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, clearOrderingState, traceConsumer, traceProducer };
|
|
780
|
+
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, TraceHeaders, clearOrderingState, traceConsumer, traceProducer };
|
package/dist/messaging.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TraceContext } from "./trace-context-
|
|
1
|
+
import { n as TraceContext } from "./trace-context-f89xPJbK.js";
|
|
2
2
|
import { Attributes, Link, SpanContext } from "@opentelemetry/api";
|
|
3
3
|
//#region src/messaging.d.ts
|
|
4
4
|
/**
|
|
@@ -83,7 +83,7 @@ interface ProducerConfig {
|
|
|
83
83
|
/**
|
|
84
84
|
* Configuration for consumer tracing
|
|
85
85
|
*/
|
|
86
|
-
interface ConsumerConfig {
|
|
86
|
+
interface ConsumerConfig<TMessage = unknown> {
|
|
87
87
|
/** Messaging system (kafka, rabbitmq, sqs, etc.) */
|
|
88
88
|
system: MessagingSystem;
|
|
89
89
|
/** Destination name (topic/queue) */
|
|
@@ -91,7 +91,7 @@ interface ConsumerConfig {
|
|
|
91
91
|
/** Consumer group name */
|
|
92
92
|
consumerGroup?: string;
|
|
93
93
|
/** Extract headers from message for link creation */
|
|
94
|
-
headersFrom?: string | ((msg:
|
|
94
|
+
headersFrom?: string | ((msg: TMessage) => Record<string, string> | undefined);
|
|
95
95
|
/** Enable batch mode - extract links from all messages */
|
|
96
96
|
batchMode?: boolean;
|
|
97
97
|
/** Extract baggage from message headers */
|
|
@@ -99,7 +99,7 @@ interface ConsumerConfig {
|
|
|
99
99
|
/** Additional attributes to set on span */
|
|
100
100
|
attributes?: Attributes;
|
|
101
101
|
/** Consumer lag metrics extraction */
|
|
102
|
-
lagMetrics?: LagMetricsConfig
|
|
102
|
+
lagMetrics?: LagMetricsConfig<TMessage>;
|
|
103
103
|
/** Callback when message goes to DLQ */
|
|
104
104
|
onDLQ?: (ctx: ConsumerContext, reason: string) => void;
|
|
105
105
|
/** Callback on error */
|
|
@@ -121,7 +121,7 @@ interface ConsumerConfig {
|
|
|
121
121
|
* }
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
|
-
ordering?: OrderingConfig
|
|
124
|
+
ordering?: OrderingConfig<TMessage>;
|
|
125
125
|
/**
|
|
126
126
|
* Consumer group tracking configuration
|
|
127
127
|
*
|
|
@@ -168,7 +168,7 @@ interface ConsumerConfig {
|
|
|
168
168
|
* })
|
|
169
169
|
* ```
|
|
170
170
|
*/
|
|
171
|
-
customAttributes?: (ctx: ConsumerContext, msg:
|
|
171
|
+
customAttributes?: (ctx: ConsumerContext, msg: TMessage) => Attributes;
|
|
172
172
|
/**
|
|
173
173
|
* Hook for custom context extraction (beyond W3C traceparent)
|
|
174
174
|
*
|
|
@@ -209,20 +209,20 @@ interface ConsumerConfig {
|
|
|
209
209
|
/**
|
|
210
210
|
* Configuration for consumer lag metrics
|
|
211
211
|
*/
|
|
212
|
-
interface LagMetricsConfig {
|
|
212
|
+
interface LagMetricsConfig<TMessage = unknown> {
|
|
213
213
|
/** Get current message offset */
|
|
214
|
-
getCurrentOffset?: (msg:
|
|
214
|
+
getCurrentOffset?: (msg: TMessage) => number | undefined;
|
|
215
215
|
/** Get end offset (high watermark) - can be async */
|
|
216
216
|
getEndOffset?: () => number | Promise<number>;
|
|
217
217
|
/** Get committed offset - can be async */
|
|
218
218
|
getCommittedOffset?: () => number | Promise<number>;
|
|
219
219
|
/** Get partition from message */
|
|
220
|
-
getPartition?: (msg:
|
|
220
|
+
getPartition?: (msg: TMessage) => number | undefined;
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* Configuration for message ordering tracking
|
|
224
224
|
*/
|
|
225
|
-
interface OrderingConfig {
|
|
225
|
+
interface OrderingConfig<TMessage = unknown> {
|
|
226
226
|
/**
|
|
227
227
|
* Extract sequence number from message
|
|
228
228
|
*
|
|
@@ -233,7 +233,7 @@ interface OrderingConfig {
|
|
|
233
233
|
* sequenceFrom: (msg) => msg.offset
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
|
-
sequenceFrom?: (msg:
|
|
236
|
+
sequenceFrom?: (msg: TMessage) => number | undefined;
|
|
237
237
|
/**
|
|
238
238
|
* Extract partition key from message
|
|
239
239
|
*
|
|
@@ -244,7 +244,7 @@ interface OrderingConfig {
|
|
|
244
244
|
* partitionKeyFrom: (msg) => msg.key
|
|
245
245
|
* ```
|
|
246
246
|
*/
|
|
247
|
-
partitionKeyFrom?: (msg:
|
|
247
|
+
partitionKeyFrom?: (msg: TMessage) => string | undefined;
|
|
248
248
|
/**
|
|
249
249
|
* Extract message ID for deduplication
|
|
250
250
|
*
|
|
@@ -255,7 +255,7 @@ interface OrderingConfig {
|
|
|
255
255
|
* messageIdFrom: (msg) => msg.headers['idempotency-key']
|
|
256
256
|
* ```
|
|
257
257
|
*/
|
|
258
|
-
messageIdFrom?: (msg:
|
|
258
|
+
messageIdFrom?: (msg: TMessage) => string | undefined;
|
|
259
259
|
/**
|
|
260
260
|
* Enable out-of-order detection
|
|
261
261
|
*
|
|
@@ -499,6 +499,11 @@ interface DLQReplayOptions {
|
|
|
499
499
|
/**
|
|
500
500
|
* Extended trace context for producers with header injection
|
|
501
501
|
*/
|
|
502
|
+
/** The W3C trace context headers a producer attaches to a message. */
|
|
503
|
+
interface TraceHeaders {
|
|
504
|
+
traceparent: string;
|
|
505
|
+
tracestate?: string;
|
|
506
|
+
}
|
|
502
507
|
interface ProducerContext extends TraceContext {
|
|
503
508
|
/**
|
|
504
509
|
* Get W3C trace context headers to inject into message
|
|
@@ -514,10 +519,7 @@ interface ProducerContext extends TraceContext {
|
|
|
514
519
|
* });
|
|
515
520
|
* ```
|
|
516
521
|
*/
|
|
517
|
-
getTraceHeaders():
|
|
518
|
-
traceparent: string;
|
|
519
|
-
tracestate?: string;
|
|
520
|
-
};
|
|
522
|
+
getTraceHeaders(): TraceHeaders;
|
|
521
523
|
/**
|
|
522
524
|
* Get all propagation headers including baggage if enabled
|
|
523
525
|
*
|
|
@@ -700,49 +702,6 @@ interface ConsumerContext extends TraceContext {
|
|
|
700
702
|
*/
|
|
701
703
|
getAssignedPartitions(): PartitionAssignment[];
|
|
702
704
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Create a traced message producer function
|
|
705
|
-
*
|
|
706
|
-
* Sets SpanKind.PRODUCER, OTel messaging semantic attributes,
|
|
707
|
-
* and provides context injection helpers.
|
|
708
|
-
*
|
|
709
|
-
* @param config - Producer configuration
|
|
710
|
-
* @returns Factory function that wraps your producer logic
|
|
711
|
-
*
|
|
712
|
-
* @example Kafka producer
|
|
713
|
-
* ```typescript
|
|
714
|
-
* export const publishUserEvent = traceProducer({
|
|
715
|
-
* system: 'kafka',
|
|
716
|
-
* destination: 'user-events',
|
|
717
|
-
* messageIdFrom: (args) => args[0]?.eventId,
|
|
718
|
-
* })(ctx => async (event: UserEvent) => {
|
|
719
|
-
* const headers = ctx.getTraceHeaders();
|
|
720
|
-
* await producer.send({
|
|
721
|
-
* topic: 'user-events',
|
|
722
|
-
* messages: [{
|
|
723
|
-
* key: event.userId,
|
|
724
|
-
* value: JSON.stringify(event),
|
|
725
|
-
* headers,
|
|
726
|
-
* }]
|
|
727
|
-
* });
|
|
728
|
-
* });
|
|
729
|
-
* ```
|
|
730
|
-
*
|
|
731
|
-
* @example SQS producer
|
|
732
|
-
* ```typescript
|
|
733
|
-
* export const sendToSQS = traceProducer({
|
|
734
|
-
* system: 'sqs',
|
|
735
|
-
* destination: 'orders-queue',
|
|
736
|
-
* })(ctx => async (order: Order) => {
|
|
737
|
-
* const headers = ctx.getAllPropagationHeaders();
|
|
738
|
-
* await sqs.sendMessage({
|
|
739
|
-
* QueueUrl: QUEUE_URL,
|
|
740
|
-
* MessageBody: JSON.stringify(order),
|
|
741
|
-
* MessageAttributes: headersToSQSAttributes(headers),
|
|
742
|
-
* });
|
|
743
|
-
* });
|
|
744
|
-
* ```
|
|
745
|
-
*/
|
|
746
705
|
declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ProducerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
747
706
|
/**
|
|
748
707
|
* Create a traced message consumer function
|
|
@@ -812,10 +771,10 @@ declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[]
|
|
|
812
771
|
* });
|
|
813
772
|
* ```
|
|
814
773
|
*/
|
|
815
|
-
declare function traceConsumer(
|
|
774
|
+
declare function traceConsumer<TMessage = unknown>(typedConfig: ConsumerConfig<TMessage>): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ConsumerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
816
775
|
/**
|
|
817
776
|
* Clear sequence tracking state (useful for testing)
|
|
818
777
|
*/
|
|
819
778
|
declare function clearOrderingState(): void;
|
|
820
779
|
//#endregion
|
|
821
|
-
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, clearOrderingState, traceConsumer, traceProducer };
|
|
780
|
+
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, TraceHeaders, clearOrderingState, traceConsumer, traceProducer };
|
package/dist/messaging.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { _ as readProperty, b as toAttributeValue, c as asScalar, g as nonEmptyString, h as isFunction, s as asRecord, v as resolveValue, y as splitNameOrOptions } from "./values-BenyvWKz.js";
|
|
1
2
|
import { createLinkFromHeaders, extractLinksFromBatch } from "./sampling.js";
|
|
2
|
-
import { c as withTracing } from "./functional-
|
|
3
|
-
import { t as emitCorrelatedEvent } from "./correlated-events-
|
|
3
|
+
import { c as withTracing } from "./functional-uSbNnnxK.js";
|
|
4
|
+
import { t as emitCorrelatedEvent } from "./correlated-events-DwMMbItg.js";
|
|
4
5
|
import { t as assertTraceFactory } from "./trace-factory-validation-BjVAinz6.js";
|
|
5
6
|
import { SpanKind, context, propagation } from "@opentelemetry/api";
|
|
6
7
|
|
|
@@ -90,10 +91,22 @@ import { SpanKind, context, propagation } from "@opentelemetry/api";
|
|
|
90
91
|
* });
|
|
91
92
|
* ```
|
|
92
93
|
*/
|
|
94
|
+
/** The Error an onError callback expects, wrapping a non-Error rejection. */
|
|
95
|
+
function toError(cause) {
|
|
96
|
+
return cause instanceof Error ? cause : new Error(String(cause));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check a config a JavaScript caller may have built by hand. TypeScript has
|
|
100
|
+
* already checked it for everyone else, so this only has to catch the shapes
|
|
101
|
+
* that reach here untyped.
|
|
102
|
+
*/
|
|
103
|
+
function assertMessagingConfig(fn, config) {
|
|
104
|
+
const record = asRecord(config);
|
|
105
|
+
if (!record) throw new TypeError(`${fn}: config must be an object`);
|
|
106
|
+
for (const field of ["system", "destination"]) if (nonEmptyString(record[field]) === void 0) throw new TypeError(`${fn}: config.${field} must be a non-empty string`);
|
|
107
|
+
}
|
|
93
108
|
function traceProducer(config) {
|
|
94
|
-
|
|
95
|
-
if (typeof config.system !== "string" || config.system.trim() === "") throw new TypeError("traceProducer: config.system must be a non-empty string");
|
|
96
|
-
if (typeof config.destination !== "string" || config.destination.trim() === "") throw new TypeError("traceProducer: config.destination must be a non-empty string");
|
|
109
|
+
assertMessagingConfig("traceProducer", config);
|
|
97
110
|
const spanName = `publish ${config.destination}`;
|
|
98
111
|
return (fnFactory) => {
|
|
99
112
|
assertTraceFactory("traceProducer", fnFactory);
|
|
@@ -113,7 +126,7 @@ function traceProducer(config) {
|
|
|
113
126
|
const userFn = fnFactory(ctx);
|
|
114
127
|
assertTraceFactory("traceProducer", userFn, "result");
|
|
115
128
|
return Promise.resolve(userFn(...args)).catch((error) => {
|
|
116
|
-
if (config.onError) config.onError(error, ctx);
|
|
129
|
+
if (config.onError) config.onError(toError(error), ctx);
|
|
117
130
|
throw error;
|
|
118
131
|
});
|
|
119
132
|
};
|
|
@@ -188,10 +201,9 @@ function traceProducer(config) {
|
|
|
188
201
|
* });
|
|
189
202
|
* ```
|
|
190
203
|
*/
|
|
191
|
-
function traceConsumer(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (typeof config.destination !== "string" || config.destination.trim() === "") throw new TypeError("traceConsumer: config.destination must be a non-empty string");
|
|
204
|
+
function traceConsumer(typedConfig) {
|
|
205
|
+
const config = typedConfig;
|
|
206
|
+
assertMessagingConfig("traceConsumer", config);
|
|
195
207
|
const spanName = `${config.batchMode ? "receive" : "process"} ${config.destination}`;
|
|
196
208
|
return (fnFactory) => {
|
|
197
209
|
assertTraceFactory("traceConsumer", fnFactory);
|
|
@@ -208,15 +220,16 @@ function traceConsumer(config) {
|
|
|
208
220
|
outOfOrderInfo: null
|
|
209
221
|
};
|
|
210
222
|
const groupTracking = config.consumerGroupTracking;
|
|
211
|
-
const
|
|
212
|
-
memberId:
|
|
213
|
-
groupInstanceId:
|
|
223
|
+
const groupState = {
|
|
224
|
+
memberId: resolveValue(groupTracking?.memberId) ?? null,
|
|
225
|
+
groupInstanceId: resolveValue(groupTracking?.groupInstanceId) ?? null,
|
|
214
226
|
assignedPartitions: [],
|
|
215
227
|
generation: null,
|
|
216
228
|
isActive: true,
|
|
217
229
|
lastHeartbeat: null,
|
|
218
230
|
state: null
|
|
219
|
-
}
|
|
231
|
+
};
|
|
232
|
+
const ctx = extendContextForConsumer(baseCtx, config, linkStorage, orderingState, groupState);
|
|
220
233
|
setConsumerAttributes(ctx, config);
|
|
221
234
|
return async (...args) => {
|
|
222
235
|
await extractAndAddLinks(ctx, config, args, linkStorage);
|
|
@@ -233,7 +246,7 @@ function traceConsumer(config) {
|
|
|
233
246
|
const userFn = fnFactory(ctx);
|
|
234
247
|
assertTraceFactory("traceConsumer", userFn, "result");
|
|
235
248
|
return Promise.resolve(userFn(...args)).catch((error) => {
|
|
236
|
-
if (config.onError) config.onError(error, ctx);
|
|
249
|
+
if (config.onError) config.onError(toError(error), ctx);
|
|
237
250
|
throw error;
|
|
238
251
|
});
|
|
239
252
|
};
|
|
@@ -306,12 +319,8 @@ function extendContextForConsumer(baseCtx, config, linkStorage, orderingState, g
|
|
|
306
319
|
const consumerCtx = {
|
|
307
320
|
...baseCtx,
|
|
308
321
|
recordDLQ(reason, dlqNameOrOptions, optionsParam) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (typeof dlqNameOrOptions === "string") {
|
|
312
|
-
dlqName = dlqNameOrOptions;
|
|
313
|
-
options = optionsParam;
|
|
314
|
-
} else if (typeof dlqNameOrOptions === "object") options = dlqNameOrOptions;
|
|
322
|
+
const { name: dlqName, options: inlineOptions } = splitNameOrOptions(dlqNameOrOptions);
|
|
323
|
+
const options = dlqName === void 0 ? inlineOptions : optionsParam;
|
|
315
324
|
const linkToProducer = options?.linkToProducer ?? true;
|
|
316
325
|
baseCtx.setAttribute("messaging.dlq.reason", reason);
|
|
317
326
|
if (dlqName) baseCtx.setAttribute("messaging.dlq.name", dlqName);
|
|
@@ -604,29 +613,23 @@ async function extractLagMetrics(ctx, lagConfig, args) {
|
|
|
604
613
|
* Extract headers from message using config
|
|
605
614
|
*/
|
|
606
615
|
function extractHeaders(headersFrom, msg) {
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
const value = msg[headersFrom];
|
|
610
|
-
if (typeof value === "object" && value !== null) return value;
|
|
611
|
-
}
|
|
616
|
+
if (isFunction(headersFrom)) return headersFrom(msg);
|
|
617
|
+
return asRecord(readProperty(msg, headersFrom));
|
|
612
618
|
}
|
|
613
619
|
/**
|
|
614
620
|
* Extract value from arguments using config
|
|
615
621
|
*/
|
|
616
622
|
function extractValue(extractor, args) {
|
|
617
|
-
|
|
618
|
-
const firstArg = args[0];
|
|
619
|
-
if (typeof firstArg === "object" && firstArg !== null) return firstArg[extractor];
|
|
623
|
+
return isFunction(extractor) ? extractor(args) : asScalar(readProperty(args[0], extractor));
|
|
620
624
|
}
|
|
621
625
|
/**
|
|
622
626
|
* Set custom attributes on context, handling non-primitive values
|
|
623
627
|
*/
|
|
624
628
|
function setCustomAttributes(ctx, attributes) {
|
|
625
|
-
for (const [key, value] of Object.entries(attributes))
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
} else ctx.setAttribute(key, JSON.stringify(value));
|
|
629
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
630
|
+
const attribute = toAttributeValue(value);
|
|
631
|
+
if (attribute !== void 0) ctx.setAttribute(key, attribute);
|
|
632
|
+
}
|
|
630
633
|
}
|
|
631
634
|
/**
|
|
632
635
|
* Extract and process ordering information from message
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as FunnelStatus, l as OutcomeStatus, r as EventAttributes } from "./event-subscriber-DMACQA-1.cjs";
|
|
2
2
|
//#region src/metric-testing.d.ts
|
|
3
3
|
interface MetricsEvent {
|
|
4
4
|
event: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as FunnelStatus, l as OutcomeStatus, r as EventAttributes } from "./event-subscriber-DMACQA-1.js";
|
|
2
2
|
//#region src/metric-testing.d.ts
|
|
3
3
|
interface MetricsEvent {
|
|
4
4
|
event: string;
|