autotel 3.6.0 → 4.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/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-CmYpdqCN.js +591 -0
- package/dist/attributes-CmYpdqCN.js.map +1 -0
- package/dist/attributes-PZ5doLgw.cjs +704 -0
- package/dist/attributes-PZ5doLgw.cjs.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 -54
- 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 -17
- 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 -66
- 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 -64
- 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 -37
- 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 -21
- 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 -57
- 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 -20
- package/dist/http.cjs +276 -176
- 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 -174
- package/dist/http.js.map +1 -1
- package/dist/index-Ck06vlW2.d.ts +678 -0
- package/dist/index-Ck06vlW2.d.ts.map +1 -0
- package/dist/index-eKuioqT1.d.cts +678 -0
- package/dist/index-eKuioqT1.d.cts.map +1 -0
- package/dist/index.cjs +751 -1218
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +341 -659
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +341 -659
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +606 -737
- 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 -36
- 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 -21
- 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-DVSmWg6Y.js +175 -0
- package/dist/registry-DVSmWg6Y.js.map +1 -0
- package/dist/registry-DYgvb62e.cjs +319 -0
- package/dist/registry-DYgvb62e.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 +327 -39
- package/dist/semantic-helpers.cjs.map +1 -1
- package/dist/semantic-helpers.d.cts +30 -150
- package/dist/semantic-helpers.d.cts.map +1 -0
- package/dist/semantic-helpers.d.ts +30 -150
- package/dist/semantic-helpers.d.ts.map +1 -0
- package/dist/semantic-helpers.js +326 -20
- 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 +178 -115
- package/dist/validate.cjs.map +1 -1
- package/dist/validate.d.cts +40 -64
- package/dist/validate.d.cts.map +1 -0
- package/dist/validate.d.ts +40 -64
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +177 -113
- package/dist/validate.js.map +1 -1
- package/dist/validation-attributes.cjs +42 -17
- package/dist/validation-attributes.cjs.map +1 -1
- package/dist/validation-attributes.d.cts +13 -20
- package/dist/validation-attributes.d.cts.map +1 -0
- package/dist/validation-attributes.d.ts +13 -20
- package/dist/validation-attributes.d.ts.map +1 -0
- package/dist/validation-attributes.js +40 -2
- package/dist/validation-attributes.js.map +1 -1
- package/dist/webhook.cjs +286 -256
- 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 -254
- package/dist/webhook.js.map +1 -1
- package/dist/workflow-distributed.cjs +498 -412
- 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 -410
- package/dist/workflow-distributed.js.map +1 -1
- package/dist/workflow.cjs +405 -40
- 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 -21
- 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 +4 -4
- package/skills/analyze-traces/SKILL.md +14 -12
- package/skills/review-otel-patterns/SKILL.md +4 -2
- package/skills/tune-sampling/SKILL.md +8 -3
- package/src/attributes/builders.ts +2 -20
- package/src/attributes/index.ts +0 -1
- package/src/attributes/registry.ts +2 -9
- package/src/attributes/types.ts +0 -8
- package/src/index.ts +7 -41
- package/src/request-logger.test.ts +53 -1
- package/src/request-logger.ts +58 -0
- package/src/semantic-helpers.test.ts +2 -87
- package/src/semantic-helpers.ts +0 -146
- package/src/validate.test.ts +3 -1
- package/src/validate.ts +9 -3
- 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-66YJ66GG.js +0 -1021
- package/dist/chunk-66YJ66GG.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-ALPYR2GC.js +0 -1061
- package/dist/chunk-ALPYR2GC.js.map +0 -1
- package/dist/chunk-B7SWBE4P.cjs +0 -799
- package/dist/chunk-B7SWBE4P.cjs.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-D4TM63S3.js +0 -795
- package/dist/chunk-D4TM63S3.js.map +0 -1
- package/dist/chunk-DCEDJQGG.js +0 -28
- package/dist/chunk-DCEDJQGG.js.map +0 -1
- package/dist/chunk-DPSA4QLA.js +0 -344
- package/dist/chunk-DPSA4QLA.js.map +0 -1
- package/dist/chunk-E6TERL5O.cjs +0 -23
- package/dist/chunk-E6TERL5O.cjs.map +0 -1
- package/dist/chunk-EE6CPXKH.cjs +0 -164
- package/dist/chunk-EE6CPXKH.cjs.map +0 -1
- package/dist/chunk-EOFB7XCL.cjs +0 -837
- package/dist/chunk-EOFB7XCL.cjs.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-FMTHVSYY.cjs +0 -1039
- package/dist/chunk-FMTHVSYY.cjs.map +0 -1
- package/dist/chunk-FU6R566Y.cjs +0 -236
- package/dist/chunk-FU6R566Y.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-KYXZS3EA.cjs +0 -100
- package/dist/chunk-KYXZS3EA.cjs.map +0 -1
- package/dist/chunk-LITNXTTT.js +0 -3
- package/dist/chunk-LITNXTTT.js.map +0 -1
- package/dist/chunk-LVIPBYFE.js +0 -157
- package/dist/chunk-LVIPBYFE.js.map +0 -1
- package/dist/chunk-M3LFHHTN.cjs +0 -764
- package/dist/chunk-M3LFHHTN.cjs.map +0 -1
- package/dist/chunk-N25JDZSC.js +0 -95
- package/dist/chunk-N25JDZSC.js.map +0 -1
- package/dist/chunk-NEIB3TLD.cjs +0 -360
- package/dist/chunk-NEIB3TLD.cjs.map +0 -1
- package/dist/chunk-NENU7E6V.cjs +0 -344
- package/dist/chunk-NENU7E6V.cjs.map +0 -1
- package/dist/chunk-NVAI5CCN.cjs +0 -39
- package/dist/chunk-NVAI5CCN.cjs.map +0 -1
- package/dist/chunk-NZ72VDNY.cjs +0 -4
- package/dist/chunk-NZ72VDNY.cjs.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-QF7ARNUM.js +0 -339
- package/dist/chunk-QF7ARNUM.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-T5WRA76K.cjs +0 -32
- package/dist/chunk-T5WRA76K.cjs.map +0 -1
- package/dist/chunk-T7JO2TCP.js +0 -1233
- package/dist/chunk-T7JO2TCP.js.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-UIKYE2QZ.js +0 -833
- package/dist/chunk-UIKYE2QZ.js.map +0 -1
- package/dist/chunk-UNPLAVE7.js +0 -21
- package/dist/chunk-UNPLAVE7.js.map +0 -1
- package/dist/chunk-UY3UYPBZ.cjs +0 -77
- package/dist/chunk-UY3UYPBZ.cjs.map +0 -1
- package/dist/chunk-V7UBMJAB.cjs +0 -1242
- package/dist/chunk-V7UBMJAB.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-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/define-event-BL6Li7CM.d.ts +0 -23
- package/dist/define-event-ClP3T1Jx.d.cts +0 -23
- 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/src/gen-ai-cost.test.ts +0 -81
- package/src/gen-ai-cost.ts +0 -145
- package/src/gen-ai-events.test.ts +0 -135
- package/src/gen-ai-events.ts +0 -208
- package/src/gen-ai-metrics.test.ts +0 -96
- package/src/gen-ai-metrics.ts +0 -128
package/dist/chunk-T7JO2TCP.js
DELETED
|
@@ -1,1233 +0,0 @@
|
|
|
1
|
-
import { setSpanName } from './chunk-HT5JQKN2.js';
|
|
2
|
-
import { runInOperationContext } from './chunk-SEO6NAQT.js';
|
|
3
|
-
import { createTraceContext, getActiveContextWithBaggage, getContextStorage, getEventQueue, enterOrRun } from './chunk-66YJ66GG.js';
|
|
4
|
-
import { getConfig as getConfig$1, getSdk } from './chunk-ALPYR2GC.js';
|
|
5
|
-
import { AlwaysSampler, AUTOTEL_SAMPLING_TAIL_KEEP, AUTOTEL_SAMPLING_TAIL_EVALUATED } from './chunk-DPSA4QLA.js';
|
|
6
|
-
import { getConfig } from './chunk-J5QENANM.js';
|
|
7
|
-
import { trace as trace$1, SpanStatusCode, context, propagation } from '@opentelemetry/api';
|
|
8
|
-
import { readFileSync } from 'fs';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
|
|
11
|
-
var inferenceCache = /* @__PURE__ */ new Map();
|
|
12
|
-
var MAX_CACHE_SIZE = 50;
|
|
13
|
-
function captureStackTrace() {
|
|
14
|
-
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
15
|
-
Error.stackTraceLimit = 10;
|
|
16
|
-
const err = new Error("Stack trace capture");
|
|
17
|
-
const stack = err.stack || "";
|
|
18
|
-
Error.stackTraceLimit = originalStackTraceLimit;
|
|
19
|
-
return stack;
|
|
20
|
-
}
|
|
21
|
-
function parseCallLocation(stack) {
|
|
22
|
-
const lines = stack.split("\n");
|
|
23
|
-
let skippedExternalFrame = false;
|
|
24
|
-
for (const line of lines) {
|
|
25
|
-
if (line.includes("variable-name-inference.ts") || line.includes("variable-name-inference.js") || line.includes("functional.ts") || line.includes("functional.js")) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const match = line.match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/) || line.match(/^.*?([^:]+):(\d+):(\d+)/);
|
|
29
|
-
if (match) {
|
|
30
|
-
let filePath = match[1].trim();
|
|
31
|
-
if (filePath.startsWith("file://")) {
|
|
32
|
-
try {
|
|
33
|
-
filePath = fileURLToPath(filePath);
|
|
34
|
-
} catch {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (!skippedExternalFrame) {
|
|
39
|
-
skippedExternalFrame = true;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
file: filePath,
|
|
44
|
-
line: Number.parseInt(match[2], 10),
|
|
45
|
-
column: Number.parseInt(match[3], 10)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
function readSourceLine(filePath, lineNumber) {
|
|
52
|
-
try {
|
|
53
|
-
if (typeof readFileSync !== "function") {
|
|
54
|
-
return void 0;
|
|
55
|
-
}
|
|
56
|
-
const content = readFileSync(filePath, "utf8");
|
|
57
|
-
const lines = content.split("\n");
|
|
58
|
-
return lines[lineNumber - 1];
|
|
59
|
-
} catch {
|
|
60
|
-
return void 0;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function extractVariableName(sourceLine) {
|
|
64
|
-
const trimmed = sourceLine.trim();
|
|
65
|
-
const patterns = [
|
|
66
|
-
// export const varName = anyFunction(
|
|
67
|
-
/export\s+const\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
|
|
68
|
-
// const varName = anyFunction(
|
|
69
|
-
/const\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
|
|
70
|
-
// export let varName = anyFunction(
|
|
71
|
-
/export\s+let\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
|
|
72
|
-
// let varName = anyFunction(
|
|
73
|
-
/let\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
|
|
74
|
-
// export var varName = anyFunction(
|
|
75
|
-
/export\s+var\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/,
|
|
76
|
-
// var varName = anyFunction(
|
|
77
|
-
/var\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/
|
|
78
|
-
];
|
|
79
|
-
for (const pattern of patterns) {
|
|
80
|
-
const match = trimmed.match(pattern);
|
|
81
|
-
if (match && match[1]) {
|
|
82
|
-
return match[1];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return void 0;
|
|
86
|
-
}
|
|
87
|
-
function cacheInference(key, value) {
|
|
88
|
-
if (inferenceCache.size >= MAX_CACHE_SIZE) {
|
|
89
|
-
const firstKey = inferenceCache.keys().next().value;
|
|
90
|
-
if (firstKey) {
|
|
91
|
-
inferenceCache.delete(firstKey);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
inferenceCache.set(key, value);
|
|
95
|
-
}
|
|
96
|
-
function inferVariableNameFromCallStack() {
|
|
97
|
-
try {
|
|
98
|
-
const stack = captureStackTrace();
|
|
99
|
-
const callLocation = parseCallLocation(stack);
|
|
100
|
-
if (!callLocation) {
|
|
101
|
-
return void 0;
|
|
102
|
-
}
|
|
103
|
-
const cacheKey = `${callLocation.file}:${callLocation.line}`;
|
|
104
|
-
if (inferenceCache.has(cacheKey)) {
|
|
105
|
-
return inferenceCache.get(cacheKey);
|
|
106
|
-
}
|
|
107
|
-
const sourceLine = readSourceLine(callLocation.file, callLocation.line);
|
|
108
|
-
if (!sourceLine) {
|
|
109
|
-
return void 0;
|
|
110
|
-
}
|
|
111
|
-
const variableName = extractVariableName(sourceLine);
|
|
112
|
-
cacheInference(cacheKey, variableName);
|
|
113
|
-
return variableName;
|
|
114
|
-
} catch {
|
|
115
|
-
return void 0;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// src/functional.ts
|
|
120
|
-
var FACTORY_NAME_HINTS = /* @__PURE__ */ new Set([
|
|
121
|
-
"ctx",
|
|
122
|
-
"_ctx",
|
|
123
|
-
"context",
|
|
124
|
-
"tracecontext",
|
|
125
|
-
"tracectx"
|
|
126
|
-
]);
|
|
127
|
-
var TRACE_FACTORY_SET = /* @__PURE__ */ new WeakSet();
|
|
128
|
-
var SINGLE_LINE_COMMENT_REGEX = /\/\/.*$/gm;
|
|
129
|
-
var MULTI_LINE_COMMENT_REGEX = /\/\*[\s\S]*?\*\//gm;
|
|
130
|
-
var PARAM_TOKEN_SANITIZE_REGEX = new RegExp(String.raw`[{}\[\]\s]`, "g");
|
|
131
|
-
function markAsTraceFactory(fn) {
|
|
132
|
-
TRACE_FACTORY_SET.add(fn);
|
|
133
|
-
}
|
|
134
|
-
function hasFactoryMark(fn) {
|
|
135
|
-
return TRACE_FACTORY_SET.has(fn);
|
|
136
|
-
}
|
|
137
|
-
function sanitizeParameterToken(token) {
|
|
138
|
-
const [firstToken] = token.split("=");
|
|
139
|
-
return (firstToken ?? "").replaceAll(PARAM_TOKEN_SANITIZE_REGEX, "").trim();
|
|
140
|
-
}
|
|
141
|
-
function getFirstParameterToken(fn) {
|
|
142
|
-
let source = Function.prototype.toString.call(fn);
|
|
143
|
-
source = source.replaceAll(MULTI_LINE_COMMENT_REGEX, "").replaceAll(SINGLE_LINE_COMMENT_REGEX, "").trim();
|
|
144
|
-
const arrowMatch = source.match(
|
|
145
|
-
/^(?:async\s*)?(?:\(([^)]*)\)|([^=()]+))\s*=>/
|
|
146
|
-
);
|
|
147
|
-
if (arrowMatch) {
|
|
148
|
-
const params = (arrowMatch[1] ?? arrowMatch[2] ?? "").split(",");
|
|
149
|
-
const first = params[0]?.trim();
|
|
150
|
-
if (first) {
|
|
151
|
-
return sanitizeParameterToken(first);
|
|
152
|
-
}
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
const functionMatch = source.match(/^[^(]*\(([^)]*)\)/);
|
|
156
|
-
if (functionMatch) {
|
|
157
|
-
const params = functionMatch[1]?.split(",");
|
|
158
|
-
const first = params?.[0]?.trim();
|
|
159
|
-
if (first) {
|
|
160
|
-
return sanitizeParameterToken(first);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
var IMMEDIATE_EXECUTION_SYMBOL = /* @__PURE__ */ Symbol.for("autotel.immediate-execution");
|
|
166
|
-
function hasImmediateExecutionMark(fn) {
|
|
167
|
-
return typeof fn === "function" && fn[IMMEDIATE_EXECUTION_SYMBOL] === true;
|
|
168
|
-
}
|
|
169
|
-
function markAsImmediate(fn) {
|
|
170
|
-
if (typeof fn === "function") {
|
|
171
|
-
fn[IMMEDIATE_EXECUTION_SYMBOL] = true;
|
|
172
|
-
}
|
|
173
|
-
return fn;
|
|
174
|
-
}
|
|
175
|
-
function looksLikeTraceFactory(fn) {
|
|
176
|
-
if (hasFactoryMark(fn)) {
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
if (hasImmediateExecutionMark(fn)) {
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
if (fn.length === 0) {
|
|
183
|
-
if (!isAsyncFunction(fn)) {
|
|
184
|
-
try {
|
|
185
|
-
const result = fn();
|
|
186
|
-
return typeof result === "function";
|
|
187
|
-
} catch {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
const firstParam = getFirstParameterToken(fn);
|
|
194
|
-
if (!firstParam) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
const normalized = firstParam.toLowerCase();
|
|
198
|
-
if (FACTORY_NAME_HINTS.has(normalized) || normalized.startsWith("ctx") || normalized.startsWith("_ctx") || normalized.startsWith("trace") || normalized.endsWith("ctx") || // Match baseCtx, spanCtx, etc.
|
|
199
|
-
normalized.includes("context")) {
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
function isFactoryReturningFunction(fnWithCtx) {
|
|
205
|
-
if (isAsyncFunction(fnWithCtx)) {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
const result = fnWithCtx(createDummyCtx());
|
|
210
|
-
return typeof result === "function";
|
|
211
|
-
} catch {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function isTraceFactoryFunction(fn) {
|
|
216
|
-
if (typeof fn !== "function") {
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
if (hasFactoryMark(fn)) {
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
if (looksLikeTraceFactory(fn)) {
|
|
223
|
-
markAsTraceFactory(fn);
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
function ensureTraceFactory(fnOrFactory) {
|
|
229
|
-
if (isTraceFactoryFunction(fnOrFactory)) {
|
|
230
|
-
return fnOrFactory;
|
|
231
|
-
}
|
|
232
|
-
const plainFn = fnOrFactory;
|
|
233
|
-
const factory = (ctx2) => {
|
|
234
|
-
return plainFn;
|
|
235
|
-
};
|
|
236
|
-
markAsTraceFactory(factory);
|
|
237
|
-
return factory;
|
|
238
|
-
}
|
|
239
|
-
function wrapFactoryWithTracing(fnOrFactory, options, variableName) {
|
|
240
|
-
const factory = ensureTraceFactory(fnOrFactory);
|
|
241
|
-
const sampleFn = factory(createDummyCtx());
|
|
242
|
-
const innerFunctionName = inferFunctionName(
|
|
243
|
-
sampleFn
|
|
244
|
-
);
|
|
245
|
-
const callStackVariableName = innerFunctionName ? void 0 : inferVariableNameFromCallStack();
|
|
246
|
-
const factoryName = inferFunctionName(factory);
|
|
247
|
-
const effectiveVariableName = variableName || innerFunctionName || callStackVariableName || factoryName;
|
|
248
|
-
const useAsyncWrapper = isAsyncFunction(sampleFn);
|
|
249
|
-
if (useAsyncWrapper) {
|
|
250
|
-
return wrapWithTracing(
|
|
251
|
-
factory,
|
|
252
|
-
options,
|
|
253
|
-
effectiveVariableName
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
return wrapWithTracingSync(
|
|
257
|
-
factory,
|
|
258
|
-
options,
|
|
259
|
-
effectiveVariableName
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
var MAX_ERROR_MESSAGE_LENGTH = 500;
|
|
263
|
-
function createDummyCtx() {
|
|
264
|
-
return {
|
|
265
|
-
traceId: "",
|
|
266
|
-
spanId: "",
|
|
267
|
-
correlationId: "",
|
|
268
|
-
setAttribute: () => {
|
|
269
|
-
},
|
|
270
|
-
setAttributes: () => {
|
|
271
|
-
},
|
|
272
|
-
setStatus: () => {
|
|
273
|
-
},
|
|
274
|
-
recordException: () => {
|
|
275
|
-
},
|
|
276
|
-
addEvent: () => {
|
|
277
|
-
},
|
|
278
|
-
addLink: () => {
|
|
279
|
-
},
|
|
280
|
-
addLinks: () => {
|
|
281
|
-
},
|
|
282
|
-
updateName: () => {
|
|
283
|
-
},
|
|
284
|
-
isRecording: () => false,
|
|
285
|
-
getBaggage: () => {
|
|
286
|
-
},
|
|
287
|
-
setBaggage: () => "",
|
|
288
|
-
deleteBaggage: () => {
|
|
289
|
-
},
|
|
290
|
-
getAllBaggage: () => /* @__PURE__ */ new Map()
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
var AUTOTEL_INPUT_ATTR = "autotel.input";
|
|
294
|
-
var AUTOTEL_OUTPUT_ATTR = "autotel.output";
|
|
295
|
-
var CAPTURE_MAX_CHARS = 4096;
|
|
296
|
-
function serializeCapture(value) {
|
|
297
|
-
if (value === void 0) return void 0;
|
|
298
|
-
try {
|
|
299
|
-
const json = typeof value === "string" ? value : JSON.stringify(value);
|
|
300
|
-
if (json === void 0) return void 0;
|
|
301
|
-
return json.length > CAPTURE_MAX_CHARS ? `${json.slice(0, CAPTURE_MAX_CHARS)}\u2026[truncated]` : json;
|
|
302
|
-
} catch {
|
|
303
|
-
return void 0;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
function captureInputAttrs(args, enabled) {
|
|
307
|
-
if (!enabled) return {};
|
|
308
|
-
const s = serializeCapture(args.length === 1 ? args[0] : args);
|
|
309
|
-
return s === void 0 ? {} : { [AUTOTEL_INPUT_ATTR]: s };
|
|
310
|
-
}
|
|
311
|
-
function captureOutputAttrs(result, enabled) {
|
|
312
|
-
if (!enabled) return {};
|
|
313
|
-
const s = serializeCapture(result);
|
|
314
|
-
return s === void 0 ? {} : { [AUTOTEL_OUTPUT_ATTR]: s };
|
|
315
|
-
}
|
|
316
|
-
function isAsyncFunction(fn) {
|
|
317
|
-
return typeof fn === "function" && fn.constructor?.name === "AsyncFunction";
|
|
318
|
-
}
|
|
319
|
-
var INSTRUMENTED_SYMBOL = /* @__PURE__ */ Symbol.for("autotel.functional.instrumented");
|
|
320
|
-
function hasInstrumentationFlag(value) {
|
|
321
|
-
return (typeof value === "function" || typeof value === "object") && value !== null && Boolean(value[INSTRUMENTED_SYMBOL]);
|
|
322
|
-
}
|
|
323
|
-
function truncateErrorMessage(message) {
|
|
324
|
-
if (message.length <= MAX_ERROR_MESSAGE_LENGTH) {
|
|
325
|
-
return message;
|
|
326
|
-
}
|
|
327
|
-
return `${message.slice(0, MAX_ERROR_MESSAGE_LENGTH)}... (truncated)`;
|
|
328
|
-
}
|
|
329
|
-
function inferFunctionName(fn) {
|
|
330
|
-
const displayName = fn.displayName;
|
|
331
|
-
if (displayName) {
|
|
332
|
-
return displayName;
|
|
333
|
-
}
|
|
334
|
-
if (fn.name && fn.name !== "anonymous" && fn.name !== "") {
|
|
335
|
-
return fn.name;
|
|
336
|
-
}
|
|
337
|
-
const source = Function.prototype.toString.call(fn);
|
|
338
|
-
const match = source.match(/function\s+([^(\s]+)/);
|
|
339
|
-
if (match && match[1] && match[1] !== "anonymous") {
|
|
340
|
-
return match[1];
|
|
341
|
-
}
|
|
342
|
-
return void 0;
|
|
343
|
-
}
|
|
344
|
-
function getSpanName(options, fn, variableName) {
|
|
345
|
-
if (options.name) {
|
|
346
|
-
return options.name;
|
|
347
|
-
}
|
|
348
|
-
let fnName = variableName || inferFunctionName(fn);
|
|
349
|
-
fnName = fnName || "anonymous";
|
|
350
|
-
if (options.serviceName) {
|
|
351
|
-
return `${options.serviceName}.${fnName}`;
|
|
352
|
-
}
|
|
353
|
-
if (fnName && fnName !== "anonymous") {
|
|
354
|
-
return fnName;
|
|
355
|
-
}
|
|
356
|
-
return "unknown";
|
|
357
|
-
}
|
|
358
|
-
function shouldSkip(key, fn, skip) {
|
|
359
|
-
if (key.startsWith("_")) {
|
|
360
|
-
return true;
|
|
361
|
-
}
|
|
362
|
-
if (!skip || skip.length === 0) {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
for (const rule of skip) {
|
|
366
|
-
if (typeof rule === "string" && key === rule) {
|
|
367
|
-
return true;
|
|
368
|
-
} else if (rule instanceof RegExp && rule.test(key)) {
|
|
369
|
-
return true;
|
|
370
|
-
} else if (typeof rule === "function" && rule(key, fn)) {
|
|
371
|
-
return true;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
function getCtxValue() {
|
|
377
|
-
const activeSpan = trace$1.getActiveSpan();
|
|
378
|
-
if (!activeSpan) return null;
|
|
379
|
-
return createTraceContext(activeSpan);
|
|
380
|
-
}
|
|
381
|
-
var ctx = new Proxy(
|
|
382
|
-
{},
|
|
383
|
-
{
|
|
384
|
-
get(_target, prop) {
|
|
385
|
-
const ctxValue = getCtxValue();
|
|
386
|
-
if (!ctxValue) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
return ctxValue[prop];
|
|
390
|
-
},
|
|
391
|
-
has(_target, prop) {
|
|
392
|
-
const ctxValue = getCtxValue();
|
|
393
|
-
if (!ctxValue) {
|
|
394
|
-
return false;
|
|
395
|
-
}
|
|
396
|
-
return prop in ctxValue;
|
|
397
|
-
},
|
|
398
|
-
ownKeys() {
|
|
399
|
-
const ctxValue = getCtxValue();
|
|
400
|
-
if (!ctxValue) {
|
|
401
|
-
return [];
|
|
402
|
-
}
|
|
403
|
-
return Object.keys(ctxValue);
|
|
404
|
-
},
|
|
405
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
406
|
-
const ctxValue = getCtxValue();
|
|
407
|
-
if (!ctxValue) {
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
return Object.getOwnPropertyDescriptor(ctxValue, prop);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
);
|
|
414
|
-
function wrapWithTracing(fnFactory, options, variableName) {
|
|
415
|
-
if (hasInstrumentationFlag(fnFactory)) ;
|
|
416
|
-
const config = getConfig();
|
|
417
|
-
const tracer = config.tracer;
|
|
418
|
-
const meter = config.meter;
|
|
419
|
-
const sampler = options.sampler || new AlwaysSampler();
|
|
420
|
-
const tempFn = fnFactory(createDummyCtx());
|
|
421
|
-
const spanName = getSpanName(options, tempFn, variableName);
|
|
422
|
-
const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
|
|
423
|
-
description: `Call count for ${spanName}`,
|
|
424
|
-
unit: "1"
|
|
425
|
-
}) : void 0;
|
|
426
|
-
const durationHistogram = options.withMetrics ? meter.createHistogram(`${spanName}.duration`, {
|
|
427
|
-
description: `Duration for ${spanName}`,
|
|
428
|
-
unit: "ms"
|
|
429
|
-
}) : void 0;
|
|
430
|
-
const wrappedFunction = async function wrappedFunction2(...args) {
|
|
431
|
-
const samplingContext = {
|
|
432
|
-
operationName: spanName,
|
|
433
|
-
args,
|
|
434
|
-
metadata: {}
|
|
435
|
-
};
|
|
436
|
-
const shouldSample = sampler.shouldSample(samplingContext);
|
|
437
|
-
const needsTailSampling = "needsTailSampling" in sampler && typeof sampler.needsTailSampling === "function" ? sampler.needsTailSampling() : false;
|
|
438
|
-
if (!shouldSample && !needsTailSampling) {
|
|
439
|
-
const fn = fnFactory(createDummyCtx());
|
|
440
|
-
return await fn.call(this, ...args);
|
|
441
|
-
}
|
|
442
|
-
const startTime = performance.now();
|
|
443
|
-
const isRootSpan = options.startNewRoot || trace$1.getActiveSpan() === void 0;
|
|
444
|
-
const shouldAutoFlush = options.flushOnRootSpanEnd ?? getConfig$1()?.flushOnRootSpanEnd ?? true;
|
|
445
|
-
const shouldAutoFlushSpans = getConfig$1()?.forceFlushOnShutdown ?? false;
|
|
446
|
-
const flushIfNeeded = async () => {
|
|
447
|
-
if (!shouldAutoFlush || !isRootSpan) return;
|
|
448
|
-
try {
|
|
449
|
-
const queue = getEventQueue();
|
|
450
|
-
if (queue && queue.size() > 0) {
|
|
451
|
-
await queue.flush();
|
|
452
|
-
}
|
|
453
|
-
if (shouldAutoFlushSpans) {
|
|
454
|
-
const sdk = getSdk();
|
|
455
|
-
if (sdk) {
|
|
456
|
-
try {
|
|
457
|
-
const sdkAny = sdk;
|
|
458
|
-
if (typeof sdkAny.getTracerProvider === "function") {
|
|
459
|
-
const tracerProvider = sdkAny.getTracerProvider();
|
|
460
|
-
if (tracerProvider && typeof tracerProvider.forceFlush === "function") {
|
|
461
|
-
await tracerProvider.forceFlush();
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
} catch {
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
} catch (error) {
|
|
469
|
-
const initConfig = getConfig$1();
|
|
470
|
-
const logger = initConfig?.logger;
|
|
471
|
-
if (logger?.error) {
|
|
472
|
-
logger.error(
|
|
473
|
-
{
|
|
474
|
-
err: error instanceof Error ? error : void 0
|
|
475
|
-
},
|
|
476
|
-
`[autotel] Auto-flush failed${error instanceof Error ? "" : `: ${String(error)}`}`
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
const spanOptions = {};
|
|
482
|
-
if (options.startNewRoot) {
|
|
483
|
-
spanOptions.root = true;
|
|
484
|
-
}
|
|
485
|
-
if (options.spanKind !== void 0) {
|
|
486
|
-
spanOptions.kind = options.spanKind;
|
|
487
|
-
}
|
|
488
|
-
const parentContext = getActiveContextWithBaggage();
|
|
489
|
-
return tracer.startActiveSpan(
|
|
490
|
-
spanName,
|
|
491
|
-
spanOptions,
|
|
492
|
-
parentContext,
|
|
493
|
-
async (span2) => {
|
|
494
|
-
return runInOperationContext(spanName, async () => {
|
|
495
|
-
let shouldKeepSpan = true;
|
|
496
|
-
setSpanName(span2, spanName);
|
|
497
|
-
const initialContext = context.active();
|
|
498
|
-
const contextStorage = getContextStorage();
|
|
499
|
-
if (!contextStorage.getStore()) {
|
|
500
|
-
enterOrRun(contextStorage, initialContext);
|
|
501
|
-
}
|
|
502
|
-
const ctxValue = createTraceContext(span2);
|
|
503
|
-
const fn = fnFactory(ctxValue);
|
|
504
|
-
const argsAttributes = {
|
|
505
|
-
...captureInputAttrs(args, options.captureInput),
|
|
506
|
-
...options.attributesFromArgs ? options.attributesFromArgs(args) : {}
|
|
507
|
-
};
|
|
508
|
-
const handleTailSampling = (success, duration, error) => {
|
|
509
|
-
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
510
|
-
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
511
|
-
success,
|
|
512
|
-
duration,
|
|
513
|
-
error
|
|
514
|
-
});
|
|
515
|
-
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
516
|
-
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
const onSuccess = async (result) => {
|
|
520
|
-
const duration = performance.now() - startTime;
|
|
521
|
-
callCounter?.add(1, {
|
|
522
|
-
operation: spanName,
|
|
523
|
-
status: "success"
|
|
524
|
-
});
|
|
525
|
-
durationHistogram?.record(duration, {
|
|
526
|
-
operation: spanName,
|
|
527
|
-
status: "success"
|
|
528
|
-
});
|
|
529
|
-
const resultAttributes = {
|
|
530
|
-
...captureOutputAttrs(result, options.captureOutput),
|
|
531
|
-
...options.attributesFromResult ? options.attributesFromResult(result) : {}
|
|
532
|
-
};
|
|
533
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
534
|
-
span2.setAttributes({
|
|
535
|
-
...argsAttributes,
|
|
536
|
-
...resultAttributes,
|
|
537
|
-
"operation.name": spanName,
|
|
538
|
-
"code.function": spanName,
|
|
539
|
-
"operation.duration": duration,
|
|
540
|
-
"operation.success": true
|
|
541
|
-
});
|
|
542
|
-
handleTailSampling(true, duration);
|
|
543
|
-
span2.end();
|
|
544
|
-
await flushIfNeeded();
|
|
545
|
-
return result;
|
|
546
|
-
};
|
|
547
|
-
const onError = async (error) => {
|
|
548
|
-
const duration = performance.now() - startTime;
|
|
549
|
-
callCounter?.add(1, {
|
|
550
|
-
operation: spanName,
|
|
551
|
-
status: "error"
|
|
552
|
-
});
|
|
553
|
-
durationHistogram?.record(duration, {
|
|
554
|
-
operation: spanName,
|
|
555
|
-
status: "error"
|
|
556
|
-
});
|
|
557
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
558
|
-
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
559
|
-
span2.setStatus({
|
|
560
|
-
code: SpanStatusCode.ERROR,
|
|
561
|
-
message: truncatedMessage
|
|
562
|
-
});
|
|
563
|
-
span2.setAttributes({
|
|
564
|
-
...argsAttributes,
|
|
565
|
-
"operation.name": spanName,
|
|
566
|
-
"code.function": spanName,
|
|
567
|
-
"operation.duration": duration,
|
|
568
|
-
"operation.success": false,
|
|
569
|
-
error: true,
|
|
570
|
-
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
571
|
-
"exception.message": truncatedMessage
|
|
572
|
-
});
|
|
573
|
-
if (error instanceof Error && error.stack) {
|
|
574
|
-
span2.setAttribute(
|
|
575
|
-
"exception.stack",
|
|
576
|
-
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
span2.recordException(
|
|
580
|
-
error instanceof Error ? error : new Error(String(error))
|
|
581
|
-
);
|
|
582
|
-
handleTailSampling(false, duration, error);
|
|
583
|
-
span2.end();
|
|
584
|
-
await flushIfNeeded();
|
|
585
|
-
throw error;
|
|
586
|
-
};
|
|
587
|
-
try {
|
|
588
|
-
callCounter?.add(1, {
|
|
589
|
-
operation: spanName,
|
|
590
|
-
status: "started"
|
|
591
|
-
});
|
|
592
|
-
const executeWithContext = async () => {
|
|
593
|
-
const currentContext = getActiveContextWithBaggage();
|
|
594
|
-
return context.with(currentContext, async () => {
|
|
595
|
-
return fn.call(this, ...args);
|
|
596
|
-
});
|
|
597
|
-
};
|
|
598
|
-
const result = await executeWithContext();
|
|
599
|
-
return await onSuccess(result);
|
|
600
|
-
} catch (error) {
|
|
601
|
-
await onError(error);
|
|
602
|
-
throw error;
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
);
|
|
607
|
-
};
|
|
608
|
-
wrappedFunction[INSTRUMENTED_SYMBOL] = true;
|
|
609
|
-
Object.defineProperty(wrappedFunction, "name", {
|
|
610
|
-
value: tempFn.name || "trace",
|
|
611
|
-
configurable: true
|
|
612
|
-
});
|
|
613
|
-
return wrappedFunction;
|
|
614
|
-
}
|
|
615
|
-
function wrapWithTracingSync(fnFactory, options, variableName) {
|
|
616
|
-
if (hasInstrumentationFlag(fnFactory)) ;
|
|
617
|
-
const config = getConfig();
|
|
618
|
-
const tracer = config.tracer;
|
|
619
|
-
const meter = config.meter;
|
|
620
|
-
const sampler = options.sampler || new AlwaysSampler();
|
|
621
|
-
const tempFn = fnFactory(createDummyCtx());
|
|
622
|
-
const spanName = getSpanName(options, tempFn, variableName);
|
|
623
|
-
const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
|
|
624
|
-
description: `Call count for ${spanName}`,
|
|
625
|
-
unit: "1"
|
|
626
|
-
}) : void 0;
|
|
627
|
-
const durationHistogram = options.withMetrics ? meter.createHistogram(`${spanName}.duration`, {
|
|
628
|
-
description: `Duration for ${spanName}`,
|
|
629
|
-
unit: "ms"
|
|
630
|
-
}) : void 0;
|
|
631
|
-
function wrappedFunction(...args) {
|
|
632
|
-
const samplingContext = {
|
|
633
|
-
operationName: spanName,
|
|
634
|
-
args,
|
|
635
|
-
metadata: {}
|
|
636
|
-
};
|
|
637
|
-
const shouldSample = sampler.shouldSample(samplingContext);
|
|
638
|
-
const needsTailSampling = "needsTailSampling" in sampler && typeof sampler.needsTailSampling === "function" ? sampler.needsTailSampling() : false;
|
|
639
|
-
if (!shouldSample && !needsTailSampling) {
|
|
640
|
-
const fn = fnFactory(createDummyCtx());
|
|
641
|
-
return fn.call(this, ...args);
|
|
642
|
-
}
|
|
643
|
-
const startTime = performance.now();
|
|
644
|
-
const isRootSpan = options.startNewRoot || trace$1.getActiveSpan() === void 0;
|
|
645
|
-
const shouldAutoFlush = options.flushOnRootSpanEnd ?? getConfig$1()?.flushOnRootSpanEnd ?? true;
|
|
646
|
-
const shouldAutoFlushSpans = getConfig$1()?.forceFlushOnShutdown ?? false;
|
|
647
|
-
const flushIfNeeded = () => {
|
|
648
|
-
if (!shouldAutoFlush || !isRootSpan) return;
|
|
649
|
-
const queue = getEventQueue();
|
|
650
|
-
if (queue && queue.size() > 0) {
|
|
651
|
-
void queue.flush().catch((error) => {
|
|
652
|
-
const initConfig = getConfig$1();
|
|
653
|
-
const logger = initConfig?.logger;
|
|
654
|
-
if (logger?.error) {
|
|
655
|
-
logger.error(
|
|
656
|
-
{
|
|
657
|
-
err: error instanceof Error ? error : void 0
|
|
658
|
-
},
|
|
659
|
-
`[autotel] Auto-flush failed${error instanceof Error ? "" : `: ${String(error)}`}`
|
|
660
|
-
);
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
if (shouldAutoFlushSpans) {
|
|
665
|
-
const sdk = getSdk();
|
|
666
|
-
if (sdk) {
|
|
667
|
-
try {
|
|
668
|
-
const sdkAny = sdk;
|
|
669
|
-
if (typeof sdkAny.getTracerProvider === "function") {
|
|
670
|
-
const tracerProvider = sdkAny.getTracerProvider();
|
|
671
|
-
if (tracerProvider && typeof tracerProvider.forceFlush === "function") {
|
|
672
|
-
void tracerProvider.forceFlush().catch((error) => {
|
|
673
|
-
const initConfig = getConfig$1();
|
|
674
|
-
const logger = initConfig?.logger;
|
|
675
|
-
if (logger?.error) {
|
|
676
|
-
logger.error(
|
|
677
|
-
{
|
|
678
|
-
err: error instanceof Error ? error : void 0
|
|
679
|
-
},
|
|
680
|
-
`[autotel] Span flush failed${error instanceof Error ? "" : `: ${String(error)}`}`
|
|
681
|
-
);
|
|
682
|
-
}
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
} catch {
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
const spanOptions = {};
|
|
692
|
-
if (options.startNewRoot) {
|
|
693
|
-
spanOptions.root = true;
|
|
694
|
-
}
|
|
695
|
-
if (options.spanKind !== void 0) {
|
|
696
|
-
spanOptions.kind = options.spanKind;
|
|
697
|
-
}
|
|
698
|
-
const parentContext = getActiveContextWithBaggage();
|
|
699
|
-
return tracer.startActiveSpan(
|
|
700
|
-
spanName,
|
|
701
|
-
spanOptions,
|
|
702
|
-
parentContext,
|
|
703
|
-
(span2) => {
|
|
704
|
-
return runInOperationContext(spanName, () => {
|
|
705
|
-
let shouldKeepSpan = true;
|
|
706
|
-
setSpanName(span2, spanName);
|
|
707
|
-
const ctxValue = createTraceContext(span2);
|
|
708
|
-
const fn = fnFactory(ctxValue);
|
|
709
|
-
const argsAttributes = {
|
|
710
|
-
...captureInputAttrs(args, options.captureInput),
|
|
711
|
-
...options.attributesFromArgs ? options.attributesFromArgs(args) : {}
|
|
712
|
-
};
|
|
713
|
-
const handleTailSampling = (success, duration, error) => {
|
|
714
|
-
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
715
|
-
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
716
|
-
success,
|
|
717
|
-
duration,
|
|
718
|
-
error
|
|
719
|
-
});
|
|
720
|
-
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
721
|
-
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
const onSuccess = (result) => {
|
|
725
|
-
const duration = performance.now() - startTime;
|
|
726
|
-
callCounter?.add(1, {
|
|
727
|
-
operation: spanName,
|
|
728
|
-
status: "success"
|
|
729
|
-
});
|
|
730
|
-
durationHistogram?.record(duration, {
|
|
731
|
-
operation: spanName,
|
|
732
|
-
status: "success"
|
|
733
|
-
});
|
|
734
|
-
const resultAttributes = {
|
|
735
|
-
...captureOutputAttrs(result, options.captureOutput),
|
|
736
|
-
...options.attributesFromResult ? options.attributesFromResult(result) : {}
|
|
737
|
-
};
|
|
738
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
739
|
-
span2.setAttributes({
|
|
740
|
-
...argsAttributes,
|
|
741
|
-
...resultAttributes,
|
|
742
|
-
"operation.name": spanName,
|
|
743
|
-
"code.function": spanName,
|
|
744
|
-
"operation.duration": duration,
|
|
745
|
-
"operation.success": true
|
|
746
|
-
});
|
|
747
|
-
handleTailSampling(true, duration);
|
|
748
|
-
span2.end();
|
|
749
|
-
void flushIfNeeded();
|
|
750
|
-
return result;
|
|
751
|
-
};
|
|
752
|
-
const onError = (error) => {
|
|
753
|
-
const duration = performance.now() - startTime;
|
|
754
|
-
callCounter?.add(1, {
|
|
755
|
-
operation: spanName,
|
|
756
|
-
status: "error"
|
|
757
|
-
});
|
|
758
|
-
durationHistogram?.record(duration, {
|
|
759
|
-
operation: spanName,
|
|
760
|
-
status: "error"
|
|
761
|
-
});
|
|
762
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
763
|
-
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
764
|
-
span2.setStatus({
|
|
765
|
-
code: SpanStatusCode.ERROR,
|
|
766
|
-
message: truncatedMessage
|
|
767
|
-
});
|
|
768
|
-
span2.setAttributes({
|
|
769
|
-
...argsAttributes,
|
|
770
|
-
"operation.name": spanName,
|
|
771
|
-
"code.function": spanName,
|
|
772
|
-
"operation.duration": duration,
|
|
773
|
-
"operation.success": false,
|
|
774
|
-
error: true,
|
|
775
|
-
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
776
|
-
"exception.message": truncatedMessage
|
|
777
|
-
});
|
|
778
|
-
span2.recordException(
|
|
779
|
-
error instanceof Error ? error : new Error(String(error))
|
|
780
|
-
);
|
|
781
|
-
handleTailSampling(false, duration, error);
|
|
782
|
-
span2.end();
|
|
783
|
-
void flushIfNeeded();
|
|
784
|
-
throw error;
|
|
785
|
-
};
|
|
786
|
-
try {
|
|
787
|
-
callCounter?.add(1, {
|
|
788
|
-
operation: spanName,
|
|
789
|
-
status: "started"
|
|
790
|
-
});
|
|
791
|
-
const result = fn.call(this, ...args);
|
|
792
|
-
if (result instanceof Promise) {
|
|
793
|
-
return result.then(onSuccess, onError);
|
|
794
|
-
}
|
|
795
|
-
return onSuccess(result);
|
|
796
|
-
} catch (error) {
|
|
797
|
-
return onError(error);
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
);
|
|
802
|
-
}
|
|
803
|
-
wrappedFunction[INSTRUMENTED_SYMBOL] = true;
|
|
804
|
-
Object.defineProperty(wrappedFunction, "name", {
|
|
805
|
-
value: tempFn.name || "trace",
|
|
806
|
-
configurable: true
|
|
807
|
-
});
|
|
808
|
-
return wrappedFunction;
|
|
809
|
-
}
|
|
810
|
-
function executeImmediately(fn, options) {
|
|
811
|
-
const config = getConfig();
|
|
812
|
-
const tracer = config.tracer;
|
|
813
|
-
const meter = config.meter;
|
|
814
|
-
const sampler = options.sampler || new AlwaysSampler();
|
|
815
|
-
const spanName = options.name || "anonymous";
|
|
816
|
-
const samplingContext = {
|
|
817
|
-
operationName: spanName,
|
|
818
|
-
args: [],
|
|
819
|
-
metadata: {}
|
|
820
|
-
};
|
|
821
|
-
const shouldSample = sampler.shouldSample(samplingContext);
|
|
822
|
-
const needsTailSampling = "needsTailSampling" in sampler && typeof sampler.needsTailSampling === "function" ? sampler.needsTailSampling() : false;
|
|
823
|
-
if (!shouldSample && !needsTailSampling) {
|
|
824
|
-
return fn(createDummyCtx());
|
|
825
|
-
}
|
|
826
|
-
const startTime = performance.now();
|
|
827
|
-
const isRootSpan = options.startNewRoot || trace$1.getActiveSpan() === void 0;
|
|
828
|
-
const shouldAutoFlush = options.flushOnRootSpanEnd ?? getConfig$1()?.flushOnRootSpanEnd ?? true;
|
|
829
|
-
const shouldAutoFlushSpans = getConfig$1()?.forceFlushOnShutdown ?? false;
|
|
830
|
-
const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
|
|
831
|
-
description: `Call count for ${spanName}`,
|
|
832
|
-
unit: "1"
|
|
833
|
-
}) : void 0;
|
|
834
|
-
const durationHistogram = options.withMetrics ? meter.createHistogram(`${spanName}.duration`, {
|
|
835
|
-
description: `Duration for ${spanName}`,
|
|
836
|
-
unit: "ms"
|
|
837
|
-
}) : void 0;
|
|
838
|
-
const flushIfNeeded = async () => {
|
|
839
|
-
if (!shouldAutoFlush || !isRootSpan) return;
|
|
840
|
-
try {
|
|
841
|
-
const queue = getEventQueue();
|
|
842
|
-
if (queue && queue.size() > 0) {
|
|
843
|
-
await queue.flush();
|
|
844
|
-
}
|
|
845
|
-
if (shouldAutoFlushSpans) {
|
|
846
|
-
const sdk = getSdk();
|
|
847
|
-
if (sdk) {
|
|
848
|
-
try {
|
|
849
|
-
const sdkAny = sdk;
|
|
850
|
-
if (typeof sdkAny.getTracerProvider === "function") {
|
|
851
|
-
const tracerProvider = sdkAny.getTracerProvider();
|
|
852
|
-
if (tracerProvider && typeof tracerProvider.forceFlush === "function") {
|
|
853
|
-
await tracerProvider.forceFlush();
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
} catch {
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
} catch (error) {
|
|
861
|
-
const initConfig = getConfig$1();
|
|
862
|
-
const logger = initConfig?.logger;
|
|
863
|
-
if (logger?.error) {
|
|
864
|
-
logger.error(
|
|
865
|
-
{
|
|
866
|
-
err: error instanceof Error ? error : void 0
|
|
867
|
-
},
|
|
868
|
-
`[autotel] Auto-flush failed${error instanceof Error ? "" : `: ${String(error)}`}`
|
|
869
|
-
);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
};
|
|
873
|
-
const spanOptions = {};
|
|
874
|
-
if (options.startNewRoot) {
|
|
875
|
-
spanOptions.root = true;
|
|
876
|
-
}
|
|
877
|
-
if (options.spanKind !== void 0) {
|
|
878
|
-
spanOptions.kind = options.spanKind;
|
|
879
|
-
}
|
|
880
|
-
const parentContext = getActiveContextWithBaggage();
|
|
881
|
-
return tracer.startActiveSpan(
|
|
882
|
-
spanName,
|
|
883
|
-
spanOptions,
|
|
884
|
-
parentContext,
|
|
885
|
-
(span2) => {
|
|
886
|
-
return runInOperationContext(spanName, () => {
|
|
887
|
-
let shouldKeepSpan = true;
|
|
888
|
-
setSpanName(span2, spanName);
|
|
889
|
-
const ctxValue = createTraceContext(span2);
|
|
890
|
-
const handleTailSampling = (success, duration, error) => {
|
|
891
|
-
if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
|
|
892
|
-
shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
|
|
893
|
-
success,
|
|
894
|
-
duration,
|
|
895
|
-
error
|
|
896
|
-
});
|
|
897
|
-
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_KEEP, shouldKeepSpan);
|
|
898
|
-
span2.setAttribute(AUTOTEL_SAMPLING_TAIL_EVALUATED, true);
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
const onSuccessSync = (result) => {
|
|
902
|
-
const duration = performance.now() - startTime;
|
|
903
|
-
callCounter?.add(1, {
|
|
904
|
-
operation: spanName,
|
|
905
|
-
status: "success"
|
|
906
|
-
});
|
|
907
|
-
durationHistogram?.record(duration, {
|
|
908
|
-
operation: spanName,
|
|
909
|
-
status: "success"
|
|
910
|
-
});
|
|
911
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
912
|
-
span2.setAttributes({
|
|
913
|
-
"operation.name": spanName,
|
|
914
|
-
"code.function": spanName,
|
|
915
|
-
"operation.duration": duration,
|
|
916
|
-
"operation.success": true
|
|
917
|
-
});
|
|
918
|
-
handleTailSampling(true, duration);
|
|
919
|
-
span2.end();
|
|
920
|
-
void flushIfNeeded();
|
|
921
|
-
return result;
|
|
922
|
-
};
|
|
923
|
-
const onErrorSync = (error) => {
|
|
924
|
-
const duration = performance.now() - startTime;
|
|
925
|
-
callCounter?.add(1, {
|
|
926
|
-
operation: spanName,
|
|
927
|
-
status: "error"
|
|
928
|
-
});
|
|
929
|
-
durationHistogram?.record(duration, {
|
|
930
|
-
operation: spanName,
|
|
931
|
-
status: "error"
|
|
932
|
-
});
|
|
933
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
934
|
-
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
935
|
-
span2.setStatus({
|
|
936
|
-
code: SpanStatusCode.ERROR,
|
|
937
|
-
message: truncatedMessage
|
|
938
|
-
});
|
|
939
|
-
span2.setAttributes({
|
|
940
|
-
"operation.name": spanName,
|
|
941
|
-
"code.function": spanName,
|
|
942
|
-
"operation.duration": duration,
|
|
943
|
-
"operation.success": false,
|
|
944
|
-
error: true,
|
|
945
|
-
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
946
|
-
"exception.message": truncatedMessage
|
|
947
|
-
});
|
|
948
|
-
if (error instanceof Error && error.stack) {
|
|
949
|
-
span2.setAttribute(
|
|
950
|
-
"exception.stack",
|
|
951
|
-
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
span2.recordException(
|
|
955
|
-
error instanceof Error ? error : new Error(String(error))
|
|
956
|
-
);
|
|
957
|
-
handleTailSampling(false, duration, error);
|
|
958
|
-
span2.end();
|
|
959
|
-
void flushIfNeeded();
|
|
960
|
-
throw error;
|
|
961
|
-
};
|
|
962
|
-
const onSuccessAsync = async (result) => {
|
|
963
|
-
const duration = performance.now() - startTime;
|
|
964
|
-
callCounter?.add(1, {
|
|
965
|
-
operation: spanName,
|
|
966
|
-
status: "success"
|
|
967
|
-
});
|
|
968
|
-
durationHistogram?.record(duration, {
|
|
969
|
-
operation: spanName,
|
|
970
|
-
status: "success"
|
|
971
|
-
});
|
|
972
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
973
|
-
span2.setAttributes({
|
|
974
|
-
"operation.name": spanName,
|
|
975
|
-
"code.function": spanName,
|
|
976
|
-
"operation.duration": duration,
|
|
977
|
-
"operation.success": true
|
|
978
|
-
});
|
|
979
|
-
handleTailSampling(true, duration);
|
|
980
|
-
span2.end();
|
|
981
|
-
await flushIfNeeded();
|
|
982
|
-
return result;
|
|
983
|
-
};
|
|
984
|
-
const onErrorAsync = async (error) => {
|
|
985
|
-
const duration = performance.now() - startTime;
|
|
986
|
-
callCounter?.add(1, {
|
|
987
|
-
operation: spanName,
|
|
988
|
-
status: "error"
|
|
989
|
-
});
|
|
990
|
-
durationHistogram?.record(duration, {
|
|
991
|
-
operation: spanName,
|
|
992
|
-
status: "error"
|
|
993
|
-
});
|
|
994
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
995
|
-
const truncatedMessage = truncateErrorMessage(errorMessage);
|
|
996
|
-
span2.setStatus({
|
|
997
|
-
code: SpanStatusCode.ERROR,
|
|
998
|
-
message: truncatedMessage
|
|
999
|
-
});
|
|
1000
|
-
span2.setAttributes({
|
|
1001
|
-
"operation.name": spanName,
|
|
1002
|
-
"code.function": spanName,
|
|
1003
|
-
"operation.duration": duration,
|
|
1004
|
-
"operation.success": false,
|
|
1005
|
-
error: true,
|
|
1006
|
-
"exception.type": error instanceof Error ? error.constructor.name : "Error",
|
|
1007
|
-
"exception.message": truncatedMessage
|
|
1008
|
-
});
|
|
1009
|
-
if (error instanceof Error && error.stack) {
|
|
1010
|
-
span2.setAttribute(
|
|
1011
|
-
"exception.stack",
|
|
1012
|
-
error.stack.slice(0, MAX_ERROR_MESSAGE_LENGTH)
|
|
1013
|
-
);
|
|
1014
|
-
}
|
|
1015
|
-
span2.recordException(
|
|
1016
|
-
error instanceof Error ? error : new Error(String(error))
|
|
1017
|
-
);
|
|
1018
|
-
handleTailSampling(false, duration, error);
|
|
1019
|
-
span2.end();
|
|
1020
|
-
await flushIfNeeded();
|
|
1021
|
-
throw error;
|
|
1022
|
-
};
|
|
1023
|
-
try {
|
|
1024
|
-
callCounter?.add(1, {
|
|
1025
|
-
operation: spanName,
|
|
1026
|
-
status: "started"
|
|
1027
|
-
});
|
|
1028
|
-
const result = fn(ctxValue);
|
|
1029
|
-
if (result instanceof Promise) {
|
|
1030
|
-
return result.then(onSuccessAsync, onErrorAsync);
|
|
1031
|
-
}
|
|
1032
|
-
return onSuccessSync(result);
|
|
1033
|
-
} catch (error) {
|
|
1034
|
-
return onErrorSync(error);
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
);
|
|
1039
|
-
}
|
|
1040
|
-
function trace(fnOrNameOrOptions, maybeFn) {
|
|
1041
|
-
if (typeof fnOrNameOrOptions === "function") {
|
|
1042
|
-
if (looksLikeTraceFactory(fnOrNameOrOptions) && !isFactoryReturningFunction(
|
|
1043
|
-
fnOrNameOrOptions
|
|
1044
|
-
)) {
|
|
1045
|
-
return executeImmediately(
|
|
1046
|
-
fnOrNameOrOptions,
|
|
1047
|
-
{}
|
|
1048
|
-
);
|
|
1049
|
-
}
|
|
1050
|
-
return wrapFactoryWithTracing(
|
|
1051
|
-
fnOrNameOrOptions,
|
|
1052
|
-
{}
|
|
1053
|
-
);
|
|
1054
|
-
}
|
|
1055
|
-
if (typeof fnOrNameOrOptions === "string") {
|
|
1056
|
-
if (!maybeFn) {
|
|
1057
|
-
throw new Error("trace(name, fn): fn is required");
|
|
1058
|
-
}
|
|
1059
|
-
if (looksLikeTraceFactory(maybeFn) && !isFactoryReturningFunction(maybeFn)) {
|
|
1060
|
-
return executeImmediately(
|
|
1061
|
-
maybeFn,
|
|
1062
|
-
{ name: fnOrNameOrOptions }
|
|
1063
|
-
);
|
|
1064
|
-
}
|
|
1065
|
-
return wrapFactoryWithTracing(
|
|
1066
|
-
maybeFn,
|
|
1067
|
-
{ name: fnOrNameOrOptions }
|
|
1068
|
-
);
|
|
1069
|
-
}
|
|
1070
|
-
if (!maybeFn) {
|
|
1071
|
-
throw new Error("trace(options, fn): fn is required");
|
|
1072
|
-
}
|
|
1073
|
-
if (looksLikeTraceFactory(maybeFn) && !isFactoryReturningFunction(maybeFn)) {
|
|
1074
|
-
return executeImmediately(
|
|
1075
|
-
maybeFn,
|
|
1076
|
-
fnOrNameOrOptions
|
|
1077
|
-
);
|
|
1078
|
-
}
|
|
1079
|
-
return wrapFactoryWithTracing(
|
|
1080
|
-
maybeFn,
|
|
1081
|
-
fnOrNameOrOptions
|
|
1082
|
-
);
|
|
1083
|
-
}
|
|
1084
|
-
function withTracing(options = {}) {
|
|
1085
|
-
return (fnFactory) => wrapFactoryWithTracing(fnFactory, options);
|
|
1086
|
-
}
|
|
1087
|
-
function instrument(options) {
|
|
1088
|
-
const { functions, ...tracingOptions } = options;
|
|
1089
|
-
const instrumented = {};
|
|
1090
|
-
for (const key of Object.keys(functions)) {
|
|
1091
|
-
const typedKey = key;
|
|
1092
|
-
const fn = functions[typedKey];
|
|
1093
|
-
if (!fn || typeof fn !== "function") {
|
|
1094
|
-
instrumented[typedKey] = fn;
|
|
1095
|
-
continue;
|
|
1096
|
-
}
|
|
1097
|
-
if (shouldSkip(key, fn, tracingOptions.skip)) {
|
|
1098
|
-
instrumented[typedKey] = fn;
|
|
1099
|
-
continue;
|
|
1100
|
-
}
|
|
1101
|
-
const fnOptions = {
|
|
1102
|
-
...tracingOptions,
|
|
1103
|
-
...tracingOptions.overrides?.[key],
|
|
1104
|
-
// If no explicit name, use key as function name
|
|
1105
|
-
name: tracingOptions.overrides?.[key]?.name
|
|
1106
|
-
};
|
|
1107
|
-
const boundFn = fn.bind(functions);
|
|
1108
|
-
const fnFactory = (ctx2) => {
|
|
1109
|
-
return boundFn;
|
|
1110
|
-
};
|
|
1111
|
-
instrumented[typedKey] = wrapFactoryWithTracing(
|
|
1112
|
-
fnFactory,
|
|
1113
|
-
fnOptions,
|
|
1114
|
-
key
|
|
1115
|
-
);
|
|
1116
|
-
}
|
|
1117
|
-
return instrumented;
|
|
1118
|
-
}
|
|
1119
|
-
function span(nameOrOptions, fn) {
|
|
1120
|
-
const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions;
|
|
1121
|
-
const config = getConfig();
|
|
1122
|
-
const tracer = config.tracer;
|
|
1123
|
-
const { name, attributes } = options;
|
|
1124
|
-
const executeSpan = (span2) => {
|
|
1125
|
-
return runInOperationContext(name, () => {
|
|
1126
|
-
try {
|
|
1127
|
-
if (attributes) {
|
|
1128
|
-
for (const [key, value] of Object.entries(attributes)) {
|
|
1129
|
-
span2.setAttribute(key, value);
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
const result2 = fn(span2);
|
|
1133
|
-
if (result2 instanceof Promise) {
|
|
1134
|
-
return result2.then((resolved) => {
|
|
1135
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1136
|
-
span2.end();
|
|
1137
|
-
return resolved;
|
|
1138
|
-
}).catch((error) => {
|
|
1139
|
-
const errorMessage = error instanceof Error ? error.message.slice(0, MAX_ERROR_MESSAGE_LENGTH) : String(error).slice(0, MAX_ERROR_MESSAGE_LENGTH);
|
|
1140
|
-
span2.setAttribute("error.message", errorMessage);
|
|
1141
|
-
span2.setStatus({
|
|
1142
|
-
code: SpanStatusCode.ERROR,
|
|
1143
|
-
message: errorMessage
|
|
1144
|
-
});
|
|
1145
|
-
span2.recordException(
|
|
1146
|
-
error instanceof Error ? error : new Error(String(error))
|
|
1147
|
-
);
|
|
1148
|
-
span2.end();
|
|
1149
|
-
throw error;
|
|
1150
|
-
});
|
|
1151
|
-
} else {
|
|
1152
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1153
|
-
span2.end();
|
|
1154
|
-
return result2;
|
|
1155
|
-
}
|
|
1156
|
-
} catch (error) {
|
|
1157
|
-
const errorMessage = error instanceof Error ? error.message.slice(0, MAX_ERROR_MESSAGE_LENGTH) : String(error).slice(0, MAX_ERROR_MESSAGE_LENGTH);
|
|
1158
|
-
span2.setAttribute("error.message", errorMessage);
|
|
1159
|
-
span2.setStatus({
|
|
1160
|
-
code: SpanStatusCode.ERROR,
|
|
1161
|
-
message: errorMessage
|
|
1162
|
-
});
|
|
1163
|
-
span2.recordException(
|
|
1164
|
-
error instanceof Error ? error : new Error(String(error))
|
|
1165
|
-
);
|
|
1166
|
-
span2.end();
|
|
1167
|
-
throw error;
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1170
|
-
};
|
|
1171
|
-
const parentContext = getActiveContextWithBaggage();
|
|
1172
|
-
const result = tracer.startActiveSpan(name, {}, parentContext, executeSpan);
|
|
1173
|
-
if (result instanceof Promise) {
|
|
1174
|
-
return result;
|
|
1175
|
-
}
|
|
1176
|
-
return result;
|
|
1177
|
-
}
|
|
1178
|
-
async function withNewContext(options) {
|
|
1179
|
-
const { fn } = options;
|
|
1180
|
-
const config = getConfig();
|
|
1181
|
-
const tracer = config.tracer;
|
|
1182
|
-
return tracer.startActiveSpan("root", { root: true }, async (span2) => {
|
|
1183
|
-
try {
|
|
1184
|
-
const result = await fn();
|
|
1185
|
-
span2.setStatus({ code: SpanStatusCode.OK });
|
|
1186
|
-
return result;
|
|
1187
|
-
} catch (error) {
|
|
1188
|
-
span2.recordException(
|
|
1189
|
-
error instanceof Error ? error : new Error(String(error))
|
|
1190
|
-
);
|
|
1191
|
-
span2.setStatus({ code: SpanStatusCode.ERROR });
|
|
1192
|
-
throw error;
|
|
1193
|
-
} finally {
|
|
1194
|
-
span2.end();
|
|
1195
|
-
}
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
function withBaggage(options) {
|
|
1199
|
-
const { baggage: baggageEntries, fn } = options;
|
|
1200
|
-
const currentContext = context.active();
|
|
1201
|
-
let updatedBaggage = propagation.getBaggage(currentContext) ?? propagation.createBaggage();
|
|
1202
|
-
for (const [key, value] of Object.entries(baggageEntries)) {
|
|
1203
|
-
updatedBaggage = updatedBaggage.setEntry(key, { value });
|
|
1204
|
-
}
|
|
1205
|
-
const newContext = propagation.setBaggage(currentContext, updatedBaggage);
|
|
1206
|
-
const ctxStorage = getContextStorage();
|
|
1207
|
-
const previousStored = ctxStorage.getStore();
|
|
1208
|
-
const baggageEnrichedStored = previousStored ? { value: propagation.setBaggage(previousStored.value, updatedBaggage) } : { value: newContext };
|
|
1209
|
-
const result = previousStored ? ctxStorage.run(baggageEnrichedStored, () => context.with(newContext, fn)) : context.with(newContext, fn);
|
|
1210
|
-
if (result instanceof Promise) {
|
|
1211
|
-
return result.then(
|
|
1212
|
-
(value) => {
|
|
1213
|
-
if (previousStored) {
|
|
1214
|
-
return ctxStorage.run(previousStored, () => value);
|
|
1215
|
-
}
|
|
1216
|
-
return value;
|
|
1217
|
-
},
|
|
1218
|
-
(error) => {
|
|
1219
|
-
if (previousStored) {
|
|
1220
|
-
return ctxStorage.run(previousStored, () => {
|
|
1221
|
-
throw error;
|
|
1222
|
-
});
|
|
1223
|
-
}
|
|
1224
|
-
throw error;
|
|
1225
|
-
}
|
|
1226
|
-
);
|
|
1227
|
-
}
|
|
1228
|
-
return result;
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
export { ctx, instrument, markAsImmediate, span, trace, withBaggage, withNewContext, withTracing };
|
|
1232
|
-
//# sourceMappingURL=chunk-T7JO2TCP.js.map
|
|
1233
|
-
//# sourceMappingURL=chunk-T7JO2TCP.js.map
|