autotel 4.3.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -103
- package/dist/analysis.cjs +87 -0
- package/dist/analysis.cjs.map +1 -0
- package/dist/analysis.d.cts +87 -0
- package/dist/analysis.d.cts.map +1 -0
- package/dist/analysis.d.ts +87 -0
- package/dist/analysis.d.ts.map +1 -0
- package/dist/analysis.js +85 -0
- package/dist/analysis.js.map +1 -0
- package/dist/{attribute-redacting-processor-DtTS9xxh.d.ts → attribute-redacting-processor-Pk7lAzWd.d.cts} +13 -8
- package/dist/attribute-redacting-processor-Pk7lAzWd.d.cts.map +1 -0
- package/dist/{attribute-redacting-processor-DtTS9xxh.d.cts → attribute-redacting-processor-Pk7lAzWd.d.ts} +13 -8
- package/dist/attribute-redacting-processor-Pk7lAzWd.d.ts.map +1 -0
- package/dist/attribute-redacting-processor.cjs +4 -4
- package/dist/attribute-redacting-processor.cjs.map +1 -1
- package/dist/attribute-redacting-processor.d.cts +1 -1
- package/dist/attribute-redacting-processor.d.ts +1 -1
- package/dist/attribute-redacting-processor.js +4 -4
- package/dist/attribute-redacting-processor.js.map +1 -1
- package/dist/attributes.d.cts +1 -1
- package/dist/attributes.d.ts +1 -1
- package/dist/auto.cjs +1 -1
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.d.cts +1 -1
- package/dist/auto.d.ts +1 -1
- package/dist/auto.js +1 -1
- package/dist/auto.js.map +1 -1
- package/dist/business-baggage.d.cts +2 -3
- package/dist/business-baggage.d.cts.map +1 -1
- package/dist/business-baggage.d.ts +2 -3
- package/dist/business-baggage.d.ts.map +1 -1
- package/dist/{canonical-log-line-processor-xvjMgtpF.d.cts → canonical-log-line-processor-B4WgG-VS.d.cts} +2 -3
- package/dist/canonical-log-line-processor-B4WgG-VS.d.cts.map +1 -0
- package/dist/{canonical-log-line-processor-BcRuAdRk.d.ts → canonical-log-line-processor-CL_J7gb5.d.ts} +2 -3
- package/dist/canonical-log-line-processor-CL_J7gb5.d.ts.map +1 -0
- package/dist/{canonical-log-line-processor-CcrDi6TO.cjs → canonical-log-line-processor-DOjb6Kxy.cjs} +5 -5
- package/dist/canonical-log-line-processor-DOjb6Kxy.cjs.map +1 -0
- package/dist/{canonical-log-line-processor-FLezvFCB.js → canonical-log-line-processor-mKABvGP0.js} +5 -5
- package/dist/canonical-log-line-processor-mKABvGP0.js.map +1 -0
- package/dist/config.d.cts +12 -7
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.ts +12 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/correlation-id.cjs +9 -9
- package/dist/correlation-id.d.cts +0 -1
- package/dist/correlation-id.d.cts.map +1 -1
- package/dist/correlation-id.d.ts +0 -1
- package/dist/correlation-id.d.ts.map +1 -1
- package/dist/correlation-id.js +1 -1
- package/dist/db.d.cts.map +1 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/decorators.cjs +2 -2
- package/dist/decorators.cjs.map +1 -1
- package/dist/decorators.d.cts +1 -2
- package/dist/decorators.d.cts.map +1 -1
- package/dist/decorators.d.ts +1 -2
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +1 -1
- package/dist/decorators.js.map +1 -1
- package/dist/{define-event-CreknLm3.d.ts → define-event-B2z1SBe7.d.ts} +2 -3
- package/dist/define-event-B2z1SBe7.d.ts.map +1 -0
- package/dist/{define-event-HZRizPwz.d.cts → define-event-CGG048HE.d.cts} +2 -3
- package/dist/define-event-CGG048HE.d.cts.map +1 -0
- package/dist/diagnostics.cjs +10 -1
- package/dist/diagnostics.cjs.map +1 -1
- package/dist/diagnostics.d.cts +0 -1
- package/dist/diagnostics.d.cts.map +1 -1
- package/dist/diagnostics.d.ts +0 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +10 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/drain-pipeline.d.cts +12 -5
- package/dist/drain-pipeline.d.cts.map +1 -1
- package/dist/drain-pipeline.d.ts +12 -5
- package/dist/drain-pipeline.d.ts.map +1 -1
- package/dist/enrichers.d.cts.map +1 -1
- package/dist/enrichers.d.ts.map +1 -1
- package/dist/{event-subscriber-D1XLkPzi.d.ts → event-subscriber-CWh8sTGh.d.cts} +2 -2
- package/dist/event-subscriber-CWh8sTGh.d.cts.map +1 -0
- package/dist/{event-subscriber-D1XLkPzi.d.cts → event-subscriber-CWh8sTGh.d.ts} +2 -2
- package/dist/event-subscriber-CWh8sTGh.d.ts.map +1 -0
- package/dist/event-subscriber.d.cts +1 -1
- package/dist/event-subscriber.d.ts +1 -1
- package/dist/{event-testing-CfFs3to2.d.ts → event-testing-CA2mIx1E.d.ts} +2 -3
- package/dist/event-testing-CA2mIx1E.d.ts.map +1 -0
- package/dist/{event-testing-BqRnI0z4.d.cts → event-testing-D0qWfqAy.d.cts} +2 -3
- package/dist/event-testing-D0qWfqAy.d.cts.map +1 -0
- package/dist/event-testing.d.cts +1 -1
- package/dist/event-testing.d.ts +1 -1
- package/dist/event.cjs +4 -4
- package/dist/event.d.cts +3 -4
- package/dist/event.d.cts.map +1 -1
- package/dist/event.d.ts +3 -4
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +1 -1
- package/dist/exporters.d.cts +0 -4
- package/dist/exporters.d.cts.map +1 -1
- package/dist/exporters.d.ts +0 -4
- package/dist/exporters.d.ts.map +1 -1
- package/dist/{filtering-span-processor-B8R8B7Uk.d.ts → filtering-span-processor-BpDagWNa.d.cts} +1 -2
- package/dist/filtering-span-processor-BpDagWNa.d.cts.map +1 -0
- package/dist/{filtering-span-processor-B8R8B7Uk.d.cts → filtering-span-processor-BpDagWNa.d.ts} +1 -2
- package/dist/filtering-span-processor-BpDagWNa.d.ts.map +1 -0
- package/dist/filtering-span-processor.d.cts +1 -1
- package/dist/filtering-span-processor.d.ts +1 -1
- package/dist/functional-BnDUxnSl.js +838 -0
- package/dist/functional-BnDUxnSl.js.map +1 -0
- package/dist/functional-DcLBuCPz.cjs +888 -0
- package/dist/functional-DcLBuCPz.cjs.map +1 -0
- package/dist/functional.cjs +2 -2
- package/dist/functional.d.cts +79 -130
- package/dist/functional.d.cts.map +1 -1
- package/dist/functional.d.ts +79 -130
- package/dist/functional.d.ts.map +1 -1
- package/dist/functional.js +2 -2
- package/dist/http.cjs +6 -6
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +4 -5
- package/dist/http.d.cts.map +1 -1
- package/dist/http.d.ts +4 -5
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +5 -5
- package/dist/http.js.map +1 -1
- package/dist/{index-eKuioqT1.d.cts → index-BPcxVucm.d.cts} +2 -3
- package/dist/index-BPcxVucm.d.cts.map +1 -0
- package/dist/{index-Ck06vlW2.d.ts → index-DolOVX6F.d.ts} +2 -3
- package/dist/index-DolOVX6F.d.ts.map +1 -0
- package/dist/index.cjs +25 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -148
- package/dist/index.js.map +1 -1
- package/dist/init-C3RApHKJ.cjs +3371 -0
- package/dist/init-C3RApHKJ.cjs.map +1 -0
- package/dist/{init-DSrRmVnz.d.cts → init-D6n2diBy.d.ts} +46 -20
- package/dist/init-D6n2diBy.d.ts.map +1 -0
- package/dist/init-R-gSEXkJ.js +3190 -0
- package/dist/init-R-gSEXkJ.js.map +1 -0
- package/dist/{init-B7u-DjxM.d.ts → init-XzXzrarP.d.cts} +46 -20
- package/dist/init-XzXzrarP.d.cts.map +1 -0
- package/dist/instrumentation.cjs +7 -13
- package/dist/instrumentation.cjs.map +1 -1
- package/dist/instrumentation.d.cts +0 -1
- package/dist/instrumentation.d.cts.map +1 -1
- package/dist/instrumentation.d.ts +0 -1
- package/dist/instrumentation.d.ts.map +1 -1
- package/dist/instrumentation.js +8 -14
- package/dist/instrumentation.js.map +1 -1
- package/dist/{logger-BauSUhUv.d.ts → logger-CN4xpzMd.d.cts} +1 -2
- package/dist/logger-CN4xpzMd.d.cts.map +1 -0
- package/dist/{logger-BauSUhUv.d.cts → logger-CN4xpzMd.d.ts} +1 -2
- package/dist/logger-CN4xpzMd.d.ts.map +1 -0
- package/dist/logger-D3Ej3DII.js.map +1 -1
- package/dist/logger-thMPLpOG.cjs.map +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/messaging-adapters.cjs.map +1 -1
- package/dist/messaging-adapters.d.cts +0 -1
- package/dist/messaging-adapters.d.cts.map +1 -1
- package/dist/messaging-adapters.d.ts +0 -1
- package/dist/messaging-adapters.d.ts.map +1 -1
- package/dist/messaging-adapters.js.map +1 -1
- package/dist/messaging-testing.d.cts +0 -1
- package/dist/messaging-testing.d.cts.map +1 -1
- package/dist/messaging-testing.d.ts +0 -1
- package/dist/messaging-testing.d.ts.map +1 -1
- package/dist/messaging.cjs +27 -10
- package/dist/messaging.cjs.map +1 -1
- package/dist/messaging.d.cts +6 -7
- package/dist/messaging.d.cts.map +1 -1
- package/dist/messaging.d.ts +6 -7
- package/dist/messaging.d.ts.map +1 -1
- package/dist/messaging.js +27 -10
- package/dist/messaging.js.map +1 -1
- package/dist/metric-helpers.d.cts +0 -1
- package/dist/metric-helpers.d.cts.map +1 -1
- package/dist/metric-helpers.d.ts +0 -1
- package/dist/metric-helpers.d.ts.map +1 -1
- package/dist/{metric-testing-DXdK3-Q3.d.ts → metric-testing-CWm6UhaR.d.ts} +2 -3
- package/dist/metric-testing-CWm6UhaR.d.ts.map +1 -0
- package/dist/{metric-testing-MxvzChDp.d.cts → metric-testing-CpvP3ZIa.d.cts} +2 -3
- package/dist/metric-testing-CpvP3ZIa.d.cts.map +1 -0
- package/dist/metric-testing.d.cts +1 -1
- package/dist/metric-testing.d.ts +1 -1
- package/dist/metric.d.cts +3 -4
- package/dist/metric.d.cts.map +1 -1
- package/dist/metric.d.ts +3 -4
- package/dist/metric.d.ts.map +1 -1
- package/dist/parse-error.d.cts.map +1 -1
- package/dist/parse-error.d.ts.map +1 -1
- package/dist/processors.cjs +1 -1
- package/dist/processors.d.cts +1 -1
- package/dist/processors.d.ts +1 -1
- package/dist/processors.js +1 -1
- package/dist/register.d.cts +1 -1
- package/dist/register.d.ts +1 -1
- package/dist/{sampling-DfYhDJij.d.cts → sampling-BR9fkSwx.d.cts} +127 -10
- package/dist/sampling-BR9fkSwx.d.cts.map +1 -0
- package/dist/{sampling-CR0Va1VB.d.ts → sampling-CP3e7-Yr.d.ts} +127 -10
- package/dist/sampling-CP3e7-Yr.d.ts.map +1 -0
- package/dist/sampling.cjs +160 -12
- package/dist/sampling.cjs.map +1 -1
- package/dist/sampling.d.cts +2 -2
- package/dist/sampling.d.ts +2 -2
- package/dist/sampling.js +157 -13
- package/dist/sampling.js.map +1 -1
- package/dist/security-schema.d.cts +9 -4
- package/dist/security-schema.d.cts.map +1 -1
- package/dist/security-schema.d.ts +9 -4
- package/dist/security-schema.d.ts.map +1 -1
- package/dist/semantic-conventions-FhSxv-bK.d.cts.map +1 -1
- package/dist/semantic-conventions-FhSxv-bK.d.ts.map +1 -1
- package/dist/semantic-conventions.cjs.map +1 -1
- package/dist/semantic-conventions.js.map +1 -1
- package/dist/semantic-helpers.cjs +85 -304
- package/dist/semantic-helpers.cjs.map +1 -1
- package/dist/semantic-helpers.d.cts +21 -12
- package/dist/semantic-helpers.d.cts.map +1 -1
- package/dist/semantic-helpers.d.ts +21 -12
- package/dist/semantic-helpers.d.ts.map +1 -1
- package/dist/semantic-helpers.js +85 -304
- package/dist/semantic-helpers.js.map +1 -1
- package/dist/slo.cjs +225 -0
- package/dist/slo.cjs.map +1 -0
- package/dist/slo.d.cts +97 -0
- package/dist/slo.d.cts.map +1 -0
- package/dist/slo.d.ts +97 -0
- package/dist/slo.d.ts.map +1 -0
- package/dist/slo.js +223 -0
- package/dist/slo.js.map +1 -0
- package/dist/{span-name-normalizer-8ZOGJuwv.d.ts → span-name-normalizer-CN1-8C76.d.cts} +1 -2
- package/dist/span-name-normalizer-CN1-8C76.d.cts.map +1 -0
- package/dist/{span-name-normalizer-8ZOGJuwv.d.cts → span-name-normalizer-CN1-8C76.d.ts} +1 -2
- package/dist/span-name-normalizer-CN1-8C76.d.ts.map +1 -0
- package/dist/span-name-normalizer.cjs.map +1 -1
- package/dist/span-name-normalizer.d.cts +1 -1
- package/dist/span-name-normalizer.d.ts +1 -1
- package/dist/span-name-normalizer.js.map +1 -1
- package/dist/tail-sampling-processor.d.cts +0 -1
- package/dist/tail-sampling-processor.d.cts.map +1 -1
- package/dist/tail-sampling-processor.d.ts +0 -1
- package/dist/tail-sampling-processor.d.ts.map +1 -1
- package/dist/test-span-collector.cjs.map +1 -1
- package/dist/test-span-collector.d.cts +0 -1
- package/dist/test-span-collector.d.cts.map +1 -1
- package/dist/test-span-collector.d.ts +0 -1
- package/dist/test-span-collector.d.ts.map +1 -1
- package/dist/test-span-collector.js.map +1 -1
- package/dist/testing.cjs +76 -11
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +30 -5
- package/dist/testing.d.cts.map +1 -1
- package/dist/testing.d.ts +30 -5
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +73 -12
- package/dist/testing.js.map +1 -1
- package/dist/{trace-context-Cijqoi6e.d.ts → trace-context-IuyoPyNq.d.cts} +9 -9
- package/dist/trace-context-IuyoPyNq.d.cts.map +1 -0
- package/dist/{trace-context-Cijqoi6e.d.cts → trace-context-IuyoPyNq.d.ts} +9 -9
- package/dist/trace-context-IuyoPyNq.d.ts.map +1 -0
- package/dist/trace-factory-validation-BjVAinz6.js +13 -0
- package/dist/trace-factory-validation-BjVAinz6.js.map +1 -0
- package/dist/trace-factory-validation-Dc8epn87.cjs +19 -0
- package/dist/trace-factory-validation-Dc8epn87.cjs.map +1 -0
- package/dist/trace-helpers.cjs +7 -7
- package/dist/trace-helpers.cjs.map +1 -1
- package/dist/trace-helpers.d.cts +6 -7
- package/dist/trace-helpers.d.cts.map +1 -1
- package/dist/trace-helpers.d.ts +6 -7
- package/dist/trace-helpers.d.ts.map +1 -1
- package/dist/trace-helpers.js +7 -7
- package/dist/trace-helpers.js.map +1 -1
- package/dist/tracer-provider.d.cts +0 -1
- package/dist/tracer-provider.d.cts.map +1 -1
- package/dist/tracer-provider.d.ts +0 -1
- package/dist/tracer-provider.d.ts.map +1 -1
- package/dist/validate.cjs.map +1 -1
- package/dist/validate.d.cts +1 -2
- package/dist/validate.d.cts.map +1 -1
- package/dist/validate.d.ts +1 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js.map +1 -1
- package/dist/validation-attributes.d.cts +17 -8
- package/dist/validation-attributes.d.cts.map +1 -1
- package/dist/validation-attributes.d.ts +17 -8
- package/dist/validation-attributes.d.ts.map +1 -1
- package/dist/webhook.cjs +5 -4
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.cts.map +1 -1
- package/dist/webhook.d.ts +4 -4
- package/dist/webhook.d.ts.map +1 -1
- package/dist/webhook.js +5 -4
- package/dist/webhook.js.map +1 -1
- package/dist/workflow-distributed.cjs +5 -5
- package/dist/workflow-distributed.cjs.map +1 -1
- package/dist/workflow-distributed.d.cts +25 -15
- package/dist/workflow-distributed.d.cts.map +1 -1
- package/dist/workflow-distributed.d.ts +25 -15
- package/dist/workflow-distributed.d.ts.map +1 -1
- package/dist/workflow-distributed.js +5 -5
- package/dist/workflow-distributed.js.map +1 -1
- package/dist/workflow.cjs +24 -30
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +11 -6
- package/dist/workflow.d.cts.map +1 -1
- package/dist/workflow.d.ts +11 -6
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +24 -30
- package/dist/workflow.js.map +1 -1
- package/dist/yaml-config.d.cts +2 -3
- package/dist/yaml-config.d.cts.map +1 -1
- package/dist/yaml-config.d.ts +2 -3
- package/dist/yaml-config.d.ts.map +1 -1
- package/package.json +24 -16
- package/dist/attribute-redacting-processor-DtTS9xxh.d.cts.map +0 -1
- package/dist/attribute-redacting-processor-DtTS9xxh.d.ts.map +0 -1
- package/dist/canonical-log-line-processor-BcRuAdRk.d.ts.map +0 -1
- package/dist/canonical-log-line-processor-CcrDi6TO.cjs.map +0 -1
- package/dist/canonical-log-line-processor-FLezvFCB.js.map +0 -1
- package/dist/canonical-log-line-processor-xvjMgtpF.d.cts.map +0 -1
- package/dist/define-event-CreknLm3.d.ts.map +0 -1
- package/dist/define-event-HZRizPwz.d.cts.map +0 -1
- package/dist/event-BEm5IJ8U.js +0 -761
- package/dist/event-BEm5IJ8U.js.map +0 -1
- package/dist/event-rzA1X5h3.cjs +0 -778
- package/dist/event-rzA1X5h3.cjs.map +0 -1
- package/dist/event-subscriber-D1XLkPzi.d.cts.map +0 -1
- package/dist/event-subscriber-D1XLkPzi.d.ts.map +0 -1
- package/dist/event-testing-BqRnI0z4.d.cts.map +0 -1
- package/dist/event-testing-CfFs3to2.d.ts.map +0 -1
- package/dist/filtering-span-processor-B8R8B7Uk.d.cts.map +0 -1
- package/dist/filtering-span-processor-B8R8B7Uk.d.ts.map +0 -1
- package/dist/functional-CwsPyc4l.cjs +0 -1298
- package/dist/functional-CwsPyc4l.cjs.map +0 -1
- package/dist/functional-dAYhXQPA.js +0 -1248
- package/dist/functional-dAYhXQPA.js.map +0 -1
- package/dist/index-Ck06vlW2.d.ts.map +0 -1
- package/dist/index-eKuioqT1.d.cts.map +0 -1
- package/dist/init-B7u-DjxM.d.ts.map +0 -1
- package/dist/init-BvBB45-T.js +0 -1034
- package/dist/init-BvBB45-T.js.map +0 -1
- package/dist/init-BxJEJ9Tn.cjs +0 -1111
- package/dist/init-BxJEJ9Tn.cjs.map +0 -1
- package/dist/init-DSrRmVnz.d.cts.map +0 -1
- package/dist/logger-BauSUhUv.d.cts.map +0 -1
- package/dist/logger-BauSUhUv.d.ts.map +0 -1
- package/dist/metric-testing-DXdK3-Q3.d.ts.map +0 -1
- package/dist/metric-testing-MxvzChDp.d.cts.map +0 -1
- package/dist/operation-context-CKBoA4Qy.js +0 -59
- package/dist/operation-context-CKBoA4Qy.js.map +0 -1
- package/dist/operation-context-hzKbTKnt.cjs +0 -72
- package/dist/operation-context-hzKbTKnt.cjs.map +0 -1
- package/dist/sampling-CR0Va1VB.d.ts.map +0 -1
- package/dist/sampling-DfYhDJij.d.cts.map +0 -1
- package/dist/span-name-normalizer-8ZOGJuwv.d.cts.map +0 -1
- package/dist/span-name-normalizer-8ZOGJuwv.d.ts.map +0 -1
- package/dist/trace-context-Cijqoi6e.d.cts.map +0 -1
- package/dist/trace-context-Cijqoi6e.d.ts.map +0 -1
- package/dist/track-D7O7oIZa.js +0 -1115
- package/dist/track-D7O7oIZa.js.map +0 -1
- package/dist/track-eovhCJ-I.cjs +0 -1218
- package/dist/track-eovhCJ-I.cjs.map +0 -1
- package/skills/analyze-traces/SKILL.md +0 -180
- package/skills/autotel-core/SKILL.md +0 -159
- package/skills/autotel-events/SKILL.md +0 -84
- package/skills/autotel-frameworks/SKILL.md +0 -90
- package/skills/autotel-instrumentation/SKILL.md +0 -145
- package/skills/autotel-request-logging/SKILL.md +0 -94
- package/skills/autotel-structured-errors/SKILL.md +0 -125
- package/skills/build-audit-trails/SKILL.md +0 -460
- package/skills/build-audit-trails/references/audit-queries.md +0 -73
- package/skills/build-audit-trails/references/framework-wiring.md +0 -196
- package/skills/debug-missing-spans/SKILL.md +0 -250
- package/skills/migrate-to-autotel/SKILL.md +0 -269
- package/skills/review-otel-patterns/SKILL.md +0 -538
- package/skills/review-otel-patterns/references/code-review.md +0 -76
- package/skills/review-otel-patterns/references/processor-pipeline.md +0 -205
- package/skills/review-otel-patterns/references/structured-errors.md +0 -102
- package/skills/review-otel-patterns/references/wide-spans.md +0 -85
- package/skills/tune-sampling/SKILL.md +0 -215
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute-redacting-processor.js","names":[],"sources":["../src/attribute-redacting-processor.ts"],"sourcesContent":["/**\n * Attribute Redacting Processor\n *\n * Automatically redacts PII and sensitive data from span attributes before export.\n * This is critical for compliance (GDPR, PCI-DSS, HIPAA) and data security.\n *\n * @example Basic usage with preset\n * ```typescript\n * init({\n * service: 'my-app',\n * attributeRedactor: 'default'\n * })\n * ```\n *\n * @example Custom patterns\n * ```typescript\n * init({\n * service: 'my-app',\n * attributeRedactor: {\n * keyPatterns: [/password/i, /secret/i],\n * valuePatterns: [\n * { name: 'customerId', pattern: /CUST-\\d{8}/g, replacement: 'CUST-***' }\n * ]\n * }\n * })\n * ```\n */\n\nimport type {\n SpanProcessor,\n ReadableSpan,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Context, AttributeValue, Attributes } from '@opentelemetry/api';\nimport type { Span } from '@opentelemetry/sdk-trace-base';\n\n/**\n * Custom redactor function type\n */\nexport type AttributeRedactorFn = (\n key: string,\n value: AttributeValue,\n) => AttributeValue;\n\n/**\n * Built-in redactor preset names\n */\nexport type AttributeRedactorPreset = 'default' | 'strict' | 'pci-dss';\n\n/**\n * Masker function type - receives the matched string and returns a masked version\n */\nexport type MaskFn = (match: string) => string;\n\n/**\n * Value pattern configuration\n */\nexport interface ValuePatternConfig {\n /** Name for debugging/logging */\n name: string;\n /** Regex pattern to match in values */\n pattern: RegExp;\n /** Custom replacement (default: uses global replacement) */\n replacement?: string;\n /** Mask function for smart partial masking (overrides replacement) */\n mask?: MaskFn;\n}\n\n/**\n * Built-in PII pattern names\n */\nexport type BuiltinPatternName = keyof typeof builtinPatterns;\n\n/**\n * Attribute redactor configuration\n */\nexport interface AttributeRedactorConfig {\n /** Patterns to match against attribute keys (redacts entire value if key matches) */\n keyPatterns?: RegExp[];\n\n /** Patterns to match against attribute values (redacts matched portion) */\n valuePatterns?: ValuePatternConfig[];\n\n /** Dot-notation paths to redact (e.g. 'user.password', 'payment.card') */\n paths?: string[];\n\n /** Built-in PII patterns to enable. `true` enables all, `false` disables all, array selects specific ones. */\n builtins?: boolean | BuiltinPatternName[];\n\n /** Custom RegExp patterns for string-level redaction */\n patterns?: RegExp[];\n\n /** Default replacement string (default: '[REDACTED]') */\n replacement?: string;\n\n /** Custom redactor function for full control */\n redactor?: AttributeRedactorFn;\n}\n\n/**\n * Processor options\n */\nexport interface AttributeRedactingProcessorOptions {\n redactor: AttributeRedactorConfig | AttributeRedactorPreset;\n}\n\n/**\n * Built-in patterns for detecting sensitive data\n */\nexport const REDACTOR_PATTERNS = {\n // Value patterns (match content in attribute values)\n email: /\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b/gi,\n phone: /\\b\\d{3}[-.]?\\d{3}[-.]?\\d{4}\\b/g,\n ssn: /\\b\\d{3}[-]?\\d{2}[-]?\\d{4}\\b/g,\n creditCard: /\\b\\d{4}[- ]?\\d{4}[- ]?\\d{4}[- ]?\\d{4}\\b/g,\n bearerToken: /Bearer\\s+[A-Za-z0-9._~+/=-]+/gi,\n apiKeyInValue: /(?:api[_-]?key|apikey|api_secret)[=:][\\s\"']*[A-Za-z0-9_-]+/gi,\n jwt: /eyJ[A-Za-z0-9_-]*\\.eyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*/g,\n\n // Key patterns (match attribute names - redacts entire value)\n sensitiveKey:\n /^(password|passwd|pwd|secret|token|api[_-]?key|auth|credential|private[_-]?key|authorization)$/i,\n} as const;\n\n/**\n * Built-in PII detection patterns with smart masking.\n * Each builtin preserves just enough signal for debugging while scrubbing PII.\n */\nexport const builtinPatterns = {\n /** Credit card numbers → ****1111 (PCI DSS: last 4 allowed) */\n creditCard: {\n pattern: /\\b\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b/g,\n mask: (m: string) => `****${m.replace(/[\\s-]/g, '').slice(-4)}`,\n },\n /** Email addresses → a***@***.com */\n email: {\n pattern: /[\\w.+-]+@[\\w-]+\\.[\\w.]+/g,\n mask: (m: string) => {\n const at = m.indexOf('@');\n if (at < 1) return '***@***';\n const tld = m.slice(m.lastIndexOf('.'));\n return `${m[0]}***@***${tld}`;\n },\n },\n /** IPv4 addresses → ***.***.***.100 (last octet only) */\n ipv4: {\n pattern:\n /\\b(?!0\\.0\\.0\\.0\\b)(?!127\\.0\\.0\\.1\\b)\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/g,\n mask: (m: string) => `***.***.***.${m.split('.').pop()}`,\n },\n /**\n * International / formatted phone numbers.\n *\n * Matches:\n * - `+33 1 23 45 67 89` -> `+33******89`\n * - `(415) 555-1234` -> `********34`\n * - `555-123-4567` / `555.123.4567` / `5551234567` -> `********67`\n *\n * Bare short digit runs like `12345678` are intentionally not matched.\n */\n phone: {\n pattern:\n /(?:\\+\\d{1,3}[\\s.-]?\\(?\\d{1,4}\\)?(?:[\\s.-]?\\d{2,4}){2,4}|\\(\\d{1,4}\\)(?:[\\s.-]?\\d{2,4}){2,4}|\\b\\d{3}[-.]?\\d{3}[-.]?\\d{4}\\b)/g,\n mask: (m: string) => {\n const digits = m.replace(/[^\\d]/g, '');\n const hasPlus = m.startsWith('+');\n if (hasPlus && digits.length > 4) {\n const ccMatch = m.match(/^\\+\\d{1,3}/);\n const cc = ccMatch ? ccMatch[0] : '+';\n return `${cc}******${digits.slice(-2)}`;\n }\n if (digits.length > 2) {\n return `${'*'.repeat(digits.length - 2)}${digits.slice(-2)}`;\n }\n return '***';\n },\n },\n /** JWT tokens → eyJ***.*** */\n jwt: {\n pattern: /\\beyJ[\\w-]*\\.[\\w-]*\\.[\\w-]*\\b/g,\n mask: () => 'eyJ***.***',\n },\n /** Bearer tokens → Bearer *** */\n bearer: {\n pattern: /\\bBearer\\s+[\\w\\-.~+/]{8,}=*/gi,\n mask: () => 'Bearer ***',\n },\n /** IBAN → FR76****189 (country + check digits + last 3) */\n iban: {\n pattern:\n /\\b[A-Z]{2}\\d{2}[\\s-]?[\\dA-Z]{4}[\\s-]?[\\dA-Z]{4}[\\s-]?[\\dA-Z]{4}[\\s-]?[\\dA-Z]{0,4}[\\s-]?[\\dA-Z]{0,4}[\\s-]?[\\dA-Z]{0,4}\\b/g,\n mask: (m: string) => {\n const clean = m.replace(/[\\s-]/g, '');\n return `${clean.slice(0, 4)}****${clean.slice(-3)}`;\n },\n },\n} as const;\n\nfunction cloneRegex(re: RegExp): RegExp {\n return new RegExp(re.source, re.flags);\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction toRegExp(value: unknown): RegExp | undefined {\n if (value instanceof RegExp) return value;\n if (typeof value === 'string') return new RegExp(value, 'g');\n if (isPlainObject(value) && typeof value.source === 'string') {\n const flags = typeof value.flags === 'string' ? value.flags : 'g';\n return new RegExp(value.source, flags);\n }\n return undefined;\n}\n\nfunction toRegExpArray(value: unknown): RegExp[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const out: RegExp[] = [];\n for (const item of value) {\n const re = toRegExp(item);\n if (re) out.push(re);\n }\n return out.length > 0 ? out : [];\n}\n\nfunction builtinToValuePattern(name: BuiltinPatternName): ValuePatternConfig {\n const b = builtinPatterns[name];\n return { name, pattern: cloneRegex(b.pattern), mask: b.mask };\n}\n\n/**\n * Default value patterns for the 'default' preset\n */\nconst DEFAULT_VALUE_PATTERNS: ValuePatternConfig[] = [\n builtinToValuePattern('email'),\n builtinToValuePattern('phone'),\n { name: 'ssn', pattern: REDACTOR_PATTERNS.ssn },\n builtinToValuePattern('creditCard'),\n];\n\n/**\n * Built-in redactor presets\n */\nexport const REDACTOR_PRESETS: Record<\n AttributeRedactorPreset,\n AttributeRedactorConfig\n> = {\n /**\n * Default preset - covers common PII patterns with smart masking\n * Detects: emails (a***@***.com), phone numbers, SSNs, credit cards (****1111)\n * Redacts keys: password, secret, token, apiKey, auth, credential\n */\n default: {\n keyPatterns: [REDACTOR_PATTERNS.sensitiveKey],\n valuePatterns: DEFAULT_VALUE_PATTERNS,\n builtins: true,\n replacement: '[REDACTED]',\n },\n\n /**\n * Strict preset - more aggressive redaction for high-security environments\n * Includes everything in default plus: Bearer tokens, JWTs, IBAN, API keys in values\n */\n strict: {\n keyPatterns: [REDACTOR_PATTERNS.sensitiveKey, /bearer/i, /jwt/i],\n valuePatterns: [\n ...DEFAULT_VALUE_PATTERNS,\n builtinToValuePattern('jwt'),\n builtinToValuePattern('bearer'),\n builtinToValuePattern('iban'),\n { name: 'apiKeyInValue', pattern: REDACTOR_PATTERNS.apiKeyInValue },\n ],\n builtins: true,\n replacement: '[REDACTED]',\n },\n\n /**\n * PCI-DSS preset - focused on payment card industry compliance\n * Redacts: credit card numbers (****1111), CVV-like patterns, card-related keys\n */\n 'pci-dss': {\n keyPatterns: [/card/i, /cvv/i, /cvc/i, /pan/i, /expir/i, /ccn/i],\n valuePatterns: [builtinToValuePattern('creditCard')],\n builtins: ['creditCard'],\n replacement: '[REDACTED]',\n },\n};\n\n/**\n * Normalize redactor config that may have been deserialized from JSON/YAML.\n * Converts regex-like values back to RegExp instances.\n */\nexport function normalizeAttributeRedactorConfig(\n raw: AttributeRedactorConfig | AttributeRedactorPreset | unknown,\n): AttributeRedactorConfig | AttributeRedactorPreset | undefined {\n if (raw === undefined || raw === null) return undefined;\n if (typeof raw === 'string') return raw as AttributeRedactorPreset;\n if (!isPlainObject(raw)) return undefined;\n\n const config: AttributeRedactorConfig = {};\n\n if (Array.isArray(raw.paths)) {\n config.paths = raw.paths.filter(\n (value): value is string => typeof value === 'string',\n );\n }\n\n if (typeof raw.replacement === 'string') {\n config.replacement = raw.replacement;\n }\n\n if (typeof raw.builtins === 'boolean') {\n config.builtins = raw.builtins;\n } else if (Array.isArray(raw.builtins)) {\n config.builtins = raw.builtins.filter(\n (name): name is BuiltinPatternName => typeof name === 'string',\n );\n }\n\n if (typeof raw.redactor === 'function') {\n config.redactor = raw.redactor as AttributeRedactorFn;\n }\n\n const keyPatterns = toRegExpArray(raw.keyPatterns);\n if (keyPatterns) config.keyPatterns = keyPatterns;\n\n const patterns = toRegExpArray(raw.patterns);\n if (patterns) config.patterns = patterns;\n\n if (Array.isArray(raw.valuePatterns)) {\n const valuePatterns: ValuePatternConfig[] = [];\n for (const item of raw.valuePatterns) {\n if (!isPlainObject(item) || typeof item.name !== 'string') continue;\n const pattern = toRegExp(item.pattern);\n if (!pattern) continue;\n valuePatterns.push({\n name: item.name,\n pattern,\n replacement:\n typeof item.replacement === 'string' ? item.replacement : undefined,\n mask:\n typeof item.mask === 'function' ? (item.mask as MaskFn) : undefined,\n });\n }\n config.valuePatterns = valuePatterns;\n }\n\n return config;\n}\n\n/**\n * Resolve config to a normalized form\n */\nfunction resolveConfig(\n config: AttributeRedactorConfig | AttributeRedactorPreset,\n): AttributeRedactorConfig {\n const normalized = normalizeAttributeRedactorConfig(config);\n if (!normalized) {\n throw new Error('Invalid attribute redactor config');\n }\n\n if (typeof normalized === 'string') {\n const preset = REDACTOR_PRESETS[normalized];\n if (!preset) {\n throw new Error(\n `Unknown attribute redactor preset: \"${normalized}\". ` +\n `Available presets: ${Object.keys(REDACTOR_PRESETS).join(', ')}`,\n );\n }\n return preset;\n }\n\n const resolvedConfig: AttributeRedactorConfig = {\n ...normalized,\n keyPatterns: normalized.keyPatterns\n ? [...normalized.keyPatterns]\n : undefined,\n valuePatterns: normalized.valuePatterns\n ? [...normalized.valuePatterns]\n : undefined,\n paths: normalized.paths ? [...normalized.paths] : undefined,\n patterns: normalized.patterns ? [...normalized.patterns] : undefined,\n };\n\n // Merge built-in patterns if enabled\n if (resolvedConfig.builtins !== false) {\n const builtinNames = Array.isArray(resolvedConfig.builtins)\n ? resolvedConfig.builtins\n : (Object.keys(builtinPatterns) as BuiltinPatternName[]);\n const builtinValuePatterns = builtinNames\n .filter((name) => name in builtinPatterns)\n .map(builtinToValuePattern);\n\n resolvedConfig.valuePatterns = [\n ...(resolvedConfig.valuePatterns ?? []),\n ...builtinValuePatterns,\n ];\n }\n\n return resolvedConfig;\n}\n\n/**\n * Create a redactor function from config\n */\nfunction createRedactorFromConfig(\n config: AttributeRedactorConfig,\n): AttributeRedactorFn {\n // If custom redactor provided, use it directly\n if (config.redactor) {\n return config.redactor;\n }\n\n const keyPatterns = config.keyPatterns ?? [];\n const valuePatterns = config.valuePatterns ?? [];\n const paths = config.paths ?? [];\n const pathSet = new Set(paths);\n const customPatterns = config.patterns ?? [];\n const defaultReplacement = config.replacement ?? '[REDACTED]';\n\n // Build masker list from valuePatterns that have mask functions\n const maskers: [RegExp, MaskFn][] = valuePatterns\n .filter((vp) => vp.mask)\n .map((vp) => [cloneRegex(vp.pattern), vp.mask!]);\n\n return (key: string, value: AttributeValue): AttributeValue => {\n // Key-pattern and path-based redaction only applies to string values.\n // Numbers, booleans and other non-string attributes are not credentials;\n // replacing them with the string '[REDACTED]' silently changes their\n // type and corrupts downstream consumers (LLM token counters etc.).\n if (typeof value === 'string') {\n for (const pattern of keyPatterns) {\n pattern.lastIndex = 0;\n if (pattern.test(key)) {\n return defaultReplacement;\n }\n }\n if (pathSet.has(key)) {\n return defaultReplacement;\n }\n }\n\n // For non-string values, return as-is\n if (typeof value !== 'string') {\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (typeof item === 'string') {\n return redactStringValue(\n item,\n valuePatterns,\n maskers,\n customPatterns,\n defaultReplacement,\n ) as string;\n }\n return item;\n }) as AttributeValue;\n }\n return value;\n }\n\n // Three-tier strategy: path-based → masker-based → pattern-based\n return redactStringValue(\n value,\n valuePatterns,\n maskers,\n customPatterns,\n defaultReplacement,\n );\n };\n}\n\n/**\n * Apply three-tier redaction strategy to a string\n * 1. Masker-based: built-in patterns with smart partial masking\n * 2. Pattern-based: custom RegExp patterns replaced with replacement\n */\nfunction redactStringValue(\n value: string,\n patterns: ValuePatternConfig[],\n maskers: [RegExp, MaskFn][],\n customPatterns: RegExp[],\n defaultReplacement: string,\n): string {\n let result = value;\n\n // Tier 1: Apply maskers (smart partial masking)\n for (const [pattern, mask] of maskers) {\n pattern.lastIndex = 0;\n result = result.replace(pattern, mask);\n }\n\n // Tier 2: Apply value patterns without mask (full replacement)\n for (const { pattern, replacement, mask } of patterns) {\n if (mask) continue; // Already handled by maskers\n pattern.lastIndex = 0;\n result = result.replaceAll(pattern, replacement ?? defaultReplacement);\n }\n\n // Tier 3: Apply custom patterns\n for (const pattern of customPatterns) {\n pattern.lastIndex = 0;\n result = result.replaceAll(pattern, defaultReplacement);\n }\n\n return result;\n}\n\n/**\n * Create a proxy wrapper around ReadableSpan with redacted attributes\n *\n * Since ReadableSpan.attributes is readonly, we use a Proxy to intercept\n * attribute access and return the redacted version.\n */\nfunction createRedactedSpan(\n span: ReadableSpan,\n redactor: AttributeRedactorFn,\n): ReadableSpan {\n // Pre-compute redacted attributes (cached for efficiency)\n const redactedAttributes: Attributes = {};\n for (const [key, value] of Object.entries(span.attributes)) {\n if (value !== undefined) {\n redactedAttributes[key] = redactor(key, value);\n }\n }\n\n // Return a proxy that intercepts attribute access\n return new Proxy(span, {\n get(target, prop) {\n if (prop === 'attributes') {\n return redactedAttributes;\n }\n // For all other properties, delegate to the original span\n const value = Reflect.get(target, prop);\n // Bind methods to the original target\n if (typeof value === 'function') {\n return value.bind(target);\n }\n return value;\n },\n });\n}\n\n/**\n * Create an attribute redactor function from a config or preset.\n *\n * This is useful when you need to apply the same redaction logic\n * outside of the span processor pipeline (e.g., for canonical log lines).\n *\n * @example\n * ```typescript\n * const redactor = createAttributeRedactor('default');\n * const redactedValue = redactor('user.password', 'secret123');\n * // redactedValue === '[REDACTED]'\n * ```\n */\nexport function createAttributeRedactor(\n config: AttributeRedactorConfig | AttributeRedactorPreset,\n): AttributeRedactorFn {\n return createRedactorFromConfig(resolveConfig(config));\n}\n\n/**\n * Span processor that redacts sensitive data from span attributes.\n *\n * Redaction happens in onEnd() when all attributes are finalized.\n * Uses a Proxy wrapper to intercept attribute access since ReadableSpan\n * attributes are readonly.\n *\n * Common use cases:\n * - PII compliance (GDPR, CCPA)\n * - PCI-DSS compliance for payment data\n * - Preventing secrets from leaking to observability backends\n */\nexport class AttributeRedactingProcessor implements SpanProcessor {\n private readonly wrappedProcessor: SpanProcessor;\n private readonly redactor: AttributeRedactorFn;\n\n constructor(\n wrappedProcessor: SpanProcessor,\n options: AttributeRedactingProcessorOptions,\n ) {\n this.wrappedProcessor = wrappedProcessor;\n const config = resolveConfig(options.redactor);\n this.redactor = createRedactorFromConfig(config);\n }\n\n /**\n * Pass through onStart unchanged - attributes aren't finalized yet\n */\n onStart(span: Span, parentContext: Context): void {\n this.wrappedProcessor.onStart(span, parentContext);\n }\n\n /**\n * Redact attributes and forward to wrapped processor\n */\n onEnd(span: ReadableSpan): void {\n try {\n const redactedSpan = createRedactedSpan(span, this.redactor);\n this.wrappedProcessor.onEnd(redactedSpan);\n } catch {\n // Fail-open: if redaction fails, forward original span\n // This ensures we don't lose telemetry due to redaction errors\n this.wrappedProcessor.onEnd(span);\n }\n }\n\n forceFlush(): Promise<void> {\n return this.wrappedProcessor.forceFlush();\n }\n\n shutdown(): Promise<void> {\n return this.wrappedProcessor.shutdown();\n }\n}\n\n/**\n * Export createRedactedSpan for advanced users who want to use it directly\n */\nexport { createRedactedSpan };\n"],"mappings":";;;;AA4GA,MAAa,oBAAoB;CAE/B,OAAO;CACP,OAAO;CACP,KAAK;CACL,YAAY;CACZ,aAAa;CACb,eAAe;CACf,KAAK;CAGL,cACE;AACJ;;;;;AAMA,MAAa,kBAAkB;;CAE7B,YAAY;EACV,SAAS;EACT,OAAO,MAAc,OAAO,EAAE,QAAQ,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CAC9D;;CAEA,OAAO;EACL,SAAS;EACT,OAAO,MAAc;GAEnB,IADW,EAAE,QAAQ,GAChB,IAAI,GAAG,OAAO;GACnB,MAAM,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,CAAC;GACtC,OAAO,GAAG,EAAE,GAAG,SAAS;EAC1B;CACF;;CAEA,MAAM;EACJ,SACE;EACF,OAAO,MAAc,eAAe,EAAE,MAAM,GAAG,CAAC,CAAC,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;EAC9B,IAAI;GACF,MAAM,eAAe,mBAAmB,MAAM,KAAK,QAAQ;GAC3D,KAAK,iBAAiB,MAAM,YAAY;EAC1C,QAAQ;GAGN,KAAK,iBAAiB,MAAM,IAAI;EAClC;CACF;CAEA,aAA4B;EAC1B,OAAO,KAAK,iBAAiB,WAAW;CAC1C;CAEA,WAA0B;EACxB,OAAO,KAAK,iBAAiB,SAAS;CACxC;AACF"}
|
|
1
|
+
{"version":3,"file":"attribute-redacting-processor.js","names":[],"sources":["../src/attribute-redacting-processor.ts"],"sourcesContent":["/**\n * Attribute Redacting Processor\n *\n * Automatically redacts PII and sensitive data from span attributes before export.\n * This is critical for compliance (GDPR, PCI-DSS, HIPAA) and data security.\n *\n * @example Basic usage with preset\n * ```typescript\n * init({\n * service: 'my-app',\n * attributeRedactor: 'default'\n * })\n * ```\n *\n * @example Custom patterns\n * ```typescript\n * init({\n * service: 'my-app',\n * attributeRedactor: {\n * keyPatterns: [/password/i, /secret/i],\n * valuePatterns: [\n * { name: 'customerId', pattern: /CUST-\\d{8}/g, replacement: 'CUST-***' }\n * ]\n * }\n * })\n * ```\n */\n\nimport type {\n SpanProcessor,\n ReadableSpan,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Context, AttributeValue, Attributes } from '@opentelemetry/api';\nimport type { Span } from '@opentelemetry/sdk-trace-base';\n\n/**\n * Custom redactor function type\n */\nexport type AttributeRedactorFn = (\n key: string,\n value: AttributeValue,\n) => AttributeValue;\n\n/**\n * Built-in redactor preset names\n */\nexport type AttributeRedactorPreset = 'default' | 'strict' | 'pci-dss';\n\n/**\n * Masker function type - receives the matched string and returns a masked version\n */\nexport type MaskFn = (match: string) => string;\n\n/**\n * Value pattern configuration\n */\nexport interface ValuePatternConfig {\n /** Name for debugging/logging */\n name: string;\n /** Regex pattern to match in values */\n pattern: RegExp;\n /** Custom replacement (default: uses global replacement) */\n replacement?: string;\n /** Mask function for smart partial masking (overrides replacement) */\n mask?: MaskFn;\n}\n\n/**\n * Built-in PII pattern names\n */\nexport type BuiltinPatternName = keyof typeof builtinPatterns;\n\n/**\n * Attribute redactor configuration\n */\nexport interface AttributeRedactorConfig {\n /** Patterns to match against attribute keys (redacts entire value if key matches) */\n keyPatterns?: RegExp[];\n\n /** Patterns to match against attribute values (redacts matched portion) */\n valuePatterns?: ValuePatternConfig[];\n\n /** Dot-notation paths to redact (e.g. 'user.password', 'payment.card') */\n paths?: string[];\n\n /** Built-in PII patterns to enable. `true` enables all, `false` disables all, array selects specific ones. */\n builtins?: boolean | BuiltinPatternName[];\n\n /** Custom RegExp patterns for string-level redaction */\n patterns?: RegExp[];\n\n /** Default replacement string (default: '[REDACTED]') */\n replacement?: string;\n\n /** Custom redactor function for full control */\n redactor?: AttributeRedactorFn;\n}\n\n/**\n * Processor options\n */\nexport interface AttributeRedactingProcessorOptions {\n redactor: AttributeRedactorConfig | AttributeRedactorPreset;\n}\n\n/**\n * Built-in patterns for detecting sensitive data\n */\nexport const REDACTOR_PATTERNS = {\n // Value patterns (match content in attribute values)\n email: /\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b/gi,\n phone: /\\b\\d{3}[-.]?\\d{3}[-.]?\\d{4}\\b/g,\n ssn: /\\b\\d{3}[-]?\\d{2}[-]?\\d{4}\\b/g,\n creditCard: /\\b\\d{4}[- ]?\\d{4}[- ]?\\d{4}[- ]?\\d{4}\\b/g,\n bearerToken: /Bearer\\s+[A-Za-z0-9._~+/=-]+/gi,\n apiKeyInValue: /(?:api[_-]?key|apikey|api_secret)[=:][\\s\"']*[A-Za-z0-9_-]+/gi,\n jwt: /eyJ[A-Za-z0-9_-]*\\.eyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*/g,\n\n // Key patterns (match attribute names - redacts entire value)\n sensitiveKey:\n /^(password|passwd|pwd|secret|token|api[_-]?key|auth|credential|private[_-]?key|authorization)$/i,\n} as const;\n\n/**\n * Built-in PII detection patterns with smart masking.\n * Each builtin preserves just enough signal for debugging while scrubbing PII.\n */\nexport const builtinPatterns = {\n /** Credit card numbers → ****1111 (PCI DSS: last 4 allowed) */\n creditCard: {\n pattern: /\\b\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}\\b/g,\n mask: (m: string) => `****${m.replaceAll(/[\\s-]/g, '').slice(-4)}`,\n },\n /** Email addresses → a***@***.com */\n email: {\n pattern: /[\\w.+-]+@[\\w-]+\\.[\\w.]+/g,\n mask: (m: string) => {\n const at = m.indexOf('@');\n if (at < 1) return '***@***';\n const tld = m.slice(m.lastIndexOf('.'));\n return `${m[0]}***@***${tld}`;\n },\n },\n /** IPv4 addresses → ***.***.***.100 (last octet only) */\n ipv4: {\n pattern:\n /\\b(?!0\\.0\\.0\\.0\\b)(?!127\\.0\\.0\\.1\\b)\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/g,\n mask: (m: string) => `***.***.***.${m.split('.').pop()}`,\n },\n /**\n * International / formatted phone numbers.\n *\n * Matches:\n * - `+33 1 23 45 67 89` -> `+33******89`\n * - `(415) 555-1234` -> `********34`\n * - `555-123-4567` / `555.123.4567` / `5551234567` -> `********67`\n *\n * Bare short digit runs like `12345678` are intentionally not matched.\n */\n phone: {\n pattern:\n /(?:\\+\\d{1,3}[\\s.-]?\\(?\\d{1,4}\\)?(?:[\\s.-]?\\d{2,4}){2,4}|\\(\\d{1,4}\\)(?:[\\s.-]?\\d{2,4}){2,4}|\\b\\d{3}[-.]?\\d{3}[-.]?\\d{4}\\b)/g,\n mask: (m: string) => {\n const digits = m.replaceAll(/[^\\d]/g, '');\n const hasPlus = m.startsWith('+');\n if (hasPlus && digits.length > 4) {\n const ccMatch = m.match(/^\\+\\d{1,3}/);\n const cc = ccMatch ? ccMatch[0] : '+';\n return `${cc}******${digits.slice(-2)}`;\n }\n if (digits.length > 2) {\n return `${'*'.repeat(digits.length - 2)}${digits.slice(-2)}`;\n }\n return '***';\n },\n },\n /** JWT tokens → eyJ***.*** */\n jwt: {\n pattern: /\\beyJ[\\w-]*\\.[\\w-]*\\.[\\w-]*\\b/g,\n mask: () => 'eyJ***.***',\n },\n /** Bearer tokens → Bearer *** */\n bearer: {\n pattern: /\\bBearer\\s+[\\w\\-.~+/]{8,}=*/gi,\n mask: () => 'Bearer ***',\n },\n /** IBAN → FR76****189 (country + check digits + last 3) */\n iban: {\n pattern:\n /\\b[A-Z]{2}\\d{2}[\\s-]?[\\dA-Z]{4}[\\s-]?[\\dA-Z]{4}[\\s-]?[\\dA-Z]{4}[\\s-]?[\\dA-Z]{0,4}[\\s-]?[\\dA-Z]{0,4}[\\s-]?[\\dA-Z]{0,4}\\b/g,\n mask: (m: string) => {\n const clean = m.replaceAll(/[\\s-]/g, '');\n return `${clean.slice(0, 4)}****${clean.slice(-3)}`;\n },\n },\n} as const;\n\nfunction cloneRegex(re: RegExp): RegExp {\n return new RegExp(re.source, re.flags);\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction toRegExp(value: unknown): RegExp | undefined {\n if (value instanceof RegExp) return value;\n if (typeof value === 'string') return new RegExp(value, 'g');\n if (isPlainObject(value) && typeof value.source === 'string') {\n const flags = typeof value.flags === 'string' ? value.flags : 'g';\n return new RegExp(value.source, flags);\n }\n return undefined;\n}\n\nfunction toRegExpArray(value: unknown): RegExp[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const out: RegExp[] = [];\n for (const item of value) {\n const re = toRegExp(item);\n if (re) out.push(re);\n }\n return out.length > 0 ? out : [];\n}\n\nfunction builtinToValuePattern(name: BuiltinPatternName): ValuePatternConfig {\n const b = builtinPatterns[name];\n return { name, pattern: cloneRegex(b.pattern), mask: b.mask };\n}\n\n/**\n * Default value patterns for the 'default' preset\n */\nconst DEFAULT_VALUE_PATTERNS: ValuePatternConfig[] = [\n builtinToValuePattern('email'),\n builtinToValuePattern('phone'),\n { name: 'ssn', pattern: REDACTOR_PATTERNS.ssn },\n builtinToValuePattern('creditCard'),\n];\n\n/**\n * Built-in redactor presets\n */\nexport const REDACTOR_PRESETS: Record<\n AttributeRedactorPreset,\n AttributeRedactorConfig\n> = {\n /**\n * Default preset - covers common PII patterns with smart masking\n * Detects: emails (a***@***.com), phone numbers, SSNs, credit cards (****1111)\n * Redacts keys: password, secret, token, apiKey, auth, credential\n */\n default: {\n keyPatterns: [REDACTOR_PATTERNS.sensitiveKey],\n valuePatterns: DEFAULT_VALUE_PATTERNS,\n builtins: true,\n replacement: '[REDACTED]',\n },\n\n /**\n * Strict preset - more aggressive redaction for high-security environments\n * Includes everything in default plus: Bearer tokens, JWTs, IBAN, API keys in values\n */\n strict: {\n keyPatterns: [REDACTOR_PATTERNS.sensitiveKey, /bearer/i, /jwt/i],\n valuePatterns: [\n ...DEFAULT_VALUE_PATTERNS,\n builtinToValuePattern('jwt'),\n builtinToValuePattern('bearer'),\n builtinToValuePattern('iban'),\n { name: 'apiKeyInValue', pattern: REDACTOR_PATTERNS.apiKeyInValue },\n ],\n builtins: true,\n replacement: '[REDACTED]',\n },\n\n /**\n * PCI-DSS preset - focused on payment card industry compliance\n * Redacts: credit card numbers (****1111), CVV-like patterns, card-related keys\n */\n 'pci-dss': {\n keyPatterns: [/card/i, /cvv/i, /cvc/i, /pan/i, /expir/i, /ccn/i],\n valuePatterns: [builtinToValuePattern('creditCard')],\n builtins: ['creditCard'],\n replacement: '[REDACTED]',\n },\n};\n\n/**\n * Normalize redactor config that may have been deserialized from JSON/YAML.\n * Converts regex-like values back to RegExp instances.\n */\nexport function normalizeAttributeRedactorConfig(\n raw: AttributeRedactorConfig | AttributeRedactorPreset | unknown,\n): AttributeRedactorConfig | AttributeRedactorPreset | undefined {\n if (raw === undefined || raw === null) return undefined;\n if (typeof raw === 'string') return raw as AttributeRedactorPreset;\n if (!isPlainObject(raw)) return undefined;\n\n const config: AttributeRedactorConfig = {};\n\n if (Array.isArray(raw.paths)) {\n config.paths = raw.paths.filter(\n (value): value is string => typeof value === 'string',\n );\n }\n\n if (typeof raw.replacement === 'string') {\n config.replacement = raw.replacement;\n }\n\n if (typeof raw.builtins === 'boolean') {\n config.builtins = raw.builtins;\n } else if (Array.isArray(raw.builtins)) {\n config.builtins = raw.builtins.filter(\n (name): name is BuiltinPatternName => typeof name === 'string',\n );\n }\n\n if (typeof raw.redactor === 'function') {\n config.redactor = raw.redactor as AttributeRedactorFn;\n }\n\n const keyPatterns = toRegExpArray(raw.keyPatterns);\n if (keyPatterns) config.keyPatterns = keyPatterns;\n\n const patterns = toRegExpArray(raw.patterns);\n if (patterns) config.patterns = patterns;\n\n if (Array.isArray(raw.valuePatterns)) {\n const valuePatterns: ValuePatternConfig[] = [];\n for (const item of raw.valuePatterns) {\n if (!isPlainObject(item) || typeof item.name !== 'string') continue;\n const pattern = toRegExp(item.pattern);\n if (!pattern) continue;\n valuePatterns.push({\n name: item.name,\n pattern,\n replacement:\n typeof item.replacement === 'string' ? item.replacement : undefined,\n mask:\n typeof item.mask === 'function' ? (item.mask as MaskFn) : undefined,\n });\n }\n config.valuePatterns = valuePatterns;\n }\n\n return config;\n}\n\n/**\n * Resolve config to a normalized form\n */\nfunction resolveConfig(\n config: AttributeRedactorConfig | AttributeRedactorPreset,\n): AttributeRedactorConfig {\n const normalized = normalizeAttributeRedactorConfig(config);\n if (!normalized) {\n throw new Error('Invalid attribute redactor config');\n }\n\n if (typeof normalized === 'string') {\n const preset = REDACTOR_PRESETS[normalized];\n if (!preset) {\n throw new Error(\n `Unknown attribute redactor preset: \"${normalized}\". ` +\n `Available presets: ${Object.keys(REDACTOR_PRESETS).join(', ')}`,\n );\n }\n return preset;\n }\n\n const resolvedConfig: AttributeRedactorConfig = {\n ...normalized,\n keyPatterns: normalized.keyPatterns\n ? [...normalized.keyPatterns]\n : undefined,\n valuePatterns: normalized.valuePatterns\n ? [...normalized.valuePatterns]\n : undefined,\n paths: normalized.paths ? [...normalized.paths] : undefined,\n patterns: normalized.patterns ? [...normalized.patterns] : undefined,\n };\n\n // Merge built-in patterns if enabled\n if (resolvedConfig.builtins !== false) {\n const builtinNames = Array.isArray(resolvedConfig.builtins)\n ? resolvedConfig.builtins\n : (Object.keys(builtinPatterns) as BuiltinPatternName[]);\n const builtinValuePatterns = builtinNames\n .filter((name) => name in builtinPatterns)\n .map((name) => builtinToValuePattern(name));\n\n resolvedConfig.valuePatterns = [\n ...(resolvedConfig.valuePatterns ?? []),\n ...builtinValuePatterns,\n ];\n }\n\n return resolvedConfig;\n}\n\n/**\n * Create a redactor function from config\n */\nfunction createRedactorFromConfig(\n config: AttributeRedactorConfig,\n): AttributeRedactorFn {\n // If custom redactor provided, use it directly\n if (config.redactor) {\n return config.redactor;\n }\n\n const keyPatterns = config.keyPatterns ?? [];\n const valuePatterns = config.valuePatterns ?? [];\n const paths = config.paths ?? [];\n const pathSet = new Set(paths);\n const customPatterns = config.patterns ?? [];\n const defaultReplacement = config.replacement ?? '[REDACTED]';\n\n // Build masker list from valuePatterns that have mask functions\n const maskers: [RegExp, MaskFn][] = valuePatterns\n .filter((vp) => vp.mask)\n .map((vp) => [cloneRegex(vp.pattern), vp.mask!]);\n\n return (key: string, value: AttributeValue): AttributeValue => {\n // Key-pattern and path-based redaction only applies to string values.\n // Numbers, booleans and other non-string attributes are not credentials;\n // replacing them with the string '[REDACTED]' silently changes their\n // type and corrupts downstream consumers (LLM token counters etc.).\n if (typeof value === 'string') {\n for (const pattern of keyPatterns) {\n pattern.lastIndex = 0;\n if (pattern.test(key)) {\n return defaultReplacement;\n }\n }\n if (pathSet.has(key)) {\n return defaultReplacement;\n }\n }\n\n // For non-string values, return as-is\n if (typeof value !== 'string') {\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (typeof item === 'string') {\n return redactStringValue(\n item,\n valuePatterns,\n maskers,\n customPatterns,\n defaultReplacement,\n ) as string;\n }\n return item;\n }) as AttributeValue;\n }\n return value;\n }\n\n // Three-tier strategy: path-based → masker-based → pattern-based\n return redactStringValue(\n value,\n valuePatterns,\n maskers,\n customPatterns,\n defaultReplacement,\n );\n };\n}\n\n/**\n * Apply three-tier redaction strategy to a string\n * 1. Masker-based: built-in patterns with smart partial masking\n * 2. Pattern-based: custom RegExp patterns replaced with replacement\n */\nfunction redactStringValue(\n value: string,\n patterns: ValuePatternConfig[],\n maskers: [RegExp, MaskFn][],\n customPatterns: RegExp[],\n defaultReplacement: string,\n): string {\n let result = value;\n\n // Tier 1: Apply maskers (smart partial masking)\n for (const [pattern, mask] of maskers) {\n pattern.lastIndex = 0;\n result = result.replace(pattern, mask);\n }\n\n // Tier 2: Apply value patterns without mask (full replacement)\n for (const { pattern, replacement, mask } of patterns) {\n if (mask) continue; // Already handled by maskers\n pattern.lastIndex = 0;\n result = result.replaceAll(pattern, replacement ?? defaultReplacement);\n }\n\n // Tier 3: Apply custom patterns\n for (const pattern of customPatterns) {\n pattern.lastIndex = 0;\n result = result.replaceAll(pattern, defaultReplacement);\n }\n\n return result;\n}\n\n/**\n * Create a proxy wrapper around ReadableSpan with redacted attributes\n *\n * Since ReadableSpan.attributes is readonly, we use a Proxy to intercept\n * attribute access and return the redacted version.\n */\nfunction createRedactedSpan(\n span: ReadableSpan,\n redactor: AttributeRedactorFn,\n): ReadableSpan {\n // Pre-compute redacted attributes (cached for efficiency)\n const redactedAttributes: Attributes = {};\n for (const [key, value] of Object.entries(span.attributes)) {\n if (value !== undefined) {\n redactedAttributes[key] = redactor(key, value);\n }\n }\n\n // Return a proxy that intercepts attribute access\n return new Proxy(span, {\n get(target, prop) {\n if (prop === 'attributes') {\n return redactedAttributes;\n }\n // For all other properties, delegate to the original span\n const value = Reflect.get(target, prop);\n // Bind methods to the original target\n if (typeof value === 'function') {\n return value.bind(target);\n }\n return value;\n },\n });\n}\n\n/**\n * Create an attribute redactor function from a config or preset.\n *\n * This is useful when you need to apply the same redaction logic\n * outside of the span processor pipeline (e.g., for canonical log lines).\n *\n * @example\n * ```typescript\n * const redactor = createAttributeRedactor('default');\n * const redactedValue = redactor('user.password', 'secret123');\n * // redactedValue === '[REDACTED]'\n * ```\n */\nexport function createAttributeRedactor(\n config: AttributeRedactorConfig | AttributeRedactorPreset,\n): AttributeRedactorFn {\n return createRedactorFromConfig(resolveConfig(config));\n}\n\n/**\n * Span processor that redacts sensitive data from span attributes.\n *\n * Redaction happens in onEnd() when all attributes are finalized.\n * Uses a Proxy wrapper to intercept attribute access since ReadableSpan\n * attributes are readonly.\n *\n * Common use cases:\n * - PII compliance (GDPR, CCPA)\n * - PCI-DSS compliance for payment data\n * - Preventing secrets from leaking to observability backends\n */\nexport class AttributeRedactingProcessor implements SpanProcessor {\n private readonly wrappedProcessor: SpanProcessor;\n private readonly redactor: AttributeRedactorFn;\n\n constructor(\n wrappedProcessor: SpanProcessor,\n options: AttributeRedactingProcessorOptions,\n ) {\n this.wrappedProcessor = wrappedProcessor;\n const config = resolveConfig(options.redactor);\n this.redactor = createRedactorFromConfig(config);\n }\n\n /**\n * Pass through onStart unchanged - attributes aren't finalized yet\n */\n onStart(span: Span, parentContext: Context): void {\n this.wrappedProcessor.onStart(span, parentContext);\n }\n\n /**\n * Redact attributes and forward to wrapped processor\n */\n onEnd(span: ReadableSpan): void {\n try {\n const redactedSpan = createRedactedSpan(span, this.redactor);\n this.wrappedProcessor.onEnd(redactedSpan);\n } catch {\n // Fail-open: if redaction fails, forward original span\n // This ensures we don't lose telemetry due to redaction errors\n this.wrappedProcessor.onEnd(span);\n }\n }\n\n forceFlush(): Promise<void> {\n return this.wrappedProcessor.forceFlush();\n }\n\n shutdown(): Promise<void> {\n return this.wrappedProcessor.shutdown();\n }\n}\n\n/**\n * Export createRedactedSpan for advanced users who want to use it directly\n */\nexport { createRedactedSpan };\n"],"mappings":";;;;AA4GA,MAAa,oBAAoB;CAE/B,OAAO;CACP,OAAO;CACP,KAAK;CACL,YAAY;CACZ,aAAa;CACb,eAAe;CACf,KAAK;CAGL,cACE;AACJ;;;;;AAMA,MAAa,kBAAkB;;CAE7B,YAAY;EACV,SAAS;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;;;;;;AAeA,SAAgB,wBACd,QACqB;CACrB,OAAO,yBAAyB,cAAc,MAAM,CAAC;AACvD;;;;;;;;;;;;;AAcA,IAAa,8BAAb,MAAkE;CAChE,AAAiB;CACjB,AAAiB;CAEjB,YACE,kBACA,SACA;EACA,KAAK,mBAAmB;EACxB,MAAM,SAAS,cAAc,QAAQ,QAAQ;EAC7C,KAAK,WAAW,yBAAyB,MAAM;CACjD;;;;CAKA,QAAQ,MAAY,eAA8B;EAChD,KAAK,iBAAiB,QAAQ,MAAM,aAAa;CACnD;;;;CAKA,MAAM,MAA0B;EAC9B,IAAI;GACF,MAAM,eAAe,mBAAmB,MAAM,KAAK,QAAQ;GAC3D,KAAK,iBAAiB,MAAM,YAAY;EAC1C,QAAQ;GAGN,KAAK,iBAAiB,MAAM,IAAI;EAClC;CACF;CAEA,aAA4B;EAC1B,OAAO,KAAK,iBAAiB,WAAW;CAC1C;CAEA,WAA0B;EACxB,OAAO,KAAK,iBAAiB,SAAS;CACxC;AACF"}
|
package/dist/attributes.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as ExceptionAttrs, B as PeerAttrs, C as CloudAttrs, D as DeploymentAttrs, E as DBAttrs, F as HTTPServerAttrs, G as SessionAttrs, H as RPCAttrs, I as K8sAttrs, J as URLAttrs, K as TLSAttrs, L as MessagingAttrs, M as FeatureFlagAttrs, N as GraphQLAttrs, O as DeviceAttrs, P as HTTPClientAttrs, R as NetworkAttrs, S as ClientAttrs, T as ContainerAttrs, U as ServerAddressAttrs, V as ProcessAttrs, W as ServiceAttrs, Y as UserAttrs, _ as autoRedactPII, a as httpClient, b as validateAttribute, c as mergeServiceResource, d as setError, f as setException, g as AttributePolicy, h as AttributeGuardrails, i as dbClient, j as FaaSAttrs, k as ErrorAttrs, l as request, m as setUser, n as safeSetAttributes, o as httpServer, p as setSession, q as ThreadAttrs, r as transaction, s as identify, t as mergeAttrs, u as setDevice, v as checkDeprecatedAttribute, w as CodeAttrs, x as attrs, y as defaultGuardrails, z as OTelAttrs } from "./index-
|
|
1
|
+
import { A as ExceptionAttrs, B as PeerAttrs, C as CloudAttrs, D as DeploymentAttrs, E as DBAttrs, F as HTTPServerAttrs, G as SessionAttrs, H as RPCAttrs, I as K8sAttrs, J as URLAttrs, K as TLSAttrs, L as MessagingAttrs, M as FeatureFlagAttrs, N as GraphQLAttrs, O as DeviceAttrs, P as HTTPClientAttrs, R as NetworkAttrs, S as ClientAttrs, T as ContainerAttrs, U as ServerAddressAttrs, V as ProcessAttrs, W as ServiceAttrs, Y as UserAttrs, _ as autoRedactPII, a as httpClient, b as validateAttribute, c as mergeServiceResource, d as setError, f as setException, g as AttributePolicy, h as AttributeGuardrails, i as dbClient, j as FaaSAttrs, k as ErrorAttrs, l as request, m as setUser, n as safeSetAttributes, o as httpServer, p as setSession, q as ThreadAttrs, r as transaction, s as identify, t as mergeAttrs, u as setDevice, v as checkDeprecatedAttribute, w as CodeAttrs, x as attrs, y as defaultGuardrails, z as OTelAttrs } from "./index-BPcxVucm.cjs";
|
|
2
2
|
export { type AttributeGuardrails, type AttributePolicy, type ClientAttrs, type CloudAttrs, type CodeAttrs, type ContainerAttrs, type DBAttrs, type DeploymentAttrs, type DeviceAttrs, type ErrorAttrs, type ExceptionAttrs, type FaaSAttrs, type FeatureFlagAttrs, type GraphQLAttrs, type HTTPClientAttrs, type HTTPServerAttrs, type K8sAttrs, type MessagingAttrs, type NetworkAttrs, type OTelAttrs, type PeerAttrs, type ProcessAttrs, type RPCAttrs, type ServerAddressAttrs, type ServiceAttrs, type SessionAttrs, type TLSAttrs, type ThreadAttrs, type URLAttrs, type UserAttrs, attrs, autoRedactPII, checkDeprecatedAttribute, dbClient, defaultGuardrails, httpClient, httpServer, identify, mergeAttrs, mergeServiceResource, request, safeSetAttributes, setDevice, setError, setException, setSession, setUser, transaction, validateAttribute };
|
package/dist/attributes.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as ExceptionAttrs, B as PeerAttrs, C as CloudAttrs, D as DeploymentAttrs, E as DBAttrs, F as HTTPServerAttrs, G as SessionAttrs, H as RPCAttrs, I as K8sAttrs, J as URLAttrs, K as TLSAttrs, L as MessagingAttrs, M as FeatureFlagAttrs, N as GraphQLAttrs, O as DeviceAttrs, P as HTTPClientAttrs, R as NetworkAttrs, S as ClientAttrs, T as ContainerAttrs, U as ServerAddressAttrs, V as ProcessAttrs, W as ServiceAttrs, Y as UserAttrs, _ as autoRedactPII, a as httpClient, b as validateAttribute, c as mergeServiceResource, d as setError, f as setException, g as AttributePolicy, h as AttributeGuardrails, i as dbClient, j as FaaSAttrs, k as ErrorAttrs, l as request, m as setUser, n as safeSetAttributes, o as httpServer, p as setSession, q as ThreadAttrs, r as transaction, s as identify, t as mergeAttrs, u as setDevice, v as checkDeprecatedAttribute, w as CodeAttrs, x as attrs, y as defaultGuardrails, z as OTelAttrs } from "./index-
|
|
1
|
+
import { A as ExceptionAttrs, B as PeerAttrs, C as CloudAttrs, D as DeploymentAttrs, E as DBAttrs, F as HTTPServerAttrs, G as SessionAttrs, H as RPCAttrs, I as K8sAttrs, J as URLAttrs, K as TLSAttrs, L as MessagingAttrs, M as FeatureFlagAttrs, N as GraphQLAttrs, O as DeviceAttrs, P as HTTPClientAttrs, R as NetworkAttrs, S as ClientAttrs, T as ContainerAttrs, U as ServerAddressAttrs, V as ProcessAttrs, W as ServiceAttrs, Y as UserAttrs, _ as autoRedactPII, a as httpClient, b as validateAttribute, c as mergeServiceResource, d as setError, f as setException, g as AttributePolicy, h as AttributeGuardrails, i as dbClient, j as FaaSAttrs, k as ErrorAttrs, l as request, m as setUser, n as safeSetAttributes, o as httpServer, p as setSession, q as ThreadAttrs, r as transaction, s as identify, t as mergeAttrs, u as setDevice, v as checkDeprecatedAttribute, w as CodeAttrs, x as attrs, y as defaultGuardrails, z as OTelAttrs } from "./index-DolOVX6F.js";
|
|
2
2
|
export { type AttributeGuardrails, type AttributePolicy, type ClientAttrs, type CloudAttrs, type CodeAttrs, type ContainerAttrs, type DBAttrs, type DeploymentAttrs, type DeviceAttrs, type ErrorAttrs, type ExceptionAttrs, type FaaSAttrs, type FeatureFlagAttrs, type GraphQLAttrs, type HTTPClientAttrs, type HTTPServerAttrs, type K8sAttrs, type MessagingAttrs, type NetworkAttrs, type OTelAttrs, type PeerAttrs, type ProcessAttrs, type RPCAttrs, type ServerAddressAttrs, type ServiceAttrs, type SessionAttrs, type TLSAttrs, type ThreadAttrs, type URLAttrs, type UserAttrs, attrs, autoRedactPII, checkDeprecatedAttribute, dbClient, defaultGuardrails, httpClient, httpServer, identify, mergeAttrs, mergeServiceResource, request, safeSetAttributes, setDevice, setError, setException, setSession, setUser, transaction, validateAttribute };
|
package/dist/auto.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
|
|
2
|
-
const require_init = require('./init-
|
|
2
|
+
const require_init = require('./init-C3RApHKJ.cjs');
|
|
3
3
|
const require_yaml_config = require('./yaml-config.cjs');
|
|
4
4
|
let node_module = require("node:module");
|
|
5
5
|
node_module = require_rolldown_runtime.__toESM(node_module, 1);
|
package/dist/auto.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.cjs","names":["nodeModule","loadYamlConfig","init"],"sources":["../src/auto.ts"],"sourcesContent":["/**\n * Zero-config ESM instrumentation with auto-init from YAML/environment variables\n *\n * This module provides the simplest possible setup for OpenTelemetry instrumentation.\n * Just import it and everything is configured from autotel.yaml or environment variables.\n *\n * Usage with YAML config (recommended):\n * ```bash\n * # Create autotel.yaml in project root, then:\n * tsx --import autotel/auto src/index.ts\n * ```\n *\n * Usage with environment variables:\n * ```bash\n * OTEL_SERVICE_NAME=my-app tsx --import autotel/auto src/index.ts\n * ```\n *\n * No instrumentation.ts file needed!\n *\n * Configuration Priority (highest to lowest):\n * 1. YAML file (autotel.yaml or AUTOTEL_CONFIG_FILE)\n * 2. Environment variables (OTEL_*, AUTOTEL_*)\n * 3. Built-in defaults\n *\n * Environment Variables:\n * - OTEL_SERVICE_NAME: Service name (required for meaningful traces)\n * - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP collector endpoint (e.g., http://localhost:4318)\n * - OTEL_EXPORTER_OTLP_HEADERS: Auth headers (e.g., x-honeycomb-team=YOUR_KEY)\n * - AUTOTEL_INTEGRATIONS: Comma-separated list or 'true' for all (default: http,express)\n * - AUTOTEL_DEBUG: Set to 'true' to enable console span output\n * - AUTOTEL_CONFIG_FILE: Path to YAML config file (overrides autotel.yaml discovery)\n *\n * @requires Node.js 20.6.0 or later\n */\n\n// namespace import for browser-bundler compat — see node-require.ts\nimport * as nodeModule from 'node:module';\nimport { createAddHookMessageChannel } from 'import-in-the-middle';\nimport { init } from './init';\nimport { loadYamlConfig } from './yaml-config';\n\n// Register ESM hooks first (must happen before any instrumented modules load)\nconst { registerOptions } = createAddHookMessageChannel();\nnodeModule.register(\n 'import-in-the-middle/hook.mjs',\n import.meta.url,\n registerOptions,\n);\n\n// Load YAML config if present (init.ts will also load it, but we need values here)\nconst yamlConfig = loadYamlConfig();\n\n// Parse auto-instrumentations from environment variable (fallback if not in YAML)\nconst autoInstrumentationsEnv = process.env.AUTOTEL_INTEGRATIONS;\nconst autoInstrumentations:\n
|
|
1
|
+
{"version":3,"file":"auto.cjs","names":["nodeModule","loadYamlConfig","init"],"sources":["../src/auto.ts"],"sourcesContent":["/**\n * Zero-config ESM instrumentation with auto-init from YAML/environment variables\n *\n * This module provides the simplest possible setup for OpenTelemetry instrumentation.\n * Just import it and everything is configured from autotel.yaml or environment variables.\n *\n * Usage with YAML config (recommended):\n * ```bash\n * # Create autotel.yaml in project root, then:\n * tsx --import autotel/auto src/index.ts\n * ```\n *\n * Usage with environment variables:\n * ```bash\n * OTEL_SERVICE_NAME=my-app tsx --import autotel/auto src/index.ts\n * ```\n *\n * No instrumentation.ts file needed!\n *\n * Configuration Priority (highest to lowest):\n * 1. YAML file (autotel.yaml or AUTOTEL_CONFIG_FILE)\n * 2. Environment variables (OTEL_*, AUTOTEL_*)\n * 3. Built-in defaults\n *\n * Environment Variables:\n * - OTEL_SERVICE_NAME: Service name (required for meaningful traces)\n * - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP collector endpoint (e.g., http://localhost:4318)\n * - OTEL_EXPORTER_OTLP_HEADERS: Auth headers (e.g., x-honeycomb-team=YOUR_KEY)\n * - AUTOTEL_INTEGRATIONS: Comma-separated list or 'true' for all (default: http,express)\n * - AUTOTEL_DEBUG: Set to 'true' to enable console span output\n * - AUTOTEL_CONFIG_FILE: Path to YAML config file (overrides autotel.yaml discovery)\n *\n * @requires Node.js 20.6.0 or later\n */\n\n// namespace import for browser-bundler compat — see node-require.ts\nimport * as nodeModule from 'node:module';\nimport { createAddHookMessageChannel } from 'import-in-the-middle';\nimport { init } from './init';\nimport { loadYamlConfig } from './yaml-config';\n\n// Register ESM hooks first (must happen before any instrumented modules load)\nconst { registerOptions } = createAddHookMessageChannel();\nnodeModule.register(\n 'import-in-the-middle/hook.mjs',\n import.meta.url,\n registerOptions,\n);\n\n// Load YAML config if present (init.ts will also load it, but we need values here)\nconst yamlConfig = loadYamlConfig();\n\n// Parse auto-instrumentations from environment variable (fallback if not in YAML)\nconst autoInstrumentationsEnv = process.env.AUTOTEL_INTEGRATIONS;\nconst autoInstrumentations:\n string[] | boolean | Record<string, { enabled?: boolean }> =\n autoInstrumentationsEnv === 'true'\n ? true // Enable all auto-instrumentations\n : autoInstrumentationsEnv\n ? autoInstrumentationsEnv.split(',').map((s) => s.trim())\n : (yamlConfig?.autoInstrumentations ?? ['http', 'express']); // YAML > default\n\n// Auto-initialize with YAML config merged with env var defaults\n// init() will load YAML again and merge properly, but we pass overrides here\ninit({\n service:\n yamlConfig?.service ?? process.env.OTEL_SERVICE_NAME ?? 'unknown-service',\n debug: yamlConfig?.debug ?? process.env.AUTOTEL_DEBUG === 'true',\n autoInstrumentations,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,EAAE,0EAAgD;AACxDA,YAAW,SACT,gFAEA,eACF;AAGA,MAAM,aAAaC,mCAAe;AAGlC,MAAM,0BAA0B,QAAQ,IAAI;AAC5C,MAAM,uBAEJ,4BAA4B,SACxB,OACA,0BACE,wBAAwB,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK,CAAC,IACrD,YAAY,wBAAwB,CAAC,QAAQ,SAAS;AAI/DC,kBAAK;CACH,SACE,YAAY,WAAW,QAAQ,IAAI,qBAAqB;CAC1D,OAAO,YAAY,SAAS,QAAQ,IAAI,kBAAkB;CAC1D;AACF,CAAC"}
|
package/dist/auto.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/auto.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/auto.js
CHANGED
package/dist/auto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.js","names":[],"sources":["../src/auto.ts"],"sourcesContent":["/**\n * Zero-config ESM instrumentation with auto-init from YAML/environment variables\n *\n * This module provides the simplest possible setup for OpenTelemetry instrumentation.\n * Just import it and everything is configured from autotel.yaml or environment variables.\n *\n * Usage with YAML config (recommended):\n * ```bash\n * # Create autotel.yaml in project root, then:\n * tsx --import autotel/auto src/index.ts\n * ```\n *\n * Usage with environment variables:\n * ```bash\n * OTEL_SERVICE_NAME=my-app tsx --import autotel/auto src/index.ts\n * ```\n *\n * No instrumentation.ts file needed!\n *\n * Configuration Priority (highest to lowest):\n * 1. YAML file (autotel.yaml or AUTOTEL_CONFIG_FILE)\n * 2. Environment variables (OTEL_*, AUTOTEL_*)\n * 3. Built-in defaults\n *\n * Environment Variables:\n * - OTEL_SERVICE_NAME: Service name (required for meaningful traces)\n * - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP collector endpoint (e.g., http://localhost:4318)\n * - OTEL_EXPORTER_OTLP_HEADERS: Auth headers (e.g., x-honeycomb-team=YOUR_KEY)\n * - AUTOTEL_INTEGRATIONS: Comma-separated list or 'true' for all (default: http,express)\n * - AUTOTEL_DEBUG: Set to 'true' to enable console span output\n * - AUTOTEL_CONFIG_FILE: Path to YAML config file (overrides autotel.yaml discovery)\n *\n * @requires Node.js 20.6.0 or later\n */\n\n// namespace import for browser-bundler compat — see node-require.ts\nimport * as nodeModule from 'node:module';\nimport { createAddHookMessageChannel } from 'import-in-the-middle';\nimport { init } from './init';\nimport { loadYamlConfig } from './yaml-config';\n\n// Register ESM hooks first (must happen before any instrumented modules load)\nconst { registerOptions } = createAddHookMessageChannel();\nnodeModule.register(\n 'import-in-the-middle/hook.mjs',\n import.meta.url,\n registerOptions,\n);\n\n// Load YAML config if present (init.ts will also load it, but we need values here)\nconst yamlConfig = loadYamlConfig();\n\n// Parse auto-instrumentations from environment variable (fallback if not in YAML)\nconst autoInstrumentationsEnv = process.env.AUTOTEL_INTEGRATIONS;\nconst autoInstrumentations:\n
|
|
1
|
+
{"version":3,"file":"auto.js","names":[],"sources":["../src/auto.ts"],"sourcesContent":["/**\n * Zero-config ESM instrumentation with auto-init from YAML/environment variables\n *\n * This module provides the simplest possible setup for OpenTelemetry instrumentation.\n * Just import it and everything is configured from autotel.yaml or environment variables.\n *\n * Usage with YAML config (recommended):\n * ```bash\n * # Create autotel.yaml in project root, then:\n * tsx --import autotel/auto src/index.ts\n * ```\n *\n * Usage with environment variables:\n * ```bash\n * OTEL_SERVICE_NAME=my-app tsx --import autotel/auto src/index.ts\n * ```\n *\n * No instrumentation.ts file needed!\n *\n * Configuration Priority (highest to lowest):\n * 1. YAML file (autotel.yaml or AUTOTEL_CONFIG_FILE)\n * 2. Environment variables (OTEL_*, AUTOTEL_*)\n * 3. Built-in defaults\n *\n * Environment Variables:\n * - OTEL_SERVICE_NAME: Service name (required for meaningful traces)\n * - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP collector endpoint (e.g., http://localhost:4318)\n * - OTEL_EXPORTER_OTLP_HEADERS: Auth headers (e.g., x-honeycomb-team=YOUR_KEY)\n * - AUTOTEL_INTEGRATIONS: Comma-separated list or 'true' for all (default: http,express)\n * - AUTOTEL_DEBUG: Set to 'true' to enable console span output\n * - AUTOTEL_CONFIG_FILE: Path to YAML config file (overrides autotel.yaml discovery)\n *\n * @requires Node.js 20.6.0 or later\n */\n\n// namespace import for browser-bundler compat — see node-require.ts\nimport * as nodeModule from 'node:module';\nimport { createAddHookMessageChannel } from 'import-in-the-middle';\nimport { init } from './init';\nimport { loadYamlConfig } from './yaml-config';\n\n// Register ESM hooks first (must happen before any instrumented modules load)\nconst { registerOptions } = createAddHookMessageChannel();\nnodeModule.register(\n 'import-in-the-middle/hook.mjs',\n import.meta.url,\n registerOptions,\n);\n\n// Load YAML config if present (init.ts will also load it, but we need values here)\nconst yamlConfig = loadYamlConfig();\n\n// Parse auto-instrumentations from environment variable (fallback if not in YAML)\nconst autoInstrumentationsEnv = process.env.AUTOTEL_INTEGRATIONS;\nconst autoInstrumentations:\n string[] | boolean | Record<string, { enabled?: boolean }> =\n autoInstrumentationsEnv === 'true'\n ? true // Enable all auto-instrumentations\n : autoInstrumentationsEnv\n ? autoInstrumentationsEnv.split(',').map((s) => s.trim())\n : (yamlConfig?.autoInstrumentations ?? ['http', 'express']); // YAML > default\n\n// Auto-initialize with YAML config merged with env var defaults\n// init() will load YAML again and merge properly, but we pass overrides here\ninit({\n service:\n yamlConfig?.service ?? process.env.OTEL_SERVICE_NAME ?? 'unknown-service',\n debug: yamlConfig?.debug ?? process.env.AUTOTEL_DEBUG === 'true',\n autoInstrumentations,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,EAAE,oBAAoB,4BAA4B;AACxD,WAAW,SACT,iCACA,OAAO,KAAK,KACZ,eACF;AAGA,MAAM,aAAa,eAAe;AAGlC,MAAM,0BAA0B,QAAQ,IAAI;AAC5C,MAAM,uBAEJ,4BAA4B,SACxB,OACA,0BACE,wBAAwB,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK,CAAC,IACrD,YAAY,wBAAwB,CAAC,QAAQ,SAAS;AAI/D,KAAK;CACH,SACE,YAAY,WAAW,QAAQ,IAAI,qBAAqB;CAC1D,OAAO,YAAY,SAAS,QAAQ,IAAI,kBAAkB;CAC1D;AACF,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { n as TraceContext } from "./trace-context-
|
|
2
|
-
|
|
1
|
+
import { n as TraceContext } from "./trace-context-IuyoPyNq.cjs";
|
|
3
2
|
//#region src/business-baggage.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Supported field types in baggage schema
|
|
@@ -52,7 +51,7 @@ type BaggageSchemaDefinition = Record<string, BaggageFieldDefinition>;
|
|
|
52
51
|
/**
|
|
53
52
|
* Inferred type from schema definition
|
|
54
53
|
*/
|
|
55
|
-
type InferBaggageType<T extends BaggageSchemaDefinition> = { [K in keyof T]?: T[K]['type'] extends 'string' ? string : T[K]['type'] extends 'number' ? number : T[K]['type'] extends 'boolean' ? boolean : T[K]['type'] extends 'enum' ? T[K]['values'] extends readonly string[] ? T[K]['values'][number] : string : unknown };
|
|
54
|
+
type InferBaggageType<T extends BaggageSchemaDefinition> = { [K in keyof T]?: T[K]['type'] extends 'string' ? string : T[K]['type'] extends 'number' ? number : T[K]['type'] extends 'boolean' ? boolean : T[K]['type'] extends 'enum' ? T[K]['values'] extends readonly string[] ? T[K]['values'][number] : string : unknown; };
|
|
56
55
|
/**
|
|
57
56
|
* Baggage error details
|
|
58
57
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"business-baggage.d.cts","names":[],"sources":["../src/business-baggage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"business-baggage.d.cts","names":[],"sources":["../src/business-baggage.ts"],"mappings":";;;;;KA0CY;;;;UAKK;;EAEf,MAAM;;EAGN;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,YAAY;;;;;UAMG;;EAEf;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,WAAW,OAAO;;;;;KAMR,0BAA0B,eAAe;;;;KAKzC,iBAAiB,UAAU,8BACpC,WAAW,KAAK,EAAE,uCAEf,EAAE,uCAEA,EAAE,yCAEA,EAAE,4BACA,EAAE,yCACA,EAAE;;;;UAQC;EACf;EACA;EACA;EACA;;;;;UAMe,kBAAkB,UAAU;;;;EAI3C,IAAI,MAAM,eAAe,QAAQ,iBAAiB;;;;;EAMlD,IACE,KAAK,0BACL,QAAQ,QAAQ,iBAAiB;;;;EAMnC,SAAS,gBAAgB,GACvB,KAAK,GACL,MAAM,eACL,iBAAiB,GAAG;;;;EAKvB,SAAS,gBAAgB,GACvB,KAAK,GACL,OAAO,iBAAiB,GAAG,IAC3B,MAAM;;;;EAMR,MAAM,MAAM;;;;EAKZ,UAAU,MAAM,eAAe;;;;EAK/B,YAAY,SAAS,wBAAwB,MAAM;;;;;;;;;;;;;;;;;;iBA8CrC,wBAAwB,UAAU,yBAChD,QAAQ,GACR,UAAS,qBACR,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8XR,iBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDhB;EACV;EACA;EACA;EACA;EACA;EACA;EACA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { n as TraceContext } from "./trace-context-
|
|
2
|
-
|
|
1
|
+
import { n as TraceContext } from "./trace-context-IuyoPyNq.js";
|
|
3
2
|
//#region src/business-baggage.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Supported field types in baggage schema
|
|
@@ -52,7 +51,7 @@ type BaggageSchemaDefinition = Record<string, BaggageFieldDefinition>;
|
|
|
52
51
|
/**
|
|
53
52
|
* Inferred type from schema definition
|
|
54
53
|
*/
|
|
55
|
-
type InferBaggageType<T extends BaggageSchemaDefinition> = { [K in keyof T]?: T[K]['type'] extends 'string' ? string : T[K]['type'] extends 'number' ? number : T[K]['type'] extends 'boolean' ? boolean : T[K]['type'] extends 'enum' ? T[K]['values'] extends readonly string[] ? T[K]['values'][number] : string : unknown };
|
|
54
|
+
type InferBaggageType<T extends BaggageSchemaDefinition> = { [K in keyof T]?: T[K]['type'] extends 'string' ? string : T[K]['type'] extends 'number' ? number : T[K]['type'] extends 'boolean' ? boolean : T[K]['type'] extends 'enum' ? T[K]['values'] extends readonly string[] ? T[K]['values'][number] : string : unknown; };
|
|
56
55
|
/**
|
|
57
56
|
* Baggage error details
|
|
58
57
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"business-baggage.d.ts","names":[],"sources":["../src/business-baggage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"business-baggage.d.ts","names":[],"sources":["../src/business-baggage.ts"],"mappings":";;;;;KA0CY;;;;UAKK;;EAEf,MAAM;;EAGN;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,YAAY;;;;;UAMG;;EAEf;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,WAAW,OAAO;;;;;KAMR,0BAA0B,eAAe;;;;KAKzC,iBAAiB,UAAU,8BACpC,WAAW,KAAK,EAAE,uCAEf,EAAE,uCAEA,EAAE,yCAEA,EAAE,4BACA,EAAE,yCACA,EAAE;;;;UAQC;EACf;EACA;EACA;EACA;;;;;UAMe,kBAAkB,UAAU;;;;EAI3C,IAAI,MAAM,eAAe,QAAQ,iBAAiB;;;;;EAMlD,IACE,KAAK,0BACL,QAAQ,QAAQ,iBAAiB;;;;EAMnC,SAAS,gBAAgB,GACvB,KAAK,GACL,MAAM,eACL,iBAAiB,GAAG;;;;EAKvB,SAAS,gBAAgB,GACvB,KAAK,GACL,OAAO,iBAAiB,GAAG,IAC3B,MAAM;;;;EAMR,MAAM,MAAM;;;;EAKZ,UAAU,MAAM,eAAe;;;;EAK/B,YAAY,SAAS,wBAAwB,MAAM;;;;;;;;;;;;;;;;;;iBA8CrC,wBAAwB,UAAU,yBAChD,QAAQ,GACR,UAAS,qBACR,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8XR,iBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDhB;EACV;EACA;EACA;EACA;EACA;EACA;EACA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { s as Logger } from "./logger-
|
|
1
|
+
import { s as Logger } from "./logger-CN4xpzMd.cjs";
|
|
2
2
|
import { ReadableSpan, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
3
|
import { AttributeValue } from "@opentelemetry/api";
|
|
4
|
-
|
|
5
4
|
//#region src/processors/canonical-log-line-processor.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Function to redact sensitive attribute values
|
|
@@ -144,4 +143,4 @@ declare class CanonicalLogLineProcessor implements SpanProcessor {
|
|
|
144
143
|
}
|
|
145
144
|
//#endregion
|
|
146
145
|
export { CanonicalLogLineProcessor as n, CanonicalLogLineOptions as t };
|
|
147
|
-
//# sourceMappingURL=canonical-log-line-processor-
|
|
146
|
+
//# sourceMappingURL=canonical-log-line-processor-B4WgG-VS.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor-B4WgG-VS.d.cts","names":[],"sources":["../src/processors/canonical-log-line-processor.ts"],"mappings":";;;;;;;KAoCY,uBACV,aACA,OAAO,mBACJ;UAEY;EACf,MAAM;EACN;EACA;EACA,OAAO;;UAGQ;;EAEf;;EAEA;;EAEA;;UAGe;;EAEf,SAAS;;EAET;;EAEA;;EAEA,iBAAiB,MAAM;;EAEvB;;;;;;EAMA,oBAAoB;;EAEpB,cAAc,KAAK;;;;;;;;EAQnB,OAAO;;EAEP,SAAS,KAAK,iCAAiC;;EAE/C,gBAAgB,gBAAgB,KAAK;;;;;EAKrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4DW,qCAAqC;UACxC;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;EAGI,YAAA,UAAS;UAsBb;EA8BR;EAIA,MAAM,MAAM;UA+CJ;UA+BA;UAcA;UAQA;UA0BA;UAeA;UAKA;UAUA;EAUF,cAAc;EAId,YAAY"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { s as Logger } from "./logger-
|
|
1
|
+
import { s as Logger } from "./logger-CN4xpzMd.js";
|
|
2
2
|
import { ReadableSpan, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
3
3
|
import { AttributeValue } from "@opentelemetry/api";
|
|
4
|
-
|
|
5
4
|
//#region src/processors/canonical-log-line-processor.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Function to redact sensitive attribute values
|
|
@@ -144,4 +143,4 @@ declare class CanonicalLogLineProcessor implements SpanProcessor {
|
|
|
144
143
|
}
|
|
145
144
|
//#endregion
|
|
146
145
|
export { CanonicalLogLineProcessor as n, CanonicalLogLineOptions as t };
|
|
147
|
-
//# sourceMappingURL=canonical-log-line-processor-
|
|
146
|
+
//# sourceMappingURL=canonical-log-line-processor-CL_J7gb5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor-CL_J7gb5.d.ts","names":[],"sources":["../src/processors/canonical-log-line-processor.ts"],"mappings":";;;;;;;KAoCY,uBACV,aACA,OAAO,mBACJ;UAEY;EACf,MAAM;EACN;EACA;EACA,OAAO;;UAGQ;;EAEf;;EAEA;;EAEA;;UAGe;;EAEf,SAAS;;EAET;;EAEA;;EAEA,iBAAiB,MAAM;;EAEvB;;;;;;EAMA,oBAAoB;;EAEpB,cAAc,KAAK;;;;;;;;EAQnB,OAAO;;EAEP,SAAS,KAAK,iCAAiC;;EAE/C,gBAAgB,gBAAgB,KAAK;;;;;EAKrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4DW,qCAAqC;UACxC;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;EAGI,YAAA,UAAS;UAsBb;EA8BR;EAIA,MAAM,MAAM;UA+CJ;UA+BA;UAcA;UAQA;UA0BA;UAeA;UAKA;UAUA;EAUF,cAAc;EAId,YAAY"}
|
package/dist/{canonical-log-line-processor-CcrDi6TO.cjs → canonical-log-line-processor-DOjb6Kxy.cjs}
RENAMED
|
@@ -104,7 +104,7 @@ function groupAttributes(event) {
|
|
|
104
104
|
if (!(part in current) || typeof current[part] !== "object") current[part] = {};
|
|
105
105
|
current = current[part];
|
|
106
106
|
}
|
|
107
|
-
current[parts
|
|
107
|
+
current[parts.at(-1)] = value;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
return tree;
|
|
@@ -112,7 +112,7 @@ function groupAttributes(event) {
|
|
|
112
112
|
function renderTree(obj, indent, isLast) {
|
|
113
113
|
const lines = [];
|
|
114
114
|
const entries = Object.entries(obj);
|
|
115
|
-
|
|
115
|
+
for (const [idx, [key, value]] of entries.entries()) {
|
|
116
116
|
const last = idx === entries.length - 1;
|
|
117
117
|
const prefix = indent + (last ? "└─" : "├─") + " ";
|
|
118
118
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -127,14 +127,14 @@ function renderTree(obj, indent, isLast) {
|
|
|
127
127
|
lines.push(...renderTree(nested, nextIndent, [...isLast, last]));
|
|
128
128
|
}
|
|
129
129
|
} else lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);
|
|
130
|
-
}
|
|
130
|
+
}
|
|
131
131
|
return lines;
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Format a canonical log line event as a pretty tree for development output.
|
|
135
135
|
*/
|
|
136
136
|
function formatPrettyLogLine(ctx) {
|
|
137
|
-
const { event, level
|
|
137
|
+
const { event, level } = ctx;
|
|
138
138
|
const timestamp = formatTime(String(event.timestamp ?? ""));
|
|
139
139
|
const service = event["service.name"] || event.service || "";
|
|
140
140
|
const method = event["http.request.method"] || "";
|
|
@@ -374,4 +374,4 @@ Object.defineProperty(exports, 'formatDuration', {
|
|
|
374
374
|
return formatDuration;
|
|
375
375
|
}
|
|
376
376
|
});
|
|
377
|
-
//# sourceMappingURL=canonical-log-line-processor-
|
|
377
|
+
//# sourceMappingURL=canonical-log-line-processor-DOjb6Kxy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor-DOjb6Kxy.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 = '\\u001B[0m';\nconst DIM = '\\u001B[2m';\nconst BOLD = '\\u001B[1m';\nconst RED = '\\u001B[31m';\nconst YELLOW = '\\u001B[33m';\nconst GREEN = '\\u001B[32m';\nconst CYAN = '\\u001B[36m';\nconst GRAY = '\\u001B[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.at(-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 for (const [idx, [key, value]] of entries.entries()) {\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 } = 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,4BAAY,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,IAAI,QAAQ,QAAQ,OAAO,OAAO;CACpC;CACA,OAAO;AACT;AAEA,SAAS,EAAE,OAAe,MAAsB;CAC9C,OAAO,SAAS,IAAI,GAAG,QAAQ,OAAO,UAAU;AAClD;;;;;;;;;AAUA,SAAgB,eAAe,IAAoB;CACjD,IAAI,KAAK,KAAM,OAAO,GAAG,KAAK,MAAM,EAAE,EAAE;CACxC,IAAI,KAAK,KAAQ;EACf,MAAM,UAAU,KAAK;EACrB,OAAO,UAAU,KAAK,GAAG,QAAQ,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,MAAM,OAAO,EAAE;CAC1E;CACA,MAAM,UAAU,KAAK,MAAM,KAAK,GAAM;CACtC,MAAM,UAAU,KAAK,MAAO,KAAK,MAAU,GAAI;CAC/C,OAAO,UAAU,IAAI,GAAG,QAAQ,IAAI,QAAQ,KAAK,GAAG,QAAQ;AAC9D;AAEA,S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AAK,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"}
|
package/dist/{canonical-log-line-processor-FLezvFCB.js → canonical-log-line-processor-mKABvGP0.js}
RENAMED
|
@@ -104,7 +104,7 @@ function groupAttributes(event) {
|
|
|
104
104
|
if (!(part in current) || typeof current[part] !== "object") current[part] = {};
|
|
105
105
|
current = current[part];
|
|
106
106
|
}
|
|
107
|
-
current[parts
|
|
107
|
+
current[parts.at(-1)] = value;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
return tree;
|
|
@@ -112,7 +112,7 @@ function groupAttributes(event) {
|
|
|
112
112
|
function renderTree(obj, indent, isLast) {
|
|
113
113
|
const lines = [];
|
|
114
114
|
const entries = Object.entries(obj);
|
|
115
|
-
|
|
115
|
+
for (const [idx, [key, value]] of entries.entries()) {
|
|
116
116
|
const last = idx === entries.length - 1;
|
|
117
117
|
const prefix = indent + (last ? "└─" : "├─") + " ";
|
|
118
118
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -127,14 +127,14 @@ function renderTree(obj, indent, isLast) {
|
|
|
127
127
|
lines.push(...renderTree(nested, nextIndent, [...isLast, last]));
|
|
128
128
|
}
|
|
129
129
|
} else lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);
|
|
130
|
-
}
|
|
130
|
+
}
|
|
131
131
|
return lines;
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Format a canonical log line event as a pretty tree for development output.
|
|
135
135
|
*/
|
|
136
136
|
function formatPrettyLogLine(ctx) {
|
|
137
|
-
const { event, level
|
|
137
|
+
const { event, level } = ctx;
|
|
138
138
|
const timestamp = formatTime(String(event.timestamp ?? ""));
|
|
139
139
|
const service = event["service.name"] || event.service || "";
|
|
140
140
|
const method = event["http.request.method"] || "";
|
|
@@ -363,4 +363,4 @@ var CanonicalLogLineProcessor = class {
|
|
|
363
363
|
|
|
364
364
|
//#endregion
|
|
365
365
|
export { formatDuration as n, CanonicalLogLineProcessor as t };
|
|
366
|
-
//# sourceMappingURL=canonical-log-line-processor-
|
|
366
|
+
//# sourceMappingURL=canonical-log-line-processor-mKABvGP0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor-mKABvGP0.js","names":[],"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 = '\\u001B[0m';\nconst DIM = '\\u001B[2m';\nconst BOLD = '\\u001B[1m';\nconst RED = '\\u001B[31m';\nconst YELLOW = '\\u001B[33m';\nconst GREEN = '\\u001B[32m';\nconst CYAN = '\\u001B[36m';\nconst GRAY = '\\u001B[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.at(-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 for (const [idx, [key, value]] of entries.entries()) {\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 } = 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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AEA,MAAM,WAA0B,CAEhC;AACF"}
|
package/dist/config.d.cts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { t as ILogger } from "./logger-
|
|
1
|
+
import { t as ILogger } from "./logger-CN4xpzMd.cjs";
|
|
2
2
|
import { Meter, Tracer } from "@opentelemetry/api";
|
|
3
|
-
|
|
4
3
|
//#region src/config.d.ts
|
|
5
4
|
declare const FEATURE_FLAGS: {
|
|
6
|
-
/** Enable full auto-instrumentation (expensive, production only) */
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
5
|
+
/** Enable full auto-instrumentation (expensive, production only) */
|
|
6
|
+
readonly ENABLE_AUTO_INSTRUMENTATION: boolean;
|
|
7
|
+
/** Enable verbose logging (development only) */
|
|
8
|
+
readonly ENABLE_VERBOSE_LOGGING: boolean;
|
|
9
|
+
/** Enable metrics collection (production only) */
|
|
10
|
+
readonly ENABLE_METRICS_BY_DEFAULT: boolean;
|
|
11
|
+
/** Enable async resource detection (production only) */
|
|
12
|
+
readonly ENABLE_RESOURCE_DETECTION: boolean;
|
|
13
|
+
/** Enable tracing in all environments (can be disabled via autotel_TRACING=false) */
|
|
14
|
+
readonly ENABLE_TRACING: boolean;
|
|
15
|
+
/** Enable log redaction for sensitive fields (can be disabled via autotel_REDACTION=false) */
|
|
11
16
|
readonly ENABLE_REDACTION: boolean;
|
|
12
17
|
};
|
|
13
18
|
/**
|
package/dist/config.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;;cAuBa;;;;;;;;;;;;;;;;;;;;UA6BI;;;;;EAKf;;;;;EAMA;;;;;EAMA,SAAS;;;;;EAMT,QAAQ;;;;;;;;;;;;;;iBA2EM,UAAU,SAAS;;;;iBAOnB,aAAa,SAAS;EACpC,qBAAqB;;;;;iBAWP"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { t as ILogger } from "./logger-
|
|
1
|
+
import { t as ILogger } from "./logger-CN4xpzMd.js";
|
|
2
2
|
import { Meter, Tracer } from "@opentelemetry/api";
|
|
3
|
-
|
|
4
3
|
//#region src/config.d.ts
|
|
5
4
|
declare const FEATURE_FLAGS: {
|
|
6
|
-
/** Enable full auto-instrumentation (expensive, production only) */
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
5
|
+
/** Enable full auto-instrumentation (expensive, production only) */
|
|
6
|
+
readonly ENABLE_AUTO_INSTRUMENTATION: boolean;
|
|
7
|
+
/** Enable verbose logging (development only) */
|
|
8
|
+
readonly ENABLE_VERBOSE_LOGGING: boolean;
|
|
9
|
+
/** Enable metrics collection (production only) */
|
|
10
|
+
readonly ENABLE_METRICS_BY_DEFAULT: boolean;
|
|
11
|
+
/** Enable async resource detection (production only) */
|
|
12
|
+
readonly ENABLE_RESOURCE_DETECTION: boolean;
|
|
13
|
+
/** Enable tracing in all environments (can be disabled via autotel_TRACING=false) */
|
|
14
|
+
readonly ENABLE_TRACING: boolean;
|
|
15
|
+
/** Enable log redaction for sensitive fields (can be disabled via autotel_REDACTION=false) */
|
|
11
16
|
readonly ENABLE_REDACTION: boolean;
|
|
12
17
|
};
|
|
13
18
|
/**
|