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
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
let _opentelemetry_api_logs = require("@opentelemetry/api-logs");
|
|
2
|
+
|
|
3
|
+
//#region src/pretty-log-formatter.ts
|
|
4
|
+
const RESET = "\x1B[0m";
|
|
5
|
+
const DIM = "\x1B[2m";
|
|
6
|
+
const BOLD = "\x1B[1m";
|
|
7
|
+
const RED = "\x1B[31m";
|
|
8
|
+
const YELLOW = "\x1B[33m";
|
|
9
|
+
const GREEN = "\x1B[32m";
|
|
10
|
+
const CYAN = "\x1B[36m";
|
|
11
|
+
const LEVEL_COLORS = {
|
|
12
|
+
debug: "\x1B[90m",
|
|
13
|
+
info: GREEN,
|
|
14
|
+
warn: YELLOW,
|
|
15
|
+
error: RED
|
|
16
|
+
};
|
|
17
|
+
/** Internal OTel attributes to skip in pretty output. */
|
|
18
|
+
const SKIP_PREFIXES = [
|
|
19
|
+
"telemetry.",
|
|
20
|
+
"otel.",
|
|
21
|
+
"process.",
|
|
22
|
+
"os.",
|
|
23
|
+
"host.",
|
|
24
|
+
"service.",
|
|
25
|
+
"autotel."
|
|
26
|
+
];
|
|
27
|
+
const SKIP_KEYS = new Set([
|
|
28
|
+
"operation",
|
|
29
|
+
"traceId",
|
|
30
|
+
"spanId",
|
|
31
|
+
"correlationId",
|
|
32
|
+
"duration_ms",
|
|
33
|
+
"duration",
|
|
34
|
+
"status_code",
|
|
35
|
+
"status_message",
|
|
36
|
+
"timestamp",
|
|
37
|
+
"http.request.method",
|
|
38
|
+
"url.path",
|
|
39
|
+
"http.route",
|
|
40
|
+
"http.response.status_code"
|
|
41
|
+
]);
|
|
42
|
+
function useColor() {
|
|
43
|
+
if (typeof process !== "undefined") {
|
|
44
|
+
if (process.env.NO_COLOR) return false;
|
|
45
|
+
if (process.env.FORCE_COLOR) return true;
|
|
46
|
+
if (process.stdout?.isTTY) return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
function c(color, text) {
|
|
51
|
+
return useColor() ? `${color}${text}${RESET}` : text;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Format milliseconds into a human-readable duration string.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* formatDuration(45) // "45ms"
|
|
58
|
+
* formatDuration(1234) // "1.2s"
|
|
59
|
+
* formatDuration(65000) // "1m 5s"
|
|
60
|
+
*/
|
|
61
|
+
function formatDuration(ms) {
|
|
62
|
+
if (ms < 1e3) return `${Math.round(ms)}ms`;
|
|
63
|
+
if (ms < 6e4) {
|
|
64
|
+
const seconds = ms / 1e3;
|
|
65
|
+
return seconds < 10 ? `${seconds.toFixed(1)}s` : `${Math.round(seconds)}s`;
|
|
66
|
+
}
|
|
67
|
+
const minutes = Math.floor(ms / 6e4);
|
|
68
|
+
const seconds = Math.round(ms % 6e4 / 1e3);
|
|
69
|
+
return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;
|
|
70
|
+
}
|
|
71
|
+
function formatTime(iso) {
|
|
72
|
+
try {
|
|
73
|
+
return new Date(iso).toLocaleTimeString("en-GB", { hour12: false });
|
|
74
|
+
} catch {
|
|
75
|
+
return iso.slice(11, 19);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function formatValue(value) {
|
|
79
|
+
if (typeof value === "string") return value;
|
|
80
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
81
|
+
if (value == null) return "";
|
|
82
|
+
try {
|
|
83
|
+
return JSON.stringify(value);
|
|
84
|
+
} catch {
|
|
85
|
+
return String(value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Group flat dot-notation attributes into a nested tree for pretty display.
|
|
90
|
+
* e.g. { 'user.id': '1', 'user.plan': 'pro' } → { user: { id: '1', plan: 'pro' } }
|
|
91
|
+
*/
|
|
92
|
+
function groupAttributes(event) {
|
|
93
|
+
const tree = {};
|
|
94
|
+
for (const [key, value] of Object.entries(event)) {
|
|
95
|
+
if (SKIP_KEYS.has(key)) continue;
|
|
96
|
+
if (SKIP_PREFIXES.some((p) => key.startsWith(p))) continue;
|
|
97
|
+
if (value == null || value === "") continue;
|
|
98
|
+
const parts = key.split(".");
|
|
99
|
+
if (parts.length === 1) tree[key] = value;
|
|
100
|
+
else {
|
|
101
|
+
let current = tree;
|
|
102
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
103
|
+
const part = parts[i];
|
|
104
|
+
if (!(part in current) || typeof current[part] !== "object") current[part] = {};
|
|
105
|
+
current = current[part];
|
|
106
|
+
}
|
|
107
|
+
current[parts[parts.length - 1]] = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return tree;
|
|
111
|
+
}
|
|
112
|
+
function renderTree(obj, indent, isLast) {
|
|
113
|
+
const lines = [];
|
|
114
|
+
const entries = Object.entries(obj);
|
|
115
|
+
entries.forEach(([key, value], idx) => {
|
|
116
|
+
const last = idx === entries.length - 1;
|
|
117
|
+
const prefix = indent + (last ? "└─" : "├─") + " ";
|
|
118
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
119
|
+
const nested = value;
|
|
120
|
+
const flatValues = Object.entries(nested).filter(([, v]) => typeof v !== "object" || v === null);
|
|
121
|
+
if (Object.entries(nested).filter(([, v]) => typeof v === "object" && v !== null && !Array.isArray(v)).length === 0) {
|
|
122
|
+
const inline = flatValues.map(([k, v]) => `${c(CYAN, k)}=${formatValue(v)}`).join(" ");
|
|
123
|
+
lines.push(`${prefix}${c(BOLD, key)}: ${inline}`);
|
|
124
|
+
} else {
|
|
125
|
+
lines.push(`${prefix}${c(BOLD, key)}:`);
|
|
126
|
+
const nextIndent = indent + (last ? " " : "│ ");
|
|
127
|
+
lines.push(...renderTree(nested, nextIndent, [...isLast, last]));
|
|
128
|
+
}
|
|
129
|
+
} else lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);
|
|
130
|
+
});
|
|
131
|
+
return lines;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Format a canonical log line event as a pretty tree for development output.
|
|
135
|
+
*/
|
|
136
|
+
function formatPrettyLogLine(ctx) {
|
|
137
|
+
const { event, level, message } = ctx;
|
|
138
|
+
const timestamp = formatTime(String(event.timestamp ?? ""));
|
|
139
|
+
const service = event["service.name"] || event.service || "";
|
|
140
|
+
const method = event["http.request.method"] || "";
|
|
141
|
+
const path = event["http.route"] || event["url.path"] || "";
|
|
142
|
+
const status = event["http.response.status_code"] || event.status_code || "";
|
|
143
|
+
const duration = formatDuration(Number(event.duration_ms ?? 0));
|
|
144
|
+
const levelStr = c(LEVEL_COLORS[level] ?? "", level.toUpperCase().padEnd(5));
|
|
145
|
+
const parts = [c(DIM, timestamp), levelStr];
|
|
146
|
+
if (service) parts.push(c(DIM, `[${service}]`));
|
|
147
|
+
if (method) parts.push(c(BOLD, String(method)));
|
|
148
|
+
if (path) parts.push(String(path));
|
|
149
|
+
if (status) {
|
|
150
|
+
const statusNum = Number(status);
|
|
151
|
+
const statusColor = statusNum >= 500 ? RED : statusNum >= 400 ? YELLOW : GREEN;
|
|
152
|
+
parts.push(c(statusColor, String(status)));
|
|
153
|
+
}
|
|
154
|
+
parts.push(c(DIM, `in ${duration}`));
|
|
155
|
+
const header = parts.join(" ");
|
|
156
|
+
const tree = groupAttributes(event);
|
|
157
|
+
if (Object.keys(tree).length === 0) return header;
|
|
158
|
+
return [header, ...renderTree(tree, " ", [])].join("\n");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/processors/canonical-log-line-processor.ts
|
|
163
|
+
/**
|
|
164
|
+
* Span processor that automatically emits spans as canonical log lines
|
|
165
|
+
*
|
|
166
|
+
* When a span ends, this processor creates a log record with ALL span attributes.
|
|
167
|
+
* This implements the "canonical log line" pattern: one comprehensive event
|
|
168
|
+
* per request with all context, queryable as structured data.
|
|
169
|
+
*
|
|
170
|
+
* **Key Benefits:**
|
|
171
|
+
* - One log line per request with all context (wide event)
|
|
172
|
+
* - High-cardinality, high-dimensionality data for powerful queries
|
|
173
|
+
* - Automatic - no manual logging needed
|
|
174
|
+
* - Works with any logger or OTel Logs API
|
|
175
|
+
*
|
|
176
|
+
* @example Basic usage
|
|
177
|
+
* ```typescript
|
|
178
|
+
* import { init } from 'autotel';
|
|
179
|
+
*
|
|
180
|
+
* init({
|
|
181
|
+
* service: 'checkout-api',
|
|
182
|
+
* canonicalLogLines: {
|
|
183
|
+
* enabled: true,
|
|
184
|
+
* rootSpansOnly: true, // One canonical log line per request
|
|
185
|
+
* },
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @example With custom logger
|
|
190
|
+
* ```typescript
|
|
191
|
+
* import pino from 'pino';
|
|
192
|
+
* import { init } from 'autotel';
|
|
193
|
+
*
|
|
194
|
+
* const logger = pino();
|
|
195
|
+
* init({
|
|
196
|
+
* service: 'my-app',
|
|
197
|
+
* logger,
|
|
198
|
+
* canonicalLogLines: {
|
|
199
|
+
* enabled: true,
|
|
200
|
+
* logger, // Use Pino for canonical log lines
|
|
201
|
+
* rootSpansOnly: true,
|
|
202
|
+
* },
|
|
203
|
+
* });
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @example Custom message format
|
|
207
|
+
* ```typescript
|
|
208
|
+
* init({
|
|
209
|
+
* service: 'my-app',
|
|
210
|
+
* canonicalLogLines: {
|
|
211
|
+
* enabled: true,
|
|
212
|
+
* messageFormat: (span) => {
|
|
213
|
+
* const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';
|
|
214
|
+
* return `${span.name} [${status}]`;
|
|
215
|
+
* },
|
|
216
|
+
* },
|
|
217
|
+
* });
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
var CanonicalLogLineProcessor = class {
|
|
221
|
+
logger;
|
|
222
|
+
rootSpansOnly;
|
|
223
|
+
minLevel;
|
|
224
|
+
messageFormat;
|
|
225
|
+
includeResourceAttributes;
|
|
226
|
+
attributeRedactor;
|
|
227
|
+
shouldEmit;
|
|
228
|
+
drain;
|
|
229
|
+
onDrainError;
|
|
230
|
+
pretty;
|
|
231
|
+
getOTelLogger = null;
|
|
232
|
+
constructor(options = {}) {
|
|
233
|
+
this.logger = options.logger;
|
|
234
|
+
this.rootSpansOnly = options.rootSpansOnly ?? false;
|
|
235
|
+
this.minLevel = options.minLevel ?? "info";
|
|
236
|
+
this.messageFormat = options.messageFormat ?? ((span) => `[${span.name}] Request completed`);
|
|
237
|
+
this.includeResourceAttributes = options.includeResourceAttributes ?? true;
|
|
238
|
+
this.attributeRedactor = options.attributeRedactor;
|
|
239
|
+
this.shouldEmit = options.shouldEmit ?? this.buildKeepPredicate(options.keep);
|
|
240
|
+
this.drain = options.drain;
|
|
241
|
+
this.onDrainError = options.onDrainError;
|
|
242
|
+
this.pretty = options.pretty ?? (typeof process !== "undefined" && process.env.NODE_ENV === "development");
|
|
243
|
+
if (!this.logger) this.getOTelLogger = () => _opentelemetry_api_logs.logs.getLogger("autotel.canonical-log-line");
|
|
244
|
+
}
|
|
245
|
+
buildKeepPredicate(keep) {
|
|
246
|
+
if (!keep || keep.length === 0) return void 0;
|
|
247
|
+
return (ctx) => {
|
|
248
|
+
return keep.some((condition) => {
|
|
249
|
+
if (condition.status !== void 0) {
|
|
250
|
+
if (Number(ctx.event["http.response.status_code"] ?? 0) >= condition.status) return true;
|
|
251
|
+
}
|
|
252
|
+
if (condition.durationMs !== void 0 && Number(ctx.event.duration_ms ?? 0) >= condition.durationMs) return true;
|
|
253
|
+
if (condition.path !== void 0) {
|
|
254
|
+
if (String(ctx.event["http.route"] ?? ctx.event["url.path"] ?? "").startsWith(condition.path)) return true;
|
|
255
|
+
}
|
|
256
|
+
return false;
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
onStart() {}
|
|
261
|
+
onEnd(span) {
|
|
262
|
+
if (this.rootSpansOnly && span.parentSpanContext?.spanId && !span.parentSpanContext.isRemote) return;
|
|
263
|
+
const level = this.getLogLevel(span);
|
|
264
|
+
if (!this.shouldLog(level)) return;
|
|
265
|
+
const canonicalLogLine = this.buildCanonicalLogLine(span);
|
|
266
|
+
const message = this.messageFormat(span);
|
|
267
|
+
const eventContext = {
|
|
268
|
+
span,
|
|
269
|
+
level,
|
|
270
|
+
message,
|
|
271
|
+
event: canonicalLogLine
|
|
272
|
+
};
|
|
273
|
+
if (this.shouldEmit && !this.shouldEmit(eventContext)) return;
|
|
274
|
+
if (this.pretty) console.log(formatPrettyLogLine(eventContext));
|
|
275
|
+
if (this.logger) this.emitViaLogger(level, message, canonicalLogLine);
|
|
276
|
+
else if (this.getOTelLogger) {
|
|
277
|
+
const otelLogger = this.getOTelLogger();
|
|
278
|
+
this.emitViaOTel(level, message, canonicalLogLine, otelLogger);
|
|
279
|
+
}
|
|
280
|
+
if (this.drain) Promise.resolve(this.drain(eventContext)).catch((error) => {
|
|
281
|
+
if (this.onDrainError) {
|
|
282
|
+
this.onDrainError(error, eventContext);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
this.reportInternalWarning("canonicalLogLines.drain failed", error);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
buildCanonicalLogLine(span) {
|
|
289
|
+
const durationMs = span.duration[0] * 1e3 + span.duration[1] / 1e6;
|
|
290
|
+
const timestamp = (/* @__PURE__ */ new Date(span.startTime[0] * 1e3 + span.startTime[1] / 1e6)).toISOString();
|
|
291
|
+
const canonicalLogLine = {};
|
|
292
|
+
const attributes = this.redactAttributes(span.attributes);
|
|
293
|
+
Object.assign(canonicalLogLine, attributes);
|
|
294
|
+
if (this.includeResourceAttributes) {
|
|
295
|
+
const resourceAttrs = this.redactAttributes(span.resource.attributes);
|
|
296
|
+
Object.assign(canonicalLogLine, resourceAttrs);
|
|
297
|
+
}
|
|
298
|
+
canonicalLogLine.operation = span.name;
|
|
299
|
+
canonicalLogLine.traceId = span.spanContext().traceId;
|
|
300
|
+
canonicalLogLine.spanId = span.spanContext().spanId;
|
|
301
|
+
canonicalLogLine.correlationId = span.spanContext().traceId.slice(0, 16);
|
|
302
|
+
canonicalLogLine.duration_ms = Math.round(durationMs * 100) / 100;
|
|
303
|
+
canonicalLogLine.duration = formatDuration(durationMs);
|
|
304
|
+
canonicalLogLine.status_code = span.status.code;
|
|
305
|
+
canonicalLogLine.status_message = span.status.message || void 0;
|
|
306
|
+
canonicalLogLine.timestamp = timestamp;
|
|
307
|
+
return canonicalLogLine;
|
|
308
|
+
}
|
|
309
|
+
redactAttributes(attributes) {
|
|
310
|
+
if (!this.attributeRedactor) return { ...attributes };
|
|
311
|
+
const redacted = {};
|
|
312
|
+
for (const [key, value] of Object.entries(attributes)) if (value !== void 0) redacted[key] = this.attributeRedactor(key, value);
|
|
313
|
+
return redacted;
|
|
314
|
+
}
|
|
315
|
+
emitViaLogger(level, message, canonicalLogLine) {
|
|
316
|
+
this.logger[level](canonicalLogLine, message);
|
|
317
|
+
}
|
|
318
|
+
emitViaOTel(level, message, canonicalLogLine, otelLogger) {
|
|
319
|
+
const otelAttributes = {};
|
|
320
|
+
for (const [key, value] of Object.entries(canonicalLogLine)) if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") otelAttributes[key] = value;
|
|
321
|
+
else if (value !== null && value !== void 0) otelAttributes[key] = String(value);
|
|
322
|
+
otelLogger.emit({
|
|
323
|
+
severityNumber: this.getSeverityNumber(level),
|
|
324
|
+
severityText: level.toUpperCase(),
|
|
325
|
+
body: message,
|
|
326
|
+
attributes: otelAttributes
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
getLogLevel(span) {
|
|
330
|
+
const explicitLevel = span.attributes["autotel.log.level"];
|
|
331
|
+
if (explicitLevel === "debug" || explicitLevel === "info" || explicitLevel === "warn" || explicitLevel === "error") return explicitLevel;
|
|
332
|
+
if (span.status.code === 2) return "error";
|
|
333
|
+
return "info";
|
|
334
|
+
}
|
|
335
|
+
shouldLog(level) {
|
|
336
|
+
const levels = [
|
|
337
|
+
"debug",
|
|
338
|
+
"info",
|
|
339
|
+
"warn",
|
|
340
|
+
"error"
|
|
341
|
+
];
|
|
342
|
+
return levels.indexOf(level) >= levels.indexOf(this.minLevel);
|
|
343
|
+
}
|
|
344
|
+
getSeverityNumber(level) {
|
|
345
|
+
return {
|
|
346
|
+
debug: _opentelemetry_api_logs.SeverityNumber.DEBUG,
|
|
347
|
+
info: _opentelemetry_api_logs.SeverityNumber.INFO,
|
|
348
|
+
warn: _opentelemetry_api_logs.SeverityNumber.WARN,
|
|
349
|
+
error: _opentelemetry_api_logs.SeverityNumber.ERROR
|
|
350
|
+
}[level] ?? _opentelemetry_api_logs.SeverityNumber.INFO;
|
|
351
|
+
}
|
|
352
|
+
reportInternalWarning(message, error) {
|
|
353
|
+
const err = error instanceof Error ? error.message : String(error ?? "unknown error");
|
|
354
|
+
if (this.logger) {
|
|
355
|
+
this.logger.warn({ error: err }, `[autotel] ${message}`);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
console.warn(`[autotel] ${message}: ${err}`);
|
|
359
|
+
}
|
|
360
|
+
async forceFlush() {}
|
|
361
|
+
async shutdown() {}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
//#endregion
|
|
365
|
+
Object.defineProperty(exports, 'CanonicalLogLineProcessor', {
|
|
366
|
+
enumerable: true,
|
|
367
|
+
get: function () {
|
|
368
|
+
return CanonicalLogLineProcessor;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
Object.defineProperty(exports, 'formatDuration', {
|
|
372
|
+
enumerable: true,
|
|
373
|
+
get: function () {
|
|
374
|
+
return formatDuration;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
//# sourceMappingURL=canonical-log-line-processor--RlFDHhm.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor--RlFDHhm.cjs","names":["logs","SeverityNumber"],"sources":["../src/pretty-log-formatter.ts","../src/processors/canonical-log-line-processor.ts"],"sourcesContent":["import type { CanonicalLogLineEvent } from './processors/canonical-log-line-processor';\n\nconst RESET = '\\x1b[0m';\nconst DIM = '\\x1b[2m';\nconst BOLD = '\\x1b[1m';\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst GREEN = '\\x1b[32m';\nconst CYAN = '\\x1b[36m';\nconst GRAY = '\\x1b[90m';\n\nconst LEVEL_COLORS: Record<string, string> = {\n debug: GRAY,\n info: GREEN,\n warn: YELLOW,\n error: RED,\n};\n\n/** Internal OTel attributes to skip in pretty output. */\nconst SKIP_PREFIXES = [\n 'telemetry.',\n 'otel.',\n 'process.',\n 'os.',\n 'host.',\n 'service.',\n 'autotel.',\n];\n\nconst SKIP_KEYS = new Set([\n 'operation',\n 'traceId',\n 'spanId',\n 'correlationId',\n 'duration_ms',\n 'duration',\n 'status_code',\n 'status_message',\n 'timestamp',\n 'http.request.method',\n 'url.path',\n 'http.route',\n 'http.response.status_code',\n]);\n\nfunction useColor(): boolean {\n if (typeof process !== 'undefined') {\n if (process.env.NO_COLOR) return false;\n if (process.env.FORCE_COLOR) return true;\n if (process.stdout?.isTTY) return true;\n }\n return false;\n}\n\nfunction c(color: string, text: string): string {\n return useColor() ? `${color}${text}${RESET}` : text;\n}\n\n/**\n * Format milliseconds into a human-readable duration string.\n *\n * @example\n * formatDuration(45) // \"45ms\"\n * formatDuration(1234) // \"1.2s\"\n * formatDuration(65000) // \"1m 5s\"\n */\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) {\n const seconds = ms / 1000;\n return seconds < 10 ? `${seconds.toFixed(1)}s` : `${Math.round(seconds)}s`;\n }\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n}\n\nfunction formatTime(iso: string): string {\n try {\n const d = new Date(iso);\n return d.toLocaleTimeString('en-GB', { hour12: false });\n } catch {\n return iso.slice(11, 19);\n }\n}\n\nfunction formatValue(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n if (value == null) return '';\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Group flat dot-notation attributes into a nested tree for pretty display.\n * e.g. { 'user.id': '1', 'user.plan': 'pro' } → { user: { id: '1', plan: 'pro' } }\n */\nfunction groupAttributes(\n event: Record<string, unknown>,\n): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(event)) {\n if (SKIP_KEYS.has(key)) continue;\n if (SKIP_PREFIXES.some((p) => key.startsWith(p))) continue;\n if (value == null || value === '') continue;\n\n const parts = key.split('.');\n if (parts.length === 1) {\n tree[key] = value;\n } else {\n let current = tree;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i]!;\n if (!(part in current) || typeof current[part] !== 'object') {\n current[part] = {};\n }\n current = current[part] as Record<string, unknown>;\n }\n current[parts[parts.length - 1]!] = value;\n }\n }\n\n return tree;\n}\n\nfunction renderTree(\n obj: Record<string, unknown>,\n indent: string,\n isLast: boolean[],\n): string[] {\n const lines: string[] = [];\n const entries = Object.entries(obj);\n\n entries.forEach(([key, value], idx) => {\n const last = idx === entries.length - 1;\n const connector = last ? '\\u2514\\u2500' : '\\u251c\\u2500';\n const prefix = indent + connector + ' ';\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const nested = value as Record<string, unknown>;\n const flatValues = Object.entries(nested).filter(\n ([, v]) => typeof v !== 'object' || v === null,\n );\n const nestedObjs = Object.entries(nested).filter(\n ([, v]) => typeof v === 'object' && v !== null && !Array.isArray(v),\n );\n\n if (nestedObjs.length === 0) {\n const inline = flatValues\n .map(([k, v]) => `${c(CYAN, k)}=${formatValue(v)}`)\n .join(' ');\n lines.push(`${prefix}${c(BOLD, key)}: ${inline}`);\n } else {\n lines.push(`${prefix}${c(BOLD, key)}:`);\n const nextIndent = indent + (last ? ' ' : '\\u2502 ');\n lines.push(...renderTree(nested, nextIndent, [...isLast, last]));\n }\n } else {\n lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);\n }\n });\n\n return lines;\n}\n\n/**\n * Format a canonical log line event as a pretty tree for development output.\n */\nexport function formatPrettyLogLine(ctx: CanonicalLogLineEvent): string {\n const { event, level, message } = ctx;\n\n const timestamp = formatTime(String(event.timestamp ?? ''));\n const service = event['service.name'] || event.service || '';\n const method = event['http.request.method'] || '';\n const path = event['http.route'] || event['url.path'] || '';\n const status = event['http.response.status_code'] || event.status_code || '';\n const durationMs = Number(event.duration_ms ?? 0);\n const duration = formatDuration(durationMs);\n\n const levelColor = LEVEL_COLORS[level] ?? '';\n const levelStr = c(levelColor, level.toUpperCase().padEnd(5));\n\n const parts = [c(DIM, timestamp), levelStr];\n if (service) parts.push(c(DIM, `[${service}]`));\n if (method) parts.push(c(BOLD, String(method)));\n if (path) parts.push(String(path));\n if (status) {\n const statusNum = Number(status);\n const statusColor =\n statusNum >= 500 ? RED : statusNum >= 400 ? YELLOW : GREEN;\n parts.push(c(statusColor, String(status)));\n }\n parts.push(c(DIM, `in ${duration}`));\n\n const header = parts.join(' ');\n\n const tree = groupAttributes(event);\n if (Object.keys(tree).length === 0) {\n return header;\n }\n\n const treeLines = renderTree(tree, ' ', []);\n return [header, ...treeLines].join('\\n');\n}\n","/**\n * Canonical Log Line Processor\n *\n * Automatically emits spans as canonical log lines (wide events) when they end.\n * Implements canonical log line\" pattern: one comprehensive\n * event per request with all context.\n *\n * When a span ends, this processor creates a log record with ALL span attributes,\n * making the span itself the canonical log line that can be queried like structured data.\n *\n * @example\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n */\n\nimport type {\n SpanProcessor,\n ReadableSpan,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Attributes, AttributeValue } from '@opentelemetry/api';\nimport { logs, SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Logger } from '../logger';\nimport { formatPrettyLogLine, formatDuration } from '../pretty-log-formatter';\n\n/**\n * Function to redact sensitive attribute values\n */\nexport type AttributeRedactorFn = (\n key: string,\n value: AttributeValue,\n) => AttributeValue;\n\nexport interface CanonicalLogLineEvent {\n span: ReadableSpan;\n level: 'debug' | 'info' | 'warn' | 'error';\n message: string;\n event: Record<string, unknown>;\n}\n\nexport interface KeepCondition {\n /** Keep events where HTTP status >= this value. */\n status?: number;\n /** Keep events where duration_ms >= this value. */\n durationMs?: number;\n /** Keep events matching this path pattern (simple prefix match). */\n path?: string;\n}\n\nexport interface CanonicalLogLineOptions {\n /** Logger to use for emitting canonical log lines (defaults to OTel Logs API) */\n logger?: Logger;\n /** Only emit canonical log lines for root spans (default: false) */\n rootSpansOnly?: boolean;\n /** Minimum log level for canonical log lines (default: 'info') */\n minLevel?: 'debug' | 'info' | 'warn' | 'error';\n /** Custom message format (default: uses span name) */\n messageFormat?: (span: ReadableSpan) => string;\n /** Whether to include resource attributes (default: true) */\n includeResourceAttributes?: boolean;\n /**\n * Attribute redactor function to apply before logging.\n * This ensures sensitive data is redacted in canonical log lines,\n * matching the behavior of attributeRedactor in init().\n */\n attributeRedactor?: AttributeRedactorFn;\n /** Predicate to decide whether to emit (runs after event is built). */\n shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n /**\n * Declarative tail sampling conditions (OR logic). If any condition matches,\n * the event is kept. Ignored when `shouldEmit` is provided.\n *\n * @example\n * keep: [{ status: 500 }, { durationMs: 1000 }]\n */\n keep?: KeepCondition[];\n /** Callback invoked after emit for custom fan-out. */\n drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n /** Handler for drain failures. */\n onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n /**\n * Pretty-print canonical log lines to console in a tree format.\n * Defaults to true when NODE_ENV is 'development'.\n */\n pretty?: boolean;\n}\n\n/**\n * Span processor that automatically emits spans as canonical log lines\n *\n * When a span ends, this processor creates a log record with ALL span attributes.\n * This implements the \"canonical log line\" pattern: one comprehensive event\n * per request with all context, queryable as structured data.\n *\n * **Key Benefits:**\n * - One log line per request with all context (wide event)\n * - High-cardinality, high-dimensionality data for powerful queries\n * - Automatic - no manual logging needed\n * - Works with any logger or OTel Logs API\n *\n * @example Basic usage\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'checkout-api',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n *\n * @example With custom logger\n * ```typescript\n * import pino from 'pino';\n * import { init } from 'autotel';\n *\n * const logger = pino();\n * init({\n * service: 'my-app',\n * logger,\n * canonicalLogLines: {\n * enabled: true,\n * logger, // Use Pino for canonical log lines\n * rootSpansOnly: true,\n * },\n * });\n * ```\n *\n * @example Custom message format\n * ```typescript\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * messageFormat: (span) => {\n * const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';\n * return `${span.name} [${status}]`;\n * },\n * },\n * });\n * ```\n */\nexport class CanonicalLogLineProcessor implements SpanProcessor {\n private logger?: Logger;\n private rootSpansOnly: boolean;\n private minLevel: 'debug' | 'info' | 'warn' | 'error';\n private messageFormat: (span: ReadableSpan) => string;\n private includeResourceAttributes: boolean;\n private attributeRedactor?: AttributeRedactorFn;\n private shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n private drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n private onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n private pretty: boolean;\n private getOTelLogger: (() => ReturnType<typeof logs.getLogger>) | null =\n null;\n\n constructor(options: CanonicalLogLineOptions = {}) {\n this.logger = options.logger;\n this.rootSpansOnly = options.rootSpansOnly ?? false;\n this.minLevel = options.minLevel ?? 'info';\n this.messageFormat =\n options.messageFormat ?? ((span) => `[${span.name}] Request completed`);\n this.includeResourceAttributes = options.includeResourceAttributes ?? true;\n this.attributeRedactor = options.attributeRedactor;\n this.shouldEmit =\n options.shouldEmit ?? this.buildKeepPredicate(options.keep);\n this.drain = options.drain;\n this.onDrainError = options.onDrainError;\n this.pretty =\n options.pretty ??\n (typeof process !== 'undefined' &&\n process.env.NODE_ENV === 'development');\n\n if (!this.logger) {\n this.getOTelLogger = () => logs.getLogger('autotel.canonical-log-line');\n }\n }\n\n private buildKeepPredicate(\n keep?: KeepCondition[],\n ): ((ctx: CanonicalLogLineEvent) => boolean) | undefined {\n if (!keep || keep.length === 0) return undefined;\n\n return (ctx: CanonicalLogLineEvent) => {\n return keep.some((condition) => {\n if (condition.status !== undefined) {\n const httpStatus = Number(\n ctx.event['http.response.status_code'] ?? 0,\n );\n if (httpStatus >= condition.status) return true;\n }\n if (\n condition.durationMs !== undefined &&\n Number(ctx.event.duration_ms ?? 0) >= condition.durationMs\n ) {\n return true;\n }\n if (condition.path !== undefined) {\n const route = String(\n ctx.event['http.route'] ?? ctx.event['url.path'] ?? '',\n );\n if (route.startsWith(condition.path)) return true;\n }\n return false;\n });\n };\n }\n\n onStart(): void {\n // No-op\n }\n\n onEnd(span: ReadableSpan): void {\n if (\n this.rootSpansOnly &&\n span.parentSpanContext?.spanId &&\n !span.parentSpanContext.isRemote\n ) {\n return;\n }\n\n const level = this.getLogLevel(span);\n if (!this.shouldLog(level)) {\n return;\n }\n\n const canonicalLogLine = this.buildCanonicalLogLine(span);\n const message = this.messageFormat(span);\n const eventContext: CanonicalLogLineEvent = {\n span,\n level,\n message,\n event: canonicalLogLine,\n };\n\n if (this.shouldEmit && !this.shouldEmit(eventContext)) return;\n\n if (this.pretty) {\n console.log(formatPrettyLogLine(eventContext));\n }\n\n if (this.logger) {\n this.emitViaLogger(level, message, canonicalLogLine);\n } else if (this.getOTelLogger) {\n const otelLogger = this.getOTelLogger();\n this.emitViaOTel(level, message, canonicalLogLine, otelLogger);\n }\n\n if (this.drain) {\n Promise.resolve(this.drain(eventContext)).catch((error) => {\n if (this.onDrainError) {\n this.onDrainError(error, eventContext);\n return;\n }\n this.reportInternalWarning('canonicalLogLines.drain failed', error);\n });\n }\n }\n\n private buildCanonicalLogLine(span: ReadableSpan): Record<string, unknown> {\n const durationMs = span.duration[0] * 1000 + span.duration[1] / 1_000_000;\n const timestamp = new Date(\n span.startTime[0] * 1000 + span.startTime[1] / 1_000_000,\n ).toISOString();\n\n // Span attributes first so core metadata fields below take precedence\n const canonicalLogLine: Record<string, unknown> = {};\n const attributes = this.redactAttributes(span.attributes);\n Object.assign(canonicalLogLine, attributes);\n\n if (this.includeResourceAttributes) {\n const resourceAttrs = this.redactAttributes(\n span.resource.attributes as Attributes,\n );\n Object.assign(canonicalLogLine, resourceAttrs);\n }\n\n canonicalLogLine.operation = span.name;\n canonicalLogLine.traceId = span.spanContext().traceId;\n canonicalLogLine.spanId = span.spanContext().spanId;\n canonicalLogLine.correlationId = span.spanContext().traceId.slice(0, 16);\n canonicalLogLine.duration_ms = Math.round(durationMs * 100) / 100;\n canonicalLogLine.duration = formatDuration(durationMs);\n canonicalLogLine.status_code = span.status.code;\n canonicalLogLine.status_message = span.status.message || undefined;\n canonicalLogLine.timestamp = timestamp;\n\n return canonicalLogLine;\n }\n\n private redactAttributes(attributes: Attributes): Record<string, unknown> {\n if (!this.attributeRedactor) {\n return { ...attributes };\n }\n\n const redacted: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n redacted[key] = this.attributeRedactor(key, value);\n }\n }\n return redacted;\n }\n\n private emitViaLogger(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n ): void {\n this.logger;\n }\n\n private emitViaOTel(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n otelLogger: ReturnType<typeof logs.getLogger>,\n ): void {\n const otelAttributes: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(canonicalLogLine)) {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n otelAttributes[key] = value;\n } else if (value !== null && value !== undefined) {\n otelAttributes[key] = String(value);\n }\n }\n otelLogger.emit({\n severityNumber: this.getSeverityNumber(level),\n severityText: level.toUpperCase(),\n body: message,\n attributes: otelAttributes,\n });\n }\n\n private getLogLevel(span: ReadableSpan): 'debug' | 'info' | 'warn' | 'error' {\n const explicitLevel = span.attributes['autotel.log.level'];\n if (\n explicitLevel === 'debug' ||\n explicitLevel === 'info' ||\n explicitLevel === 'warn' ||\n explicitLevel === 'error'\n ) {\n return explicitLevel;\n }\n\n if (span.status.code === 2) return 'error';\n return 'info';\n }\n\n private shouldLog(level: string): boolean {\n const levels = ['debug', 'info', 'warn', 'error'];\n return levels.indexOf(level) >= levels.indexOf(this.minLevel);\n }\n\n private getSeverityNumber(level: string): SeverityNumber {\n const mapping: Record<string, SeverityNumber> = {\n debug: SeverityNumber.DEBUG,\n info: SeverityNumber.INFO,\n warn: SeverityNumber.WARN,\n error: SeverityNumber.ERROR,\n };\n return mapping[level] ?? SeverityNumber.INFO;\n }\n\n private reportInternalWarning(message: string, error: unknown): void {\n const err =\n error instanceof Error ? error.message : String(error ?? 'unknown error');\n if (this.logger) {\n this.logger.warn({ error: err }, `[autotel] ${message}`);\n return;\n }\n console.warn(`[autotel] ${message}: ${err}`);\n }\n\n async forceFlush(): Promise<void> {\n // No-op\n }\n\n async shutdown(): Promise<void> {\n // No-op\n }\n}\n"],"mappings":";;;AAEA,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,QAAQ;AACd,MAAM,OAAO;AAGb,MAAM,eAAuC;CAC3C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;AACT;;AAGA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,YAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,WAAoB;CAC3B,IAAI,OAAO,YAAY,aAAa;EAClC,IAAI,QAAQ,IAAI,UAAU,OAAO;EACjC,IAAI,QAAQ,IAAI,aAAa,OAAO;EACpC,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ClB,kBAAkB,UAClB,kBAAkB,SAElB,OAAO;EAGT,IAAI,KAAK,OAAO,SAAS,GAAG,OAAO;EACnC,OAAO;CACT;CAEA,AAAQ,UAAU,OAAwB;EACxC,MAAM,SAAS;GAAC;GAAS;GAAQ;GAAQ;EAAO;EAChD,OAAO,OAAO,QAAQ,KAAK,KAAK,OAAO,QAAQ,KAAK,QAAQ;CAC9D;CAEA,AAAQ,kBAAkB,OAA+B;EAOvD,OAAO;GALL,OAAOC,uCAAe;GACtB,MAAMA,uCAAe;GACrB,MAAMA,uCAAe;GACrB,OAAOA,uCAAe;EAEX,EAAE,UAAUA,uCAAe;CAC1C;CAEA,AAAQ,sBAAsB,SAAiB,OAAsB;EACnE,MAAM,MACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,SAAS,eAAe;EAC1E,IAAI,KAAK,QAAQ;GACf,KAAK,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,aAAa,SAAS;GACvD;EACF;EACA,QAAQ,KAAK,aAAa,QAAQ,IAAI,KAAK;CAC7C;CAEA,MAAM,aAA4B,CAElC;CAEA,MAAM,WAA0B,CAEhC;AACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { s as Logger } from "./logger-BauSUhUv.js";
|
|
2
|
+
import { ReadableSpan, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
|
+
import { AttributeValue } from "@opentelemetry/api";
|
|
4
|
+
|
|
5
|
+
//#region src/processors/canonical-log-line-processor.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Function to redact sensitive attribute values
|
|
8
|
+
*/
|
|
9
|
+
type AttributeRedactorFn = (key: string, value: AttributeValue) => AttributeValue;
|
|
10
|
+
interface CanonicalLogLineEvent {
|
|
11
|
+
span: ReadableSpan;
|
|
12
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
13
|
+
message: string;
|
|
14
|
+
event: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
interface KeepCondition {
|
|
17
|
+
/** Keep events where HTTP status >= this value. */
|
|
18
|
+
status?: number;
|
|
19
|
+
/** Keep events where duration_ms >= this value. */
|
|
20
|
+
durationMs?: number;
|
|
21
|
+
/** Keep events matching this path pattern (simple prefix match). */
|
|
22
|
+
path?: string;
|
|
23
|
+
}
|
|
24
|
+
interface CanonicalLogLineOptions {
|
|
25
|
+
/** Logger to use for emitting canonical log lines (defaults to OTel Logs API) */
|
|
26
|
+
logger?: Logger;
|
|
27
|
+
/** Only emit canonical log lines for root spans (default: false) */
|
|
28
|
+
rootSpansOnly?: boolean;
|
|
29
|
+
/** Minimum log level for canonical log lines (default: 'info') */
|
|
30
|
+
minLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
31
|
+
/** Custom message format (default: uses span name) */
|
|
32
|
+
messageFormat?: (span: ReadableSpan) => string;
|
|
33
|
+
/** Whether to include resource attributes (default: true) */
|
|
34
|
+
includeResourceAttributes?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Attribute redactor function to apply before logging.
|
|
37
|
+
* This ensures sensitive data is redacted in canonical log lines,
|
|
38
|
+
* matching the behavior of attributeRedactor in init().
|
|
39
|
+
*/
|
|
40
|
+
attributeRedactor?: AttributeRedactorFn;
|
|
41
|
+
/** Predicate to decide whether to emit (runs after event is built). */
|
|
42
|
+
shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Declarative tail sampling conditions (OR logic). If any condition matches,
|
|
45
|
+
* the event is kept. Ignored when `shouldEmit` is provided.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* keep: [{ status: 500 }, { durationMs: 1000 }]
|
|
49
|
+
*/
|
|
50
|
+
keep?: KeepCondition[];
|
|
51
|
+
/** Callback invoked after emit for custom fan-out. */
|
|
52
|
+
drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;
|
|
53
|
+
/** Handler for drain failures. */
|
|
54
|
+
onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Pretty-print canonical log lines to console in a tree format.
|
|
57
|
+
* Defaults to true when NODE_ENV is 'development'.
|
|
58
|
+
*/
|
|
59
|
+
pretty?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Span processor that automatically emits spans as canonical log lines
|
|
63
|
+
*
|
|
64
|
+
* When a span ends, this processor creates a log record with ALL span attributes.
|
|
65
|
+
* This implements the "canonical log line" pattern: one comprehensive event
|
|
66
|
+
* per request with all context, queryable as structured data.
|
|
67
|
+
*
|
|
68
|
+
* **Key Benefits:**
|
|
69
|
+
* - One log line per request with all context (wide event)
|
|
70
|
+
* - High-cardinality, high-dimensionality data for powerful queries
|
|
71
|
+
* - Automatic - no manual logging needed
|
|
72
|
+
* - Works with any logger or OTel Logs API
|
|
73
|
+
*
|
|
74
|
+
* @example Basic usage
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { init } from 'autotel';
|
|
77
|
+
*
|
|
78
|
+
* init({
|
|
79
|
+
* service: 'checkout-api',
|
|
80
|
+
* canonicalLogLines: {
|
|
81
|
+
* enabled: true,
|
|
82
|
+
* rootSpansOnly: true, // One canonical log line per request
|
|
83
|
+
* },
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example With custom logger
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import pino from 'pino';
|
|
90
|
+
* import { init } from 'autotel';
|
|
91
|
+
*
|
|
92
|
+
* const logger = pino();
|
|
93
|
+
* init({
|
|
94
|
+
* service: 'my-app',
|
|
95
|
+
* logger,
|
|
96
|
+
* canonicalLogLines: {
|
|
97
|
+
* enabled: true,
|
|
98
|
+
* logger, // Use Pino for canonical log lines
|
|
99
|
+
* rootSpansOnly: true,
|
|
100
|
+
* },
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @example Custom message format
|
|
105
|
+
* ```typescript
|
|
106
|
+
* init({
|
|
107
|
+
* service: 'my-app',
|
|
108
|
+
* canonicalLogLines: {
|
|
109
|
+
* enabled: true,
|
|
110
|
+
* messageFormat: (span) => {
|
|
111
|
+
* const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';
|
|
112
|
+
* return `${span.name} [${status}]`;
|
|
113
|
+
* },
|
|
114
|
+
* },
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare class CanonicalLogLineProcessor implements SpanProcessor {
|
|
119
|
+
private logger?;
|
|
120
|
+
private rootSpansOnly;
|
|
121
|
+
private minLevel;
|
|
122
|
+
private messageFormat;
|
|
123
|
+
private includeResourceAttributes;
|
|
124
|
+
private attributeRedactor?;
|
|
125
|
+
private shouldEmit?;
|
|
126
|
+
private drain?;
|
|
127
|
+
private onDrainError?;
|
|
128
|
+
private pretty;
|
|
129
|
+
private getOTelLogger;
|
|
130
|
+
constructor(options?: CanonicalLogLineOptions);
|
|
131
|
+
private buildKeepPredicate;
|
|
132
|
+
onStart(): void;
|
|
133
|
+
onEnd(span: ReadableSpan): void;
|
|
134
|
+
private buildCanonicalLogLine;
|
|
135
|
+
private redactAttributes;
|
|
136
|
+
private emitViaLogger;
|
|
137
|
+
private emitViaOTel;
|
|
138
|
+
private getLogLevel;
|
|
139
|
+
private shouldLog;
|
|
140
|
+
private getSeverityNumber;
|
|
141
|
+
private reportInternalWarning;
|
|
142
|
+
forceFlush(): Promise<void>;
|
|
143
|
+
shutdown(): Promise<void>;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { CanonicalLogLineProcessor as n, CanonicalLogLineOptions as t };
|
|
147
|
+
//# sourceMappingURL=canonical-log-line-processor-BcRuAdRk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor-BcRuAdRk.d.ts","names":[],"sources":["../src/processors/canonical-log-line-processor.ts"],"mappings":";;;;;AA6Ce;AAGf;;AAHe,KATH,mBAAA,IACV,GAAA,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