autotel 3.5.0 → 3.7.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/dist/attribute-redacting-processor-DtTS9xxh.d.cts +175 -0
- package/dist/attribute-redacting-processor-DtTS9xxh.d.cts.map +1 -0
- package/dist/attribute-redacting-processor-DtTS9xxh.d.ts +175 -0
- package/dist/attribute-redacting-processor-DtTS9xxh.d.ts.map +1 -0
- package/dist/attribute-redacting-processor.cjs +374 -33
- package/dist/attribute-redacting-processor.cjs.map +1 -1
- package/dist/attribute-redacting-processor.d.cts +2 -207
- package/dist/attribute-redacting-processor.d.ts +2 -207
- package/dist/attribute-redacting-processor.js +368 -2
- package/dist/attribute-redacting-processor.js.map +1 -1
- package/dist/attributes-D3etyRVc.cjs +713 -0
- package/dist/attributes-D3etyRVc.cjs.map +1 -0
- package/dist/attributes-ksn4HVbd.js +600 -0
- package/dist/attributes-ksn4HVbd.js.map +1 -0
- package/dist/attributes.cjs +21 -85
- package/dist/attributes.d.cts +2 -20
- package/dist/attributes.d.ts +2 -20
- package/dist/attributes.js +3 -5
- package/dist/auto.cjs +50 -28
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.d.cts +1 -2
- package/dist/auto.d.ts +1 -2
- package/dist/auto.js +49 -23
- package/dist/auto.js.map +1 -1
- package/dist/business-baggage.cjs +357 -13
- package/dist/business-baggage.cjs.map +1 -1
- package/dist/business-baggage.d.cts +106 -139
- package/dist/business-baggage.d.cts.map +1 -0
- package/dist/business-baggage.d.ts +106 -139
- package/dist/business-baggage.d.ts.map +1 -0
- package/dist/business-baggage.js +357 -2
- package/dist/business-baggage.js.map +1 -1
- package/dist/canonical-log-line-processor--RlFDHhm.cjs +377 -0
- package/dist/canonical-log-line-processor--RlFDHhm.cjs.map +1 -0
- package/dist/canonical-log-line-processor-BcRuAdRk.d.ts +147 -0
- package/dist/canonical-log-line-processor-BcRuAdRk.d.ts.map +1 -0
- package/dist/canonical-log-line-processor-DbBQT5vY.js +366 -0
- package/dist/canonical-log-line-processor-DbBQT5vY.js.map +1 -0
- package/dist/canonical-log-line-processor-xvjMgtpF.d.cts +147 -0
- package/dist/canonical-log-line-processor-xvjMgtpF.d.cts.map +1 -0
- package/dist/config.cjs +118 -22
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +33 -45
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.ts +33 -45
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +116 -3
- package/dist/config.js.map +1 -1
- package/dist/correlated-events-Bzh5y-UB.js +28 -0
- package/dist/correlated-events-Bzh5y-UB.js.map +1 -0
- package/dist/correlated-events-kSwLo3mi.cjs +34 -0
- package/dist/correlated-events-kSwLo3mi.cjs.map +1 -0
- package/dist/correlation-id.cjs +11 -53
- package/dist/correlation-id.d.cts +6 -5
- package/dist/correlation-id.d.cts.map +1 -0
- package/dist/correlation-id.d.ts +6 -5
- package/dist/correlation-id.d.ts.map +1 -0
- package/dist/correlation-id.js +3 -16
- package/dist/db.cjs +244 -209
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +28 -26
- package/dist/db.d.cts.map +1 -0
- package/dist/db.d.ts +28 -26
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +243 -207
- package/dist/db.js.map +1 -1
- package/dist/decorators.cjs +39 -65
- package/dist/decorators.cjs.map +1 -1
- package/dist/decorators.d.cts +10 -37
- package/dist/decorators.d.cts.map +1 -0
- package/dist/decorators.d.ts +10 -37
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +38 -63
- package/dist/decorators.js.map +1 -1
- package/dist/define-event-CreknLm3.d.ts +25 -0
- package/dist/define-event-CreknLm3.d.ts.map +1 -0
- package/dist/define-event-HZRizPwz.d.cts +25 -0
- package/dist/define-event-HZRizPwz.d.cts.map +1 -0
- package/dist/drain-pipeline.cjs +111 -9
- package/dist/drain-pipeline.cjs.map +1 -1
- package/dist/drain-pipeline.d.cts +27 -32
- package/dist/drain-pipeline.d.cts.map +1 -0
- package/dist/drain-pipeline.d.ts +27 -32
- package/dist/drain-pipeline.d.ts.map +1 -0
- package/dist/drain-pipeline.js +111 -2
- package/dist/drain-pipeline.js.map +1 -1
- package/dist/enrichers.cjs +59 -66
- package/dist/enrichers.cjs.map +1 -1
- package/dist/enrichers.d.cts +15 -13
- package/dist/enrichers.d.cts.map +1 -0
- package/dist/enrichers.d.ts +15 -13
- package/dist/enrichers.d.ts.map +1 -0
- package/dist/enrichers.js +58 -65
- package/dist/enrichers.js.map +1 -1
- package/dist/event-Dlqr4ZNL.cjs +778 -0
- package/dist/event-Dlqr4ZNL.cjs.map +1 -0
- package/dist/event-_58ryBjh.js +761 -0
- package/dist/event-_58ryBjh.js.map +1 -0
- package/dist/event-subscriber-D1XLkPzi.d.cts +223 -0
- package/dist/event-subscriber-D1XLkPzi.d.cts.map +1 -0
- package/dist/event-subscriber-D1XLkPzi.d.ts +223 -0
- package/dist/event-subscriber-D1XLkPzi.d.ts.map +1 -0
- package/dist/event-subscriber.cjs +0 -6
- package/dist/event-subscriber.d.cts +2 -221
- package/dist/event-subscriber.d.ts +2 -221
- package/dist/event-subscriber.js +1 -3
- package/dist/event-testing-BqRnI0z4.d.cts +106 -0
- package/dist/event-testing-BqRnI0z4.d.cts.map +1 -0
- package/dist/event-testing-CfFs3to2.d.ts +106 -0
- package/dist/event-testing-CfFs3to2.d.ts.map +1 -0
- package/dist/event-testing.cjs +93 -17
- package/dist/event-testing.cjs.map +1 -1
- package/dist/event-testing.d.cts +2 -110
- package/dist/event-testing.d.ts +2 -110
- package/dist/event-testing.js +91 -2
- package/dist/event-testing.js.map +1 -1
- package/dist/event.cjs +5 -36
- package/dist/event.d.cts +295 -340
- package/dist/event.d.cts.map +1 -0
- package/dist/event.d.ts +295 -340
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +3 -20
- package/dist/exporters.cjs +12 -16
- package/dist/exporters.d.cts +86 -111
- package/dist/exporters.d.cts.map +1 -0
- package/dist/exporters.d.ts +86 -111
- package/dist/exporters.d.ts.map +1 -0
- package/dist/exporters.js +4 -4
- package/dist/filtering-span-processor-B8R8B7Uk.d.cts +59 -0
- package/dist/filtering-span-processor-B8R8B7Uk.d.cts.map +1 -0
- package/dist/filtering-span-processor-B8R8B7Uk.d.ts +59 -0
- package/dist/filtering-span-processor-B8R8B7Uk.d.ts.map +1 -0
- package/dist/filtering-span-processor.cjs +49 -9
- package/dist/filtering-span-processor.cjs.map +1 -1
- package/dist/filtering-span-processor.d.cts +2 -80
- package/dist/filtering-span-processor.d.ts +2 -80
- package/dist/filtering-span-processor.js +49 -2
- package/dist/filtering-span-processor.js.map +1 -1
- package/dist/functional-BGkT8J-h.js +1265 -0
- package/dist/functional-BGkT8J-h.js.map +1 -0
- package/dist/functional-C4CzoVrX.cjs +1312 -0
- package/dist/functional-C4CzoVrX.cjs.map +1 -0
- package/dist/functional.cjs +11 -56
- package/dist/functional.d.cts +96 -97
- package/dist/functional.d.cts.map +1 -0
- package/dist/functional.d.ts +96 -97
- package/dist/functional.d.ts.map +1 -0
- package/dist/functional.js +3 -19
- package/dist/http.cjs +276 -175
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +17 -37
- package/dist/http.d.cts.map +1 -0
- package/dist/http.d.ts +17 -37
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +275 -173
- package/dist/http.js.map +1 -1
- package/dist/index-CX0aG1Uh.d.ts +708 -0
- package/dist/index-CX0aG1Uh.d.ts.map +1 -0
- package/dist/index-DIWZFKUS.d.cts +708 -0
- package/dist/index-DIWZFKUS.d.cts.map +1 -0
- package/dist/index.cjs +1050 -1184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +401 -570
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +401 -570
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +913 -725
- package/dist/index.js.map +1 -1
- package/dist/init-CNp-ee80.d.cts +1157 -0
- package/dist/init-CNp-ee80.d.cts.map +1 -0
- package/dist/init-Ch6t7MNI.js +1015 -0
- package/dist/init-Ch6t7MNI.js.map +1 -0
- package/dist/init-DJQOdVlN.d.ts +1157 -0
- package/dist/init-DJQOdVlN.d.ts.map +1 -0
- package/dist/init-DvapOXCc.cjs +1092 -0
- package/dist/init-DvapOXCc.cjs.map +1 -0
- package/dist/instrumentation.cjs +159 -185
- package/dist/instrumentation.cjs.map +1 -1
- package/dist/instrumentation.d.cts +42 -40
- package/dist/instrumentation.d.cts.map +1 -0
- package/dist/instrumentation.d.ts +42 -40
- package/dist/instrumentation.d.ts.map +1 -0
- package/dist/instrumentation.js +158 -183
- package/dist/instrumentation.js.map +1 -1
- package/dist/logger-BauSUhUv.d.cts +313 -0
- package/dist/logger-BauSUhUv.d.cts.map +1 -0
- package/dist/logger-BauSUhUv.d.ts +313 -0
- package/dist/logger-BauSUhUv.d.ts.map +1 -0
- package/dist/logger.cjs +225 -25
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +2 -348
- package/dist/logger.d.ts +2 -348
- package/dist/logger.js +204 -4
- package/dist/logger.js.map +1 -1
- package/dist/messaging-adapters.cjs +292 -187
- package/dist/messaging-adapters.cjs.map +1 -1
- package/dist/messaging-adapters.d.cts +28 -66
- package/dist/messaging-adapters.d.cts.map +1 -0
- package/dist/messaging-adapters.d.ts +28 -66
- package/dist/messaging-adapters.d.ts.map +1 -0
- package/dist/messaging-adapters.js +291 -185
- package/dist/messaging-adapters.js.map +1 -1
- package/dist/messaging-testing.cjs +306 -372
- package/dist/messaging-testing.cjs.map +1 -1
- package/dist/messaging-testing.d.cts +194 -223
- package/dist/messaging-testing.d.cts.map +1 -0
- package/dist/messaging-testing.d.ts +194 -223
- package/dist/messaging-testing.d.ts.map +1 -0
- package/dist/messaging-testing.js +305 -371
- package/dist/messaging-testing.js.map +1 -1
- package/dist/messaging.cjs +757 -35
- package/dist/messaging.cjs.map +1 -1
- package/dist/messaging.d.cts +603 -644
- package/dist/messaging.d.cts.map +1 -0
- package/dist/messaging.d.ts +603 -644
- package/dist/messaging.d.ts.map +1 -0
- package/dist/messaging.js +756 -20
- package/dist/messaging.js.map +1 -1
- package/dist/metric-helpers.cjs +27 -27
- package/dist/metric-helpers.cjs.map +1 -1
- package/dist/metric-helpers.d.cts +4 -2
- package/dist/metric-helpers.d.cts.map +1 -0
- package/dist/metric-helpers.d.ts +4 -2
- package/dist/metric-helpers.d.ts.map +1 -0
- package/dist/metric-helpers.js +24 -4
- package/dist/metric-helpers.js.map +1 -1
- package/dist/metric-testing-DXdK3-Q3.d.ts +106 -0
- package/dist/metric-testing-DXdK3-Q3.d.ts.map +1 -0
- package/dist/metric-testing-MxvzChDp.d.cts +106 -0
- package/dist/metric-testing-MxvzChDp.d.cts.map +1 -0
- package/dist/metric-testing.cjs +93 -17
- package/dist/metric-testing.cjs.map +1 -1
- package/dist/metric-testing.d.cts +2 -110
- package/dist/metric-testing.d.ts +2 -110
- package/dist/metric-testing.js +91 -2
- package/dist/metric-testing.js.map +1 -1
- package/dist/metric.cjs +306 -22
- package/dist/metric.cjs.map +1 -1
- package/dist/metric.d.cts +170 -198
- package/dist/metric.d.cts.map +1 -0
- package/dist/metric.d.ts +170 -198
- package/dist/metric.d.ts.map +1 -0
- package/dist/metric.js +277 -7
- package/dist/metric.js.map +1 -1
- package/dist/node-require-DF5QBX6z.cjs +99 -0
- package/dist/node-require-DF5QBX6z.cjs.map +1 -0
- package/dist/node-require-Db1oDpLj.js +88 -0
- package/dist/node-require-Db1oDpLj.js.map +1 -0
- package/dist/operation-context-C-2hmmtP.js +59 -0
- package/dist/operation-context-C-2hmmtP.js.map +1 -0
- package/dist/operation-context-n4_obUwq.cjs +70 -0
- package/dist/operation-context-n4_obUwq.cjs.map +1 -0
- package/dist/parse-error.cjs +55 -9
- package/dist/parse-error.cjs.map +1 -1
- package/dist/parse-error.d.cts +12 -10
- package/dist/parse-error.d.cts.map +1 -0
- package/dist/parse-error.d.ts +12 -10
- package/dist/parse-error.d.ts.map +1 -0
- package/dist/parse-error.js +55 -2
- package/dist/parse-error.js.map +1 -1
- package/dist/pretty-console-exporter-CMzlrRNg.cjs +232 -0
- package/dist/pretty-console-exporter-CMzlrRNg.cjs.map +1 -0
- package/dist/pretty-console-exporter-DqKl_q9z.js +227 -0
- package/dist/pretty-console-exporter-DqKl_q9z.js.map +1 -0
- package/dist/processors.cjs +13 -17
- package/dist/processors.d.cts +3 -171
- package/dist/processors.d.ts +3 -171
- package/dist/processors.js +4 -4
- package/dist/register.cjs +35 -6
- package/dist/register.cjs.map +1 -1
- package/dist/register.d.cts +1 -2
- package/dist/register.d.ts +1 -2
- package/dist/register.js +36 -3
- package/dist/register.js.map +1 -1
- package/dist/registry-DfXA3R1L.js +184 -0
- package/dist/registry-DfXA3R1L.js.map +1 -0
- package/dist/registry-JZg2J3RZ.cjs +334 -0
- package/dist/registry-JZg2J3RZ.cjs.map +1 -0
- package/dist/sampling-CR0Va1VB.d.ts +351 -0
- package/dist/sampling-CR0Va1VB.d.ts.map +1 -0
- package/dist/sampling-DfYhDJij.d.cts +351 -0
- package/dist/sampling-DfYhDJij.d.cts.map +1 -0
- package/dist/sampling.cjs +452 -60
- package/dist/sampling.cjs.map +1 -1
- package/dist/sampling.d.cts +2 -379
- package/dist/sampling.d.ts +2 -379
- package/dist/sampling.js +441 -5
- package/dist/sampling.js.map +1 -1
- package/dist/security-schema.cjs +65 -46
- package/dist/security-schema.cjs.map +1 -1
- package/dist/security-schema.d.cts +23 -26
- package/dist/security-schema.d.cts.map +1 -0
- package/dist/security-schema.d.ts +23 -26
- package/dist/security-schema.d.ts.map +1 -0
- package/dist/security-schema.js +64 -45
- package/dist/security-schema.js.map +1 -1
- package/dist/semantic-conventions-FhSxv-bK.d.cts +32 -0
- package/dist/semantic-conventions-FhSxv-bK.d.cts.map +1 -0
- package/dist/semantic-conventions-FhSxv-bK.d.ts +32 -0
- package/dist/semantic-conventions-FhSxv-bK.d.ts.map +1 -0
- package/dist/semantic-conventions.cjs +15 -26
- package/dist/semantic-conventions.cjs.map +1 -1
- package/dist/semantic-conventions.d.cts +2 -29
- package/dist/semantic-conventions.d.ts +2 -29
- package/dist/semantic-conventions.js +12 -3
- package/dist/semantic-conventions.js.map +1 -1
- package/dist/semantic-helpers.cjs +440 -38
- package/dist/semantic-helpers.cjs.map +1 -1
- package/dist/semantic-helpers.d.cts +38 -45
- package/dist/semantic-helpers.d.cts.map +1 -0
- package/dist/semantic-helpers.d.ts +38 -45
- package/dist/semantic-helpers.d.ts.map +1 -0
- package/dist/semantic-helpers.js +438 -19
- package/dist/semantic-helpers.js.map +1 -1
- package/dist/span-name-normalizer-8ZOGJuwv.d.cts +70 -0
- package/dist/span-name-normalizer-8ZOGJuwv.d.cts.map +1 -0
- package/dist/span-name-normalizer-8ZOGJuwv.d.ts +70 -0
- package/dist/span-name-normalizer-8ZOGJuwv.d.ts.map +1 -0
- package/dist/span-name-normalizer.cjs +95 -17
- package/dist/span-name-normalizer.cjs.map +1 -1
- package/dist/span-name-normalizer.d.cts +2 -94
- package/dist/span-name-normalizer.d.ts +2 -94
- package/dist/span-name-normalizer.js +93 -2
- package/dist/span-name-normalizer.js.map +1 -1
- package/dist/stable-hash-BNTMrmdB.cjs +28 -0
- package/dist/stable-hash-BNTMrmdB.cjs.map +1 -0
- package/dist/stable-hash-Cg5cT34Q.js +23 -0
- package/dist/stable-hash-Cg5cT34Q.js.map +1 -0
- package/dist/structured-error-9--cxBay.js +143 -0
- package/dist/structured-error-9--cxBay.js.map +1 -0
- package/dist/structured-error-CHg7DoIQ.cjs +178 -0
- package/dist/structured-error-CHg7DoIQ.cjs.map +1 -0
- package/dist/tail-sampling-processor.cjs +26 -13
- package/dist/tail-sampling-processor.cjs.map +1 -1
- package/dist/tail-sampling-processor.d.cts +11 -23
- package/dist/tail-sampling-processor.d.cts.map +1 -0
- package/dist/tail-sampling-processor.d.ts +11 -23
- package/dist/tail-sampling-processor.d.ts.map +1 -0
- package/dist/tail-sampling-processor.js +27 -6
- package/dist/tail-sampling-processor.js.map +1 -1
- package/dist/test-span-collector.cjs +70 -72
- package/dist/test-span-collector.cjs.map +1 -1
- package/dist/test-span-collector.d.cts +25 -43
- package/dist/test-span-collector.d.cts.map +1 -0
- package/dist/test-span-collector.d.ts +25 -43
- package/dist/test-span-collector.d.ts.map +1 -0
- package/dist/test-span-collector.js +69 -70
- package/dist/test-span-collector.js.map +1 -1
- package/dist/testing.cjs +389 -278
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +39 -62
- package/dist/testing.d.cts.map +1 -0
- package/dist/testing.d.ts +39 -62
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +386 -265
- package/dist/testing.js.map +1 -1
- package/dist/trace-context-Cijqoi6e.d.cts +212 -0
- package/dist/trace-context-Cijqoi6e.d.cts.map +1 -0
- package/dist/trace-context-Cijqoi6e.d.ts +212 -0
- package/dist/trace-context-Cijqoi6e.d.ts.map +1 -0
- package/dist/trace-helpers.cjs +634 -54
- package/dist/trace-helpers.cjs.map +1 -1
- package/dist/trace-helpers.d.cts +17 -49
- package/dist/trace-helpers.d.cts.map +1 -0
- package/dist/trace-helpers.d.ts +17 -49
- package/dist/trace-helpers.d.ts.map +1 -0
- package/dist/trace-helpers.js +624 -3
- package/dist/trace-helpers.js.map +1 -1
- package/dist/tracer-provider.cjs +227 -16
- package/dist/tracer-provider.cjs.map +1 -1
- package/dist/tracer-provider.d.cts +5 -4
- package/dist/tracer-provider.d.cts.map +1 -0
- package/dist/tracer-provider.d.ts +5 -4
- package/dist/tracer-provider.d.ts.map +1 -0
- package/dist/tracer-provider.js +227 -2
- package/dist/tracer-provider.js.map +1 -1
- package/dist/track-3HY4NGV-.cjs +1212 -0
- package/dist/track-3HY4NGV-.cjs.map +1 -0
- package/dist/track-nsKVy-pj.js +1111 -0
- package/dist/track-nsKVy-pj.js.map +1 -0
- package/dist/validate.cjs +201 -0
- package/dist/validate.cjs.map +1 -0
- package/dist/validate.d.cts +105 -0
- package/dist/validate.d.cts.map +1 -0
- package/dist/validate.d.ts +105 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +197 -0
- package/dist/validate.js.map +1 -0
- package/dist/validation-attributes.cjs +45 -0
- package/dist/validation-attributes.cjs.map +1 -0
- package/dist/validation-attributes.d.cts +33 -0
- package/dist/validation-attributes.d.cts.map +1 -0
- package/dist/validation-attributes.d.ts +33 -0
- package/dist/validation-attributes.d.ts.map +1 -0
- package/dist/validation-attributes.js +41 -0
- package/dist/validation-attributes.js.map +1 -0
- package/dist/webhook.cjs +286 -255
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +157 -192
- package/dist/webhook.d.cts.map +1 -0
- package/dist/webhook.d.ts +157 -192
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +285 -253
- package/dist/webhook.js.map +1 -1
- package/dist/workflow-distributed.cjs +498 -411
- package/dist/workflow-distributed.cjs.map +1 -1
- package/dist/workflow-distributed.d.cts +163 -173
- package/dist/workflow-distributed.d.cts.map +1 -0
- package/dist/workflow-distributed.d.ts +163 -173
- package/dist/workflow-distributed.d.ts.map +1 -0
- package/dist/workflow-distributed.js +497 -409
- package/dist/workflow-distributed.js.map +1 -1
- package/dist/workflow.cjs +405 -39
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +78 -131
- package/dist/workflow.d.cts.map +1 -0
- package/dist/workflow.d.ts +78 -131
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +403 -20
- package/dist/workflow.js.map +1 -1
- package/dist/yaml-config-B3dQ82GR.cjs +272 -0
- package/dist/yaml-config-B3dQ82GR.cjs.map +1 -0
- package/dist/yaml-config.cjs +5 -24
- package/dist/yaml-config.d.cts +30 -64
- package/dist/yaml-config.d.cts.map +1 -0
- package/dist/yaml-config.d.ts +30 -64
- package/dist/yaml-config.d.ts.map +1 -0
- package/dist/yaml-config.js +226 -7
- package/dist/yaml-config.js.map +1 -1
- package/package.json +14 -4
- package/src/define-event.ts +2 -21
- package/src/index.ts +3 -0
- package/src/request-logger.test.ts +53 -1
- package/src/request-logger.ts +58 -0
- package/src/stable-hash.ts +27 -0
- package/src/validate.test.ts +287 -0
- package/src/validate.ts +307 -0
- package/src/validation-attributes.ts +43 -0
- package/dist/attributes.cjs.map +0 -1
- package/dist/attributes.js.map +0 -1
- package/dist/chunk-2ZKEORFN.cjs +0 -14
- package/dist/chunk-2ZKEORFN.cjs.map +0 -1
- package/dist/chunk-3QXBFGKP.js +0 -344
- package/dist/chunk-3QXBFGKP.js.map +0 -1
- package/dist/chunk-454CH4OV.js +0 -744
- package/dist/chunk-454CH4OV.js.map +0 -1
- package/dist/chunk-4A53YIAX.js +0 -180
- package/dist/chunk-4A53YIAX.js.map +0 -1
- package/dist/chunk-4IFSYQVX.js +0 -337
- package/dist/chunk-4IFSYQVX.js.map +0 -1
- package/dist/chunk-4P6ZOARG.cjs +0 -33
- package/dist/chunk-4P6ZOARG.cjs.map +0 -1
- package/dist/chunk-55ER2KD5.js +0 -228
- package/dist/chunk-55ER2KD5.js.map +0 -1
- package/dist/chunk-5ZN622AO.js +0 -73
- package/dist/chunk-5ZN622AO.js.map +0 -1
- package/dist/chunk-6S5RUKU3.cjs +0 -347
- package/dist/chunk-6S5RUKU3.cjs.map +0 -1
- package/dist/chunk-6UQRVUN3.js +0 -222
- package/dist/chunk-6UQRVUN3.js.map +0 -1
- package/dist/chunk-7552UTQW.js +0 -11
- package/dist/chunk-7552UTQW.js.map +0 -1
- package/dist/chunk-7EQ4G4SI.cjs +0 -146
- package/dist/chunk-7EQ4G4SI.cjs.map +0 -1
- package/dist/chunk-7SAWIN74.js +0 -285
- package/dist/chunk-7SAWIN74.js.map +0 -1
- package/dist/chunk-A4E5AQFK.js +0 -30
- package/dist/chunk-A4E5AQFK.js.map +0 -1
- package/dist/chunk-AC5GNZKB.cjs +0 -344
- package/dist/chunk-AC5GNZKB.cjs.map +0 -1
- package/dist/chunk-ALPYR2GC.js +0 -1061
- package/dist/chunk-ALPYR2GC.js.map +0 -1
- package/dist/chunk-BZHG5IZ4.js +0 -73
- package/dist/chunk-BZHG5IZ4.js.map +0 -1
- package/dist/chunk-CEAQK2QY.cjs +0 -32
- package/dist/chunk-CEAQK2QY.cjs.map +0 -1
- package/dist/chunk-CMHVQR6P.js +0 -170
- package/dist/chunk-CMHVQR6P.js.map +0 -1
- package/dist/chunk-CU6IDACR.cjs +0 -224
- package/dist/chunk-CU6IDACR.cjs.map +0 -1
- package/dist/chunk-DPSA4QLA.js +0 -344
- package/dist/chunk-DPSA4QLA.js.map +0 -1
- package/dist/chunk-DQEHQNQE.js +0 -795
- package/dist/chunk-DQEHQNQE.js.map +0 -1
- package/dist/chunk-ESLWRGAG.cjs +0 -92
- package/dist/chunk-ESLWRGAG.cjs.map +0 -1
- package/dist/chunk-ESMHTKLJ.cjs +0 -206
- package/dist/chunk-ESMHTKLJ.cjs.map +0 -1
- package/dist/chunk-FGNDN2FD.cjs +0 -1242
- package/dist/chunk-FGNDN2FD.cjs.map +0 -1
- package/dist/chunk-FU6R566Y.cjs +0 -236
- package/dist/chunk-FU6R566Y.cjs.map +0 -1
- package/dist/chunk-GBFTC7Q7.cjs +0 -837
- package/dist/chunk-GBFTC7Q7.cjs.map +0 -1
- package/dist/chunk-GYR5K654.js +0 -91
- package/dist/chunk-GYR5K654.js.map +0 -1
- package/dist/chunk-HA2WBOGQ.js +0 -57
- package/dist/chunk-HA2WBOGQ.js.map +0 -1
- package/dist/chunk-HT5JQKN2.js +0 -118
- package/dist/chunk-HT5JQKN2.js.map +0 -1
- package/dist/chunk-INJD3G4K.cjs +0 -340
- package/dist/chunk-INJD3G4K.cjs.map +0 -1
- package/dist/chunk-IOYFAFHJ.cjs +0 -95
- package/dist/chunk-IOYFAFHJ.cjs.map +0 -1
- package/dist/chunk-J5QENANM.js +0 -87
- package/dist/chunk-J5QENANM.js.map +0 -1
- package/dist/chunk-J7VGRIAJ.js +0 -64
- package/dist/chunk-J7VGRIAJ.js.map +0 -1
- package/dist/chunk-KFOHQK7X.js +0 -144
- package/dist/chunk-KFOHQK7X.js.map +0 -1
- package/dist/chunk-KIL5CUN6.js +0 -31
- package/dist/chunk-KIL5CUN6.js.map +0 -1
- package/dist/chunk-LITNXTTT.js +0 -3
- package/dist/chunk-LITNXTTT.js.map +0 -1
- package/dist/chunk-M3LFHHTN.cjs +0 -764
- package/dist/chunk-M3LFHHTN.cjs.map +0 -1
- package/dist/chunk-NEIB3TLD.cjs +0 -360
- package/dist/chunk-NEIB3TLD.cjs.map +0 -1
- package/dist/chunk-NVAI5CCN.cjs +0 -39
- package/dist/chunk-NVAI5CCN.cjs.map +0 -1
- package/dist/chunk-NVGPMGI4.js +0 -95
- package/dist/chunk-NVGPMGI4.js.map +0 -1
- package/dist/chunk-NZ72VDNY.cjs +0 -4
- package/dist/chunk-NZ72VDNY.cjs.map +0 -1
- package/dist/chunk-O4JZUCUE.js +0 -1174
- package/dist/chunk-O4JZUCUE.js.map +0 -1
- package/dist/chunk-O7JOKRN2.js +0 -833
- package/dist/chunk-O7JOKRN2.js.map +0 -1
- package/dist/chunk-OPPXYVEZ.cjs +0 -131
- package/dist/chunk-OPPXYVEZ.cjs.map +0 -1
- package/dist/chunk-Q4EULJQY.js +0 -35
- package/dist/chunk-Q4EULJQY.js.map +0 -1
- package/dist/chunk-QWW3E3JM.cjs +0 -178
- package/dist/chunk-QWW3E3JM.cjs.map +0 -1
- package/dist/chunk-R7QYGZUP.cjs +0 -1075
- package/dist/chunk-R7QYGZUP.cjs.map +0 -1
- package/dist/chunk-RUPKBKUF.js +0 -352
- package/dist/chunk-RUPKBKUF.js.map +0 -1
- package/dist/chunk-SEO6NAQT.js +0 -14
- package/dist/chunk-SEO6NAQT.js.map +0 -1
- package/dist/chunk-T4B5LB6E.cjs +0 -66
- package/dist/chunk-T4B5LB6E.cjs.map +0 -1
- package/dist/chunk-TC5ZPWM4.cjs +0 -289
- package/dist/chunk-TC5ZPWM4.cjs.map +0 -1
- package/dist/chunk-TQ5UWA7S.js +0 -26
- package/dist/chunk-TQ5UWA7S.js.map +0 -1
- package/dist/chunk-URHPSJW2.js +0 -339
- package/dist/chunk-URHPSJW2.js.map +0 -1
- package/dist/chunk-UY3UYPBZ.cjs +0 -77
- package/dist/chunk-UY3UYPBZ.cjs.map +0 -1
- package/dist/chunk-VG2ABKJX.cjs +0 -100
- package/dist/chunk-VG2ABKJX.cjs.map +0 -1
- package/dist/chunk-VH77IPJN.cjs +0 -358
- package/dist/chunk-VH77IPJN.cjs.map +0 -1
- package/dist/chunk-VQTCQKHQ.cjs +0 -17
- package/dist/chunk-VQTCQKHQ.cjs.map +0 -1
- package/dist/chunk-WGWSHJ2N.js +0 -38
- package/dist/chunk-WGWSHJ2N.js.map +0 -1
- package/dist/chunk-WJH6IYU2.cjs +0 -32
- package/dist/chunk-WJH6IYU2.cjs.map +0 -1
- package/dist/chunk-YREV3LGG.cjs +0 -61
- package/dist/chunk-YREV3LGG.cjs.map +0 -1
- package/dist/chunk-YTXEZ4SD.cjs +0 -77
- package/dist/chunk-YTXEZ4SD.cjs.map +0 -1
- package/dist/chunk-YWCESU4Y.js +0 -1233
- package/dist/chunk-YWCESU4Y.js.map +0 -1
- package/dist/chunk-Z6HRSM2Y.cjs +0 -799
- package/dist/chunk-Z6HRSM2Y.cjs.map +0 -1
- package/dist/chunk-Z7PW3KHL.cjs +0 -1198
- package/dist/chunk-Z7PW3KHL.cjs.map +0 -1
- package/dist/chunk-ZNMBW67B.cjs +0 -40
- package/dist/chunk-ZNMBW67B.cjs.map +0 -1
- package/dist/correlation-id.cjs.map +0 -1
- package/dist/correlation-id.js.map +0 -1
- package/dist/event-subscriber.cjs.map +0 -1
- package/dist/event-subscriber.js.map +0 -1
- package/dist/event.cjs.map +0 -1
- package/dist/event.js.map +0 -1
- package/dist/exporters.cjs.map +0 -1
- package/dist/exporters.js.map +0 -1
- package/dist/functional.cjs.map +0 -1
- package/dist/functional.js.map +0 -1
- package/dist/init-DIowiiCh.d.ts +0 -1167
- package/dist/init-j-A1zI16.d.cts +0 -1167
- package/dist/processors.cjs.map +0 -1
- package/dist/processors.js.map +0 -1
- package/dist/trace-context-DbGKd1Rn.d.cts +0 -213
- package/dist/trace-context-DbGKd1Rn.d.ts +0 -213
- package/dist/utils-BahBCFtJ.d.cts +0 -712
- package/dist/utils-CLKwaUlG.d.ts +0 -712
- package/dist/yaml-config.cjs.map +0 -1
package/dist/messaging.js
CHANGED
|
@@ -1,21 +1,757 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import '
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { createLinkFromHeaders, extractLinksFromBatch } from "./sampling.js";
|
|
2
|
+
import { a as trace$1 } from "./functional-BGkT8J-h.js";
|
|
3
|
+
import { t as emitCorrelatedEvent } from "./correlated-events-Bzh5y-UB.js";
|
|
4
|
+
import { SpanKind, context, propagation } from "@opentelemetry/api";
|
|
5
|
+
|
|
6
|
+
//#region src/messaging.ts
|
|
7
|
+
/**
|
|
8
|
+
* Messaging helpers for event-driven architectures
|
|
9
|
+
*
|
|
10
|
+
* Provides specialized tracing for message producers and consumers
|
|
11
|
+
* with automatic context propagation, link extraction, and OTel
|
|
12
|
+
* semantic convention compliance.
|
|
13
|
+
*
|
|
14
|
+
* @example Producer
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { traceProducer } from 'autotel/messaging';
|
|
17
|
+
*
|
|
18
|
+
* export const publishEvent = traceProducer({
|
|
19
|
+
* system: 'kafka',
|
|
20
|
+
* destination: 'user-events',
|
|
21
|
+
* })(ctx => async (event: UserEvent) => {
|
|
22
|
+
* const headers = ctx.getTraceHeaders();
|
|
23
|
+
* await producer.send({
|
|
24
|
+
* topic: 'user-events',
|
|
25
|
+
* messages: [{ value: JSON.stringify(event), headers }]
|
|
26
|
+
* });
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Consumer
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { traceConsumer } from 'autotel/messaging';
|
|
33
|
+
*
|
|
34
|
+
* export const processEvents = traceConsumer({
|
|
35
|
+
* system: 'kafka',
|
|
36
|
+
* destination: 'user-events',
|
|
37
|
+
* consumerGroup: 'event-processor',
|
|
38
|
+
* batchMode: true,
|
|
39
|
+
* })(ctx => async (messages: KafkaMessage[]) => {
|
|
40
|
+
* // Links to producer spans are automatically extracted
|
|
41
|
+
* for (const msg of messages) {
|
|
42
|
+
* await processMessage(msg);
|
|
43
|
+
* }
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
/**
|
|
50
|
+
* Create a traced message producer function
|
|
51
|
+
*
|
|
52
|
+
* Sets SpanKind.PRODUCER, OTel messaging semantic attributes,
|
|
53
|
+
* and provides context injection helpers.
|
|
54
|
+
*
|
|
55
|
+
* @param config - Producer configuration
|
|
56
|
+
* @returns Factory function that wraps your producer logic
|
|
57
|
+
*
|
|
58
|
+
* @example Kafka producer
|
|
59
|
+
* ```typescript
|
|
60
|
+
* export const publishUserEvent = traceProducer({
|
|
61
|
+
* system: 'kafka',
|
|
62
|
+
* destination: 'user-events',
|
|
63
|
+
* messageIdFrom: (args) => args[0]?.eventId,
|
|
64
|
+
* })(ctx => async (event: UserEvent) => {
|
|
65
|
+
* const headers = ctx.getTraceHeaders();
|
|
66
|
+
* await producer.send({
|
|
67
|
+
* topic: 'user-events',
|
|
68
|
+
* messages: [{
|
|
69
|
+
* key: event.userId,
|
|
70
|
+
* value: JSON.stringify(event),
|
|
71
|
+
* headers,
|
|
72
|
+
* }]
|
|
73
|
+
* });
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example SQS producer
|
|
78
|
+
* ```typescript
|
|
79
|
+
* export const sendToSQS = traceProducer({
|
|
80
|
+
* system: 'sqs',
|
|
81
|
+
* destination: 'orders-queue',
|
|
82
|
+
* })(ctx => async (order: Order) => {
|
|
83
|
+
* const headers = ctx.getAllPropagationHeaders();
|
|
84
|
+
* await sqs.sendMessage({
|
|
85
|
+
* QueueUrl: QUEUE_URL,
|
|
86
|
+
* MessageBody: JSON.stringify(order),
|
|
87
|
+
* MessageAttributes: headersToSQSAttributes(headers),
|
|
88
|
+
* });
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
function traceProducer(config) {
|
|
93
|
+
const spanName = `${config.system}.publish ${config.destination}`;
|
|
94
|
+
return (fnFactory) => {
|
|
95
|
+
return trace$1({
|
|
96
|
+
name: spanName,
|
|
97
|
+
spanKind: SpanKind.PRODUCER
|
|
98
|
+
}, (baseCtx) => {
|
|
99
|
+
const ctx = extendContextForProducer(baseCtx, config);
|
|
100
|
+
setProducerAttributes(ctx, config);
|
|
101
|
+
return (...args) => {
|
|
102
|
+
setDynamicProducerAttributes(ctx, config, args);
|
|
103
|
+
if (config.customAttributes) {
|
|
104
|
+
const customAttrs = config.customAttributes(ctx, args);
|
|
105
|
+
for (const [key, value] of Object.entries(customAttrs)) if (value !== void 0 && value !== null) ctx.setAttribute(key, value);
|
|
106
|
+
}
|
|
107
|
+
if (config.beforeSend) config.beforeSend(ctx, args);
|
|
108
|
+
return fnFactory(ctx)(...args).catch((error) => {
|
|
109
|
+
if (config.onError) config.onError(error, ctx);
|
|
110
|
+
throw error;
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Create a traced message consumer function
|
|
118
|
+
*
|
|
119
|
+
* Sets SpanKind.CONSUMER, OTel messaging semantic attributes,
|
|
120
|
+
* automatically extracts links from producer trace headers,
|
|
121
|
+
* and provides DLQ/retry recording helpers.
|
|
122
|
+
*
|
|
123
|
+
* @param config - Consumer configuration
|
|
124
|
+
* @returns Factory function that wraps your consumer logic
|
|
125
|
+
*
|
|
126
|
+
* @example Kafka consumer (single message)
|
|
127
|
+
* ```typescript
|
|
128
|
+
* export const processUserEvent = traceConsumer({
|
|
129
|
+
* system: 'kafka',
|
|
130
|
+
* destination: 'user-events',
|
|
131
|
+
* consumerGroup: 'event-processor',
|
|
132
|
+
* headersFrom: (msg) => msg.headers,
|
|
133
|
+
* })(ctx => async (message: KafkaMessage) => {
|
|
134
|
+
* // Link to producer span is automatically created
|
|
135
|
+
* const event = JSON.parse(message.value.toString());
|
|
136
|
+
* await processEvent(event);
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* @example Kafka consumer (batch mode)
|
|
141
|
+
* ```typescript
|
|
142
|
+
* export const processUserEventBatch = traceConsumer({
|
|
143
|
+
* system: 'kafka',
|
|
144
|
+
* destination: 'user-events',
|
|
145
|
+
* consumerGroup: 'event-processor',
|
|
146
|
+
* batchMode: true,
|
|
147
|
+
* headersFrom: (msg) => msg.headers,
|
|
148
|
+
* lagMetrics: {
|
|
149
|
+
* getCurrentOffset: (msg) => msg.offset,
|
|
150
|
+
* getEndOffset: () => consumer.getHighWatermark(),
|
|
151
|
+
* getPartition: (msg) => msg.partition,
|
|
152
|
+
* },
|
|
153
|
+
* })(ctx => async (messages: KafkaMessage[]) => {
|
|
154
|
+
* // Links to all producer spans are automatically created
|
|
155
|
+
* for (const msg of messages) {
|
|
156
|
+
* await processEvent(JSON.parse(msg.value.toString()));
|
|
157
|
+
* }
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @example SQS consumer with DLQ handling
|
|
162
|
+
* ```typescript
|
|
163
|
+
* export const processSQSMessage = traceConsumer({
|
|
164
|
+
* system: 'sqs',
|
|
165
|
+
* destination: 'orders-queue',
|
|
166
|
+
* headersFrom: (msg) => sqsAttributesToHeaders(msg.MessageAttributes),
|
|
167
|
+
* onDLQ: (ctx, reason) => {
|
|
168
|
+
* ctx.recordDLQ(reason, 'orders-dlq');
|
|
169
|
+
* },
|
|
170
|
+
* })(ctx => async (message: SQSMessage) => {
|
|
171
|
+
* try {
|
|
172
|
+
* await processOrder(JSON.parse(message.Body));
|
|
173
|
+
* } catch (error) {
|
|
174
|
+
* if (message.ApproximateReceiveCount > 3) {
|
|
175
|
+
* ctx.recordDLQ(error.message);
|
|
176
|
+
* throw error;
|
|
177
|
+
* }
|
|
178
|
+
* ctx.recordRetry(message.ApproximateReceiveCount, 3);
|
|
179
|
+
* throw error;
|
|
180
|
+
* }
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
function traceConsumer(config) {
|
|
185
|
+
const operation = config.batchMode ? "receive" : "process";
|
|
186
|
+
const spanName = `${config.system}.${operation} ${config.destination}`;
|
|
187
|
+
return (fnFactory) => {
|
|
188
|
+
return trace$1({
|
|
189
|
+
name: spanName,
|
|
190
|
+
spanKind: SpanKind.CONSUMER
|
|
191
|
+
}, (baseCtx) => {
|
|
192
|
+
const linkStorage = { links: [] };
|
|
193
|
+
const orderingState = {
|
|
194
|
+
sequenceNumber: null,
|
|
195
|
+
partitionKey: null,
|
|
196
|
+
messageId: null,
|
|
197
|
+
isDuplicate: false,
|
|
198
|
+
outOfOrderInfo: null
|
|
199
|
+
};
|
|
200
|
+
const groupTracking = config.consumerGroupTracking;
|
|
201
|
+
const ctx = extendContextForConsumer(baseCtx, config, linkStorage, orderingState, {
|
|
202
|
+
memberId: typeof groupTracking?.memberId === "function" ? groupTracking.memberId() ?? null : groupTracking?.memberId ?? null,
|
|
203
|
+
groupInstanceId: typeof groupTracking?.groupInstanceId === "function" ? groupTracking.groupInstanceId() ?? null : groupTracking?.groupInstanceId ?? null,
|
|
204
|
+
assignedPartitions: [],
|
|
205
|
+
generation: null,
|
|
206
|
+
isActive: true,
|
|
207
|
+
lastHeartbeat: null,
|
|
208
|
+
state: null
|
|
209
|
+
});
|
|
210
|
+
setConsumerAttributes(ctx, config);
|
|
211
|
+
return async (...args) => {
|
|
212
|
+
await extractAndAddLinks(ctx, config, args, linkStorage);
|
|
213
|
+
if (config.ordering) extractAndProcessOrdering(ctx, config, args, orderingState);
|
|
214
|
+
if (config.lagMetrics) await extractLagMetrics(ctx, config.lagMetrics, args);
|
|
215
|
+
if (config.customAttributes) {
|
|
216
|
+
const batch = args[0];
|
|
217
|
+
const msg = config.batchMode && Array.isArray(batch) && batch.length > 0 ? batch[0] : batch;
|
|
218
|
+
if (msg !== void 0) {
|
|
219
|
+
const customAttrs = config.customAttributes(ctx, msg);
|
|
220
|
+
for (const [key, value] of Object.entries(customAttrs)) if (value !== void 0 && value !== null) ctx.setAttribute(key, value);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return fnFactory(ctx)(...args).catch((error) => {
|
|
224
|
+
if (config.onError) config.onError(error, ctx);
|
|
225
|
+
throw error;
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Extend base context with producer-specific methods
|
|
233
|
+
*/
|
|
234
|
+
function extendContextForProducer(baseCtx, config) {
|
|
235
|
+
const producerCtx = {
|
|
236
|
+
...baseCtx,
|
|
237
|
+
getTraceHeaders() {
|
|
238
|
+
const headers = {};
|
|
239
|
+
propagation.inject(context.active(), headers);
|
|
240
|
+
const result = { traceparent: headers["traceparent"] || "" };
|
|
241
|
+
if (headers["tracestate"]) result.tracestate = headers["tracestate"];
|
|
242
|
+
return result;
|
|
243
|
+
},
|
|
244
|
+
getAllPropagationHeaders() {
|
|
245
|
+
const headers = {};
|
|
246
|
+
propagation.inject(context.active(), headers);
|
|
247
|
+
if (config.propagateBaggage) {
|
|
248
|
+
const baggage = propagation.getBaggage(context.active());
|
|
249
|
+
if (baggage) {
|
|
250
|
+
const entries = [];
|
|
251
|
+
for (const [key, value] of baggage.getAllEntries()) entries.push(`${encodeURIComponent(key)}=${encodeURIComponent(value.value)}`);
|
|
252
|
+
if (entries.length > 0) headers["baggage"] = entries.join(",");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return headers;
|
|
256
|
+
},
|
|
257
|
+
getFullHeaders() {
|
|
258
|
+
const headers = producerCtx.getAllPropagationHeaders();
|
|
259
|
+
if (config.customHeaders) {
|
|
260
|
+
const customHeaders = config.customHeaders(producerCtx);
|
|
261
|
+
Object.assign(headers, customHeaders);
|
|
262
|
+
}
|
|
263
|
+
return headers;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
return producerCtx;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Global sequence tracker for out-of-order detection (per partition)
|
|
270
|
+
*/
|
|
271
|
+
const sequenceTrackers = /* @__PURE__ */ new Map();
|
|
272
|
+
/**
|
|
273
|
+
* Global deduplication window (LRU-style using Map insertion order)
|
|
274
|
+
*/
|
|
275
|
+
const deduplicationWindow = /* @__PURE__ */ new Map();
|
|
276
|
+
const DEFAULT_DEDUP_WINDOW_SIZE = 1e3;
|
|
277
|
+
/**
|
|
278
|
+
* Clean up old entries from deduplication window
|
|
279
|
+
*/
|
|
280
|
+
function trimDeduplicationWindow(maxSize) {
|
|
281
|
+
if (deduplicationWindow.size > maxSize) {
|
|
282
|
+
const excess = deduplicationWindow.size - maxSize;
|
|
283
|
+
const iterator = deduplicationWindow.keys();
|
|
284
|
+
for (let i = 0; i < excess; i++) {
|
|
285
|
+
const key = iterator.next().value;
|
|
286
|
+
if (key) deduplicationWindow.delete(key);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Extend base context with consumer-specific methods
|
|
292
|
+
*/
|
|
293
|
+
function extendContextForConsumer(baseCtx, config, linkStorage, orderingState, groupState) {
|
|
294
|
+
const consumerCtx = {
|
|
295
|
+
...baseCtx,
|
|
296
|
+
recordDLQ(reason, dlqNameOrOptions, optionsParam) {
|
|
297
|
+
let dlqName;
|
|
298
|
+
let options;
|
|
299
|
+
if (typeof dlqNameOrOptions === "string") {
|
|
300
|
+
dlqName = dlqNameOrOptions;
|
|
301
|
+
options = optionsParam;
|
|
302
|
+
} else if (typeof dlqNameOrOptions === "object") options = dlqNameOrOptions;
|
|
303
|
+
const linkToProducer = options?.linkToProducer ?? true;
|
|
304
|
+
baseCtx.setAttribute("messaging.dlq.reason", reason);
|
|
305
|
+
if (dlqName) baseCtx.setAttribute("messaging.dlq.name", dlqName);
|
|
306
|
+
if (options?.reasonCategory) baseCtx.setAttribute("messaging.dlq.reason_category", options.reasonCategory);
|
|
307
|
+
if (options?.attemptCount !== void 0) baseCtx.setAttribute("messaging.dlq.attempt_count", options.attemptCount);
|
|
308
|
+
if (options?.originalError) {
|
|
309
|
+
baseCtx.setAttribute("messaging.dlq.error.type", options.originalError.name);
|
|
310
|
+
baseCtx.setAttribute("messaging.dlq.error.message", options.originalError.message);
|
|
311
|
+
}
|
|
312
|
+
if (options?.metadata) for (const [key, value] of Object.entries(options.metadata)) baseCtx.setAttribute(`messaging.dlq.metadata.${key}`, value);
|
|
313
|
+
const producerLink = linkStorage.links[0];
|
|
314
|
+
if (linkToProducer && producerLink) {
|
|
315
|
+
baseCtx.setAttribute("messaging.dlq.producer_trace_id", producerLink.context.traceId);
|
|
316
|
+
baseCtx.setAttribute("messaging.dlq.producer_span_id", producerLink.context.spanId);
|
|
317
|
+
}
|
|
318
|
+
const eventAttrs = {
|
|
319
|
+
"messaging.dlq.reason": reason,
|
|
320
|
+
...dlqName && { "messaging.dlq.name": dlqName },
|
|
321
|
+
...options?.reasonCategory && { "messaging.dlq.reason_category": options.reasonCategory },
|
|
322
|
+
...options?.attemptCount !== void 0 && { "messaging.dlq.attempt_count": options.attemptCount },
|
|
323
|
+
...options?.originalError && {
|
|
324
|
+
"messaging.dlq.error.type": options.originalError.name,
|
|
325
|
+
"messaging.dlq.error.message": options.originalError.message
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
if (linkToProducer && producerLink) {
|
|
329
|
+
eventAttrs["messaging.dlq.producer_trace_id"] = producerLink.context.traceId;
|
|
330
|
+
eventAttrs["messaging.dlq.producer_span_id"] = producerLink.context.spanId;
|
|
331
|
+
}
|
|
332
|
+
emitCorrelatedEvent(baseCtx, "dlq_routed", eventAttrs);
|
|
333
|
+
if (config.onDLQ) config.onDLQ(consumerCtx, reason);
|
|
334
|
+
},
|
|
335
|
+
recordReplay(options) {
|
|
336
|
+
baseCtx.setAttribute("messaging.replay", true);
|
|
337
|
+
if (options?.replayAttempt !== void 0) baseCtx.setAttribute("messaging.replay.attempt", options.replayAttempt);
|
|
338
|
+
if (options?.dlqDwellTimeMs !== void 0) baseCtx.setAttribute("messaging.replay.dwell_time_ms", options.dlqDwellTimeMs);
|
|
339
|
+
if (options?.originalDLQSpanContext) baseCtx.addLinks([{
|
|
340
|
+
context: options.originalDLQSpanContext,
|
|
341
|
+
attributes: { "messaging.link.source": "dlq_replay" }
|
|
342
|
+
}]);
|
|
343
|
+
emitCorrelatedEvent(baseCtx, "dlq_replay", {
|
|
344
|
+
"messaging.replay": true,
|
|
345
|
+
...options?.replayAttempt !== void 0 && { "messaging.replay.attempt": options.replayAttempt },
|
|
346
|
+
...options?.dlqDwellTimeMs !== void 0 && { "messaging.replay.dwell_time_ms": options.dlqDwellTimeMs }
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
recordRetry(attemptNumber, maxAttempts) {
|
|
350
|
+
baseCtx.setAttribute("messaging.retry.count", attemptNumber);
|
|
351
|
+
if (maxAttempts !== void 0) baseCtx.setAttribute("messaging.retry.max_attempts", maxAttempts);
|
|
352
|
+
emitCorrelatedEvent(baseCtx, "retry_attempt", {
|
|
353
|
+
"messaging.retry.count": attemptNumber,
|
|
354
|
+
...maxAttempts !== void 0 && { "messaging.retry.max_attempts": maxAttempts }
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
getProducerLinks() {
|
|
358
|
+
return [...linkStorage.links];
|
|
359
|
+
},
|
|
360
|
+
isDuplicate() {
|
|
361
|
+
return orderingState.isDuplicate;
|
|
362
|
+
},
|
|
363
|
+
getOutOfOrderInfo() {
|
|
364
|
+
return orderingState.outOfOrderInfo;
|
|
365
|
+
},
|
|
366
|
+
getSequenceNumber() {
|
|
367
|
+
return orderingState.sequenceNumber;
|
|
368
|
+
},
|
|
369
|
+
getPartitionKey() {
|
|
370
|
+
return orderingState.partitionKey;
|
|
371
|
+
},
|
|
372
|
+
recordRebalance(event) {
|
|
373
|
+
if (event.type === "assigned") {
|
|
374
|
+
groupState.assignedPartitions = event.partitions;
|
|
375
|
+
groupState.isActive = true;
|
|
376
|
+
groupState.state = "stable";
|
|
377
|
+
} else if (event.type === "revoked" || event.type === "lost") {
|
|
378
|
+
const revokedSet = new Set(event.partitions.map((p) => `${p.topic}:${p.partition}`));
|
|
379
|
+
groupState.assignedPartitions = groupState.assignedPartitions.filter((p) => !revokedSet.has(`${p.topic}:${p.partition}`));
|
|
380
|
+
if (event.type === "lost") {
|
|
381
|
+
groupState.isActive = false;
|
|
382
|
+
groupState.state = "dead";
|
|
383
|
+
} else groupState.state = groupState.assignedPartitions.length === 0 ? "empty" : "preparing_rebalance";
|
|
384
|
+
}
|
|
385
|
+
if (event.generation !== void 0) groupState.generation = event.generation;
|
|
386
|
+
if (event.memberId) groupState.memberId = event.memberId;
|
|
387
|
+
baseCtx.setAttribute("messaging.consumer_group.rebalance.type", event.type);
|
|
388
|
+
baseCtx.setAttribute("messaging.consumer_group.rebalance.partition_count", event.partitions.length);
|
|
389
|
+
if (event.generation !== void 0) baseCtx.setAttribute("messaging.consumer_group.generation", event.generation);
|
|
390
|
+
if (event.memberId) baseCtx.setAttribute("messaging.consumer_group.member_id", event.memberId);
|
|
391
|
+
if (event.reason) baseCtx.setAttribute("messaging.consumer_group.rebalance.reason", event.reason);
|
|
392
|
+
if (groupState.state) baseCtx.setAttribute("messaging.consumer_group.state", groupState.state);
|
|
393
|
+
const eventAttrs = {
|
|
394
|
+
"messaging.consumer_group.rebalance.type": event.type,
|
|
395
|
+
"messaging.consumer_group.rebalance.partition_count": event.partitions.length,
|
|
396
|
+
"messaging.consumer_group.rebalance.timestamp": event.timestamp,
|
|
397
|
+
...event.generation !== void 0 && { "messaging.consumer_group.generation": event.generation },
|
|
398
|
+
...event.memberId && { "messaging.consumer_group.member_id": event.memberId },
|
|
399
|
+
...event.reason && { "messaging.consumer_group.rebalance.reason": event.reason },
|
|
400
|
+
...groupState.state && { "messaging.consumer_group.state": groupState.state }
|
|
401
|
+
};
|
|
402
|
+
if (event.partitions.length <= 10) eventAttrs["messaging.consumer_group.rebalance.partitions"] = event.partitions.map((p) => `${p.topic}:${p.partition}`).join(",");
|
|
403
|
+
emitCorrelatedEvent(baseCtx, `consumer_group_${event.type}`, eventAttrs);
|
|
404
|
+
if (config.consumerGroupTracking?.onRebalance) config.consumerGroupTracking.onRebalance(consumerCtx, event);
|
|
405
|
+
if (event.type === "assigned" && config.consumerGroupTracking?.onPartitionsAssigned) config.consumerGroupTracking.onPartitionsAssigned(consumerCtx, event.partitions);
|
|
406
|
+
if (event.type === "revoked" && config.consumerGroupTracking?.onPartitionsRevoked) config.consumerGroupTracking.onPartitionsRevoked(consumerCtx, event.partitions);
|
|
407
|
+
},
|
|
408
|
+
recordHeartbeat(healthy, latencyMs) {
|
|
409
|
+
groupState.lastHeartbeat = Date.now();
|
|
410
|
+
baseCtx.setAttribute("messaging.consumer_group.heartbeat.healthy", healthy);
|
|
411
|
+
if (latencyMs !== void 0) baseCtx.setAttribute("messaging.consumer_group.heartbeat.latency_ms", latencyMs);
|
|
412
|
+
emitCorrelatedEvent(baseCtx, "consumer_group_heartbeat", {
|
|
413
|
+
"messaging.consumer_group.heartbeat.healthy": healthy,
|
|
414
|
+
"messaging.consumer_group.heartbeat.timestamp": groupState.lastHeartbeat,
|
|
415
|
+
...latencyMs !== void 0 && { "messaging.consumer_group.heartbeat.latency_ms": latencyMs }
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
recordPartitionLag(lag) {
|
|
419
|
+
const prefix = `messaging.consumer_group.lag.${lag.topic}.${lag.partition}`;
|
|
420
|
+
baseCtx.setAttribute(`${prefix}.current_offset`, lag.currentOffset);
|
|
421
|
+
baseCtx.setAttribute(`${prefix}.end_offset`, lag.endOffset);
|
|
422
|
+
baseCtx.setAttribute(`${prefix}.lag`, lag.lag);
|
|
423
|
+
emitCorrelatedEvent(baseCtx, "partition_lag_recorded", {
|
|
424
|
+
"messaging.consumer_group.lag.topic": lag.topic,
|
|
425
|
+
"messaging.consumer_group.lag.partition": lag.partition,
|
|
426
|
+
"messaging.consumer_group.lag.current_offset": lag.currentOffset,
|
|
427
|
+
"messaging.consumer_group.lag.end_offset": lag.endOffset,
|
|
428
|
+
"messaging.consumer_group.lag.lag": lag.lag,
|
|
429
|
+
"messaging.consumer_group.lag.timestamp": lag.timestamp
|
|
430
|
+
});
|
|
431
|
+
},
|
|
432
|
+
getConsumerGroupState() {
|
|
433
|
+
if (!config.consumerGroup) return null;
|
|
434
|
+
return {
|
|
435
|
+
groupId: config.consumerGroup,
|
|
436
|
+
memberId: groupState.memberId ?? void 0,
|
|
437
|
+
groupInstanceId: groupState.groupInstanceId ?? void 0,
|
|
438
|
+
assignedPartitions: [...groupState.assignedPartitions],
|
|
439
|
+
generation: groupState.generation ?? void 0,
|
|
440
|
+
isActive: groupState.isActive,
|
|
441
|
+
lastHeartbeat: groupState.lastHeartbeat ?? void 0,
|
|
442
|
+
state: groupState.state ?? void 0
|
|
443
|
+
};
|
|
444
|
+
},
|
|
445
|
+
getMemberId() {
|
|
446
|
+
return groupState.memberId;
|
|
447
|
+
},
|
|
448
|
+
getAssignedPartitions() {
|
|
449
|
+
return [...groupState.assignedPartitions];
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
return consumerCtx;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Set OTel semantic convention attributes for producer
|
|
456
|
+
*/
|
|
457
|
+
function setProducerAttributes(ctx, config) {
|
|
458
|
+
ctx.setAttribute("messaging.system", config.system);
|
|
459
|
+
ctx.setAttribute("messaging.operation", "publish");
|
|
460
|
+
ctx.setAttribute("messaging.destination.name", config.destination);
|
|
461
|
+
if (config.system === "kafka") ctx.setAttribute("messaging.kafka.destination.topic", config.destination);
|
|
462
|
+
if (config.attributes) setCustomAttributes(ctx, config.attributes);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Set dynamic producer attributes from arguments
|
|
466
|
+
*/
|
|
467
|
+
function setDynamicProducerAttributes(ctx, config, args) {
|
|
468
|
+
if (config.messageIdFrom) {
|
|
469
|
+
const messageId = extractValue(config.messageIdFrom, args);
|
|
470
|
+
if (messageId !== void 0) ctx.setAttribute("messaging.message.id", String(messageId));
|
|
471
|
+
}
|
|
472
|
+
if (config.partitionFrom) {
|
|
473
|
+
const partition = extractValue(config.partitionFrom, args);
|
|
474
|
+
if (partition !== void 0) ctx.setAttribute("messaging.kafka.destination.partition", Number(partition));
|
|
475
|
+
}
|
|
476
|
+
if (config.keyFrom) {
|
|
477
|
+
const key = extractValue(config.keyFrom, args);
|
|
478
|
+
if (key !== void 0) ctx.setAttribute("messaging.kafka.message.key", String(key));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Set OTel semantic convention attributes for consumer
|
|
483
|
+
*/
|
|
484
|
+
function setConsumerAttributes(ctx, config) {
|
|
485
|
+
ctx.setAttribute("messaging.system", config.system);
|
|
486
|
+
ctx.setAttribute("messaging.operation", config.batchMode ? "receive" : "process");
|
|
487
|
+
ctx.setAttribute("messaging.destination.name", config.destination);
|
|
488
|
+
if (config.consumerGroup) {
|
|
489
|
+
ctx.setAttribute("messaging.consumer.group", config.consumerGroup);
|
|
490
|
+
if (config.system === "kafka") ctx.setAttribute("messaging.kafka.consumer.group", config.consumerGroup);
|
|
491
|
+
}
|
|
492
|
+
if (config.system === "kafka") ctx.setAttribute("messaging.kafka.destination.topic", config.destination);
|
|
493
|
+
if (config.attributes) setCustomAttributes(ctx, config.attributes);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Extract links from message headers and add to span
|
|
497
|
+
*
|
|
498
|
+
* Uses W3C trace context by default, falls back to customContextExtractor if provided.
|
|
499
|
+
* Also populates linkStorage for getProducerLinks() and DLQ auto-linking.
|
|
500
|
+
*/
|
|
501
|
+
async function extractAndAddLinks(ctx, config, args, linkStorage) {
|
|
502
|
+
if (!config.headersFrom && !config.customContextExtractor) return;
|
|
503
|
+
const links = [];
|
|
504
|
+
if (config.batchMode && Array.isArray(args[0])) {
|
|
505
|
+
const messages = args[0];
|
|
506
|
+
if (config.headersFrom) {
|
|
507
|
+
const batchLinks = extractLinksFromBatch(messages.map((msg) => {
|
|
508
|
+
return { headers: extractHeaders(config.headersFrom, msg) };
|
|
509
|
+
}), "headers");
|
|
510
|
+
links.push(...batchLinks);
|
|
511
|
+
}
|
|
512
|
+
if (config.customContextExtractor && config.headersFrom) for (const msg of messages) {
|
|
513
|
+
const headers = extractHeaders(config.headersFrom, msg);
|
|
514
|
+
if (headers) {
|
|
515
|
+
if (!createLinkFromHeaders(headers)) {
|
|
516
|
+
const customContext = config.customContextExtractor(headers);
|
|
517
|
+
if (customContext) links.push({
|
|
518
|
+
context: customContext,
|
|
519
|
+
attributes: { "messaging.link.source": "custom_extractor" }
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
ctx.setAttribute("messaging.batch.message_count", messages.length);
|
|
525
|
+
} else {
|
|
526
|
+
const msg = args[0];
|
|
527
|
+
const headers = config.headersFrom ? extractHeaders(config.headersFrom, msg) : void 0;
|
|
528
|
+
if (headers) {
|
|
529
|
+
const w3cLink = createLinkFromHeaders(headers);
|
|
530
|
+
if (w3cLink) links.push(w3cLink);
|
|
531
|
+
else if (config.customContextExtractor) {
|
|
532
|
+
const customContext = config.customContextExtractor(headers);
|
|
533
|
+
if (customContext) links.push({
|
|
534
|
+
context: customContext,
|
|
535
|
+
attributes: { "messaging.link.source": "custom_extractor" }
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (links.length > 0) {
|
|
541
|
+
ctx.addLinks(links);
|
|
542
|
+
linkStorage.links.push(...links);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Extract lag metrics and set as span attributes
|
|
547
|
+
*/
|
|
548
|
+
async function extractLagMetrics(ctx, lagConfig, args) {
|
|
549
|
+
const msg = Array.isArray(args[0]) ? args[0][0] : args[0];
|
|
550
|
+
let currentOffset;
|
|
551
|
+
if (lagConfig.getCurrentOffset && msg) {
|
|
552
|
+
currentOffset = lagConfig.getCurrentOffset(msg);
|
|
553
|
+
if (currentOffset !== void 0) ctx.setAttribute("messaging.kafka.message.offset", currentOffset);
|
|
554
|
+
}
|
|
555
|
+
if (lagConfig.getPartition && msg) {
|
|
556
|
+
const partition = lagConfig.getPartition(msg);
|
|
557
|
+
if (partition !== void 0) ctx.setAttribute("messaging.kafka.partition", partition);
|
|
558
|
+
}
|
|
559
|
+
if (lagConfig.getEndOffset) try {
|
|
560
|
+
const endOffset = await Promise.resolve(lagConfig.getEndOffset());
|
|
561
|
+
if (endOffset !== void 0 && currentOffset !== void 0) {
|
|
562
|
+
const lag = endOffset - currentOffset;
|
|
563
|
+
ctx.setAttribute("messaging.kafka.consumer_lag", lag);
|
|
564
|
+
emitCorrelatedEvent(ctx, "consumer_lag_measured", {
|
|
565
|
+
"messaging.kafka.consumer_lag": lag,
|
|
566
|
+
"messaging.kafka.message.offset": currentOffset,
|
|
567
|
+
"messaging.kafka.high_watermark": endOffset
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
} catch {}
|
|
571
|
+
if (lagConfig.getCommittedOffset) try {
|
|
572
|
+
const committedOffset = await Promise.resolve(lagConfig.getCommittedOffset());
|
|
573
|
+
if (committedOffset !== void 0) ctx.setAttribute("messaging.kafka.committed_offset", committedOffset);
|
|
574
|
+
} catch {}
|
|
575
|
+
if (Array.isArray(args[0]) && args[0].length > 0) {
|
|
576
|
+
const messages = args[0];
|
|
577
|
+
if (lagConfig.getCurrentOffset) {
|
|
578
|
+
const firstOffset = lagConfig.getCurrentOffset(messages[0]);
|
|
579
|
+
const lastMessage = messages.at(-1);
|
|
580
|
+
const lastOffset = lastMessage === void 0 ? void 0 : lagConfig.getCurrentOffset(lastMessage);
|
|
581
|
+
if (firstOffset !== void 0) ctx.setAttribute("messaging.batch.first_offset", firstOffset);
|
|
582
|
+
if (lastOffset !== void 0) ctx.setAttribute("messaging.batch.last_offset", lastOffset);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Extract headers from message using config
|
|
588
|
+
*/
|
|
589
|
+
function extractHeaders(headersFrom, msg) {
|
|
590
|
+
if (typeof headersFrom === "function") return headersFrom(msg);
|
|
591
|
+
if (typeof msg === "object" && msg !== null) {
|
|
592
|
+
const value = msg[headersFrom];
|
|
593
|
+
if (typeof value === "object" && value !== null) return value;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Extract value from arguments using config
|
|
598
|
+
*/
|
|
599
|
+
function extractValue(extractor, args) {
|
|
600
|
+
if (typeof extractor === "function") return extractor(args);
|
|
601
|
+
const firstArg = args[0];
|
|
602
|
+
if (typeof firstArg === "object" && firstArg !== null) return firstArg[extractor];
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Set custom attributes on context, handling non-primitive values
|
|
606
|
+
*/
|
|
607
|
+
function setCustomAttributes(ctx, attributes) {
|
|
608
|
+
for (const [key, value] of Object.entries(attributes)) if (value !== void 0 && value !== null) if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") ctx.setAttribute(key, value);
|
|
609
|
+
else if (Array.isArray(value)) {
|
|
610
|
+
const cleanArray = value.filter((v) => v !== null && v !== void 0 && (typeof v === "string" || typeof v === "number" || typeof v === "boolean"));
|
|
611
|
+
if (cleanArray.length > 0) ctx.setAttribute(key, cleanArray);
|
|
612
|
+
} else ctx.setAttribute(key, JSON.stringify(value));
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Extract and process ordering information from message
|
|
616
|
+
*
|
|
617
|
+
* Handles:
|
|
618
|
+
* - Sequence number extraction and tracking
|
|
619
|
+
* - Out-of-order detection
|
|
620
|
+
* - Duplicate detection
|
|
621
|
+
* - Span attribute setting
|
|
622
|
+
* - Callback invocation
|
|
623
|
+
*/
|
|
624
|
+
function extractAndProcessOrdering(ctx, config, args, orderingState) {
|
|
625
|
+
const ordering = config.ordering;
|
|
626
|
+
if (!ordering) return;
|
|
627
|
+
const messages = config.batchMode && Array.isArray(args[0]) ? args[0] : [args[0]];
|
|
628
|
+
if (messages.length === 0) return;
|
|
629
|
+
let outOfOrderCount = 0;
|
|
630
|
+
let duplicateCount = 0;
|
|
631
|
+
let lastSequence = null;
|
|
632
|
+
let lastPartitionKey = null;
|
|
633
|
+
let lastMessageId = null;
|
|
634
|
+
for (const [i, msg] of messages.entries()) {
|
|
635
|
+
if (!msg) continue;
|
|
636
|
+
let msgSequence = null;
|
|
637
|
+
let msgPartitionKey = null;
|
|
638
|
+
let msgId = null;
|
|
639
|
+
if (ordering.sequenceFrom) {
|
|
640
|
+
const seq = ordering.sequenceFrom(msg);
|
|
641
|
+
if (seq !== void 0) {
|
|
642
|
+
msgSequence = seq;
|
|
643
|
+
lastSequence = seq;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (ordering.partitionKeyFrom) {
|
|
647
|
+
const key = ordering.partitionKeyFrom(msg);
|
|
648
|
+
if (key !== void 0) {
|
|
649
|
+
msgPartitionKey = key;
|
|
650
|
+
lastPartitionKey = key;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
if (ordering.messageIdFrom) {
|
|
654
|
+
const id = ordering.messageIdFrom(msg);
|
|
655
|
+
if (id !== void 0) {
|
|
656
|
+
msgId = id;
|
|
657
|
+
lastMessageId = id;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
if (ordering.detectOutOfOrder && msgSequence !== null) {
|
|
661
|
+
const trackerKey = buildTrackerKey(config, {
|
|
662
|
+
sequenceNumber: msgSequence,
|
|
663
|
+
partitionKey: msgPartitionKey,
|
|
664
|
+
messageId: msgId,
|
|
665
|
+
isDuplicate: false,
|
|
666
|
+
outOfOrderInfo: null
|
|
667
|
+
});
|
|
668
|
+
const prevSequence = sequenceTrackers.get(trackerKey);
|
|
669
|
+
if (prevSequence !== void 0) {
|
|
670
|
+
const expectedSequence = prevSequence + 1;
|
|
671
|
+
if (msgSequence !== expectedSequence) {
|
|
672
|
+
outOfOrderCount++;
|
|
673
|
+
const gap = msgSequence - expectedSequence;
|
|
674
|
+
const outOfOrderInfo = {
|
|
675
|
+
currentSequence: msgSequence,
|
|
676
|
+
expectedSequence,
|
|
677
|
+
partitionKey: msgPartitionKey ?? void 0,
|
|
678
|
+
gap
|
|
679
|
+
};
|
|
680
|
+
if (!orderingState.outOfOrderInfo) orderingState.outOfOrderInfo = outOfOrderInfo;
|
|
681
|
+
emitCorrelatedEvent(ctx, "message_out_of_order", {
|
|
682
|
+
"messaging.ordering.batch_index": i,
|
|
683
|
+
"messaging.ordering.current_sequence": msgSequence,
|
|
684
|
+
"messaging.ordering.expected_sequence": expectedSequence,
|
|
685
|
+
"messaging.ordering.gap": gap,
|
|
686
|
+
...msgPartitionKey && { "messaging.ordering.partition_key": msgPartitionKey }
|
|
687
|
+
});
|
|
688
|
+
if (ordering.onOutOfOrder) ordering.onOutOfOrder(ctx, outOfOrderInfo);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
sequenceTrackers.set(trackerKey, msgSequence);
|
|
692
|
+
}
|
|
693
|
+
if (ordering.detectDuplicates && msgId !== null) {
|
|
694
|
+
const dedupKey = buildDedupKey(config, {
|
|
695
|
+
sequenceNumber: msgSequence,
|
|
696
|
+
partitionKey: msgPartitionKey,
|
|
697
|
+
messageId: msgId,
|
|
698
|
+
isDuplicate: false,
|
|
699
|
+
outOfOrderInfo: null
|
|
700
|
+
});
|
|
701
|
+
if (deduplicationWindow.has(dedupKey)) {
|
|
702
|
+
duplicateCount++;
|
|
703
|
+
emitCorrelatedEvent(ctx, "message_duplicate", {
|
|
704
|
+
"messaging.ordering.batch_index": i,
|
|
705
|
+
"messaging.message.id": msgId
|
|
706
|
+
});
|
|
707
|
+
if (ordering.onDuplicate) ordering.onDuplicate(ctx, msgId);
|
|
708
|
+
} else {
|
|
709
|
+
deduplicationWindow.set(dedupKey, Date.now());
|
|
710
|
+
trimDeduplicationWindow(ordering.deduplicationWindowSize ?? DEFAULT_DEDUP_WINDOW_SIZE);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
orderingState.sequenceNumber = lastSequence;
|
|
715
|
+
orderingState.partitionKey = lastPartitionKey;
|
|
716
|
+
orderingState.messageId = lastMessageId;
|
|
717
|
+
orderingState.isDuplicate = duplicateCount > 0;
|
|
718
|
+
if (lastSequence !== null) ctx.setAttribute("messaging.message.sequence_number", lastSequence);
|
|
719
|
+
if (lastPartitionKey !== null) ctx.setAttribute("messaging.message.partition_key", lastPartitionKey);
|
|
720
|
+
if (lastMessageId !== null) ctx.setAttribute("messaging.message.id", lastMessageId);
|
|
721
|
+
if (outOfOrderCount > 0) {
|
|
722
|
+
ctx.setAttribute("messaging.ordering.out_of_order", true);
|
|
723
|
+
ctx.setAttribute("messaging.ordering.out_of_order_count", outOfOrderCount);
|
|
724
|
+
}
|
|
725
|
+
if (duplicateCount > 0) {
|
|
726
|
+
ctx.setAttribute("messaging.ordering.duplicate", true);
|
|
727
|
+
ctx.setAttribute("messaging.ordering.duplicate_count", duplicateCount);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Build a unique key for sequence tracking based on system, destination, and partition
|
|
732
|
+
*/
|
|
733
|
+
function buildTrackerKey(config, orderingState) {
|
|
734
|
+
const parts = [config.system, config.destination];
|
|
735
|
+
if (orderingState.partitionKey) parts.push(orderingState.partitionKey);
|
|
736
|
+
if (config.consumerGroup) parts.push(config.consumerGroup);
|
|
737
|
+
return parts.join(":");
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Build a unique key for deduplication based on system, destination, and message ID
|
|
741
|
+
*/
|
|
742
|
+
function buildDedupKey(config, orderingState) {
|
|
743
|
+
const parts = [config.system, config.destination];
|
|
744
|
+
if (orderingState.messageId) parts.push(orderingState.messageId);
|
|
745
|
+
return parts.join(":");
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Clear sequence tracking state (useful for testing)
|
|
749
|
+
*/
|
|
750
|
+
function clearOrderingState() {
|
|
751
|
+
sequenceTrackers.clear();
|
|
752
|
+
deduplicationWindow.clear();
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
//#endregion
|
|
756
|
+
export { clearOrderingState, traceConsumer, traceProducer };
|
|
21
757
|
//# sourceMappingURL=messaging.js.map
|