autotel 3.6.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attribute-redacting-processor-DtTS9xxh.d.cts +175 -0
- package/dist/attribute-redacting-processor-DtTS9xxh.d.cts.map +1 -0
- package/dist/attribute-redacting-processor-DtTS9xxh.d.ts +175 -0
- package/dist/attribute-redacting-processor-DtTS9xxh.d.ts.map +1 -0
- package/dist/attribute-redacting-processor.cjs +374 -33
- package/dist/attribute-redacting-processor.cjs.map +1 -1
- package/dist/attribute-redacting-processor.d.cts +2 -207
- package/dist/attribute-redacting-processor.d.ts +2 -207
- package/dist/attribute-redacting-processor.js +368 -2
- package/dist/attribute-redacting-processor.js.map +1 -1
- package/dist/attributes-CmYpdqCN.js +591 -0
- package/dist/attributes-CmYpdqCN.js.map +1 -0
- package/dist/attributes-PZ5doLgw.cjs +704 -0
- package/dist/attributes-PZ5doLgw.cjs.map +1 -0
- package/dist/attributes.cjs +21 -85
- package/dist/attributes.d.cts +2 -20
- package/dist/attributes.d.ts +2 -20
- package/dist/attributes.js +3 -5
- package/dist/auto.cjs +50 -28
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.d.cts +1 -2
- package/dist/auto.d.ts +1 -2
- package/dist/auto.js +49 -23
- package/dist/auto.js.map +1 -1
- package/dist/business-baggage.cjs +357 -13
- package/dist/business-baggage.cjs.map +1 -1
- package/dist/business-baggage.d.cts +106 -139
- package/dist/business-baggage.d.cts.map +1 -0
- package/dist/business-baggage.d.ts +106 -139
- package/dist/business-baggage.d.ts.map +1 -0
- package/dist/business-baggage.js +357 -2
- package/dist/business-baggage.js.map +1 -1
- package/dist/canonical-log-line-processor--RlFDHhm.cjs +377 -0
- package/dist/canonical-log-line-processor--RlFDHhm.cjs.map +1 -0
- package/dist/canonical-log-line-processor-BcRuAdRk.d.ts +147 -0
- package/dist/canonical-log-line-processor-BcRuAdRk.d.ts.map +1 -0
- package/dist/canonical-log-line-processor-DbBQT5vY.js +366 -0
- package/dist/canonical-log-line-processor-DbBQT5vY.js.map +1 -0
- package/dist/canonical-log-line-processor-xvjMgtpF.d.cts +147 -0
- package/dist/canonical-log-line-processor-xvjMgtpF.d.cts.map +1 -0
- package/dist/config.cjs +118 -22
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +33 -45
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.ts +33 -45
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +116 -3
- package/dist/config.js.map +1 -1
- package/dist/correlated-events-Bzh5y-UB.js +28 -0
- package/dist/correlated-events-Bzh5y-UB.js.map +1 -0
- package/dist/correlated-events-kSwLo3mi.cjs +34 -0
- package/dist/correlated-events-kSwLo3mi.cjs.map +1 -0
- package/dist/correlation-id.cjs +11 -54
- package/dist/correlation-id.d.cts +6 -5
- package/dist/correlation-id.d.cts.map +1 -0
- package/dist/correlation-id.d.ts +6 -5
- package/dist/correlation-id.d.ts.map +1 -0
- package/dist/correlation-id.js +3 -17
- package/dist/db.cjs +244 -209
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +28 -26
- package/dist/db.d.cts.map +1 -0
- package/dist/db.d.ts +28 -26
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +243 -207
- package/dist/db.js.map +1 -1
- package/dist/decorators.cjs +39 -66
- package/dist/decorators.cjs.map +1 -1
- package/dist/decorators.d.cts +10 -37
- package/dist/decorators.d.cts.map +1 -0
- package/dist/decorators.d.ts +10 -37
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +38 -64
- package/dist/decorators.js.map +1 -1
- package/dist/define-event-CreknLm3.d.ts +25 -0
- package/dist/define-event-CreknLm3.d.ts.map +1 -0
- package/dist/define-event-HZRizPwz.d.cts +25 -0
- package/dist/define-event-HZRizPwz.d.cts.map +1 -0
- package/dist/drain-pipeline.cjs +111 -9
- package/dist/drain-pipeline.cjs.map +1 -1
- package/dist/drain-pipeline.d.cts +27 -32
- package/dist/drain-pipeline.d.cts.map +1 -0
- package/dist/drain-pipeline.d.ts +27 -32
- package/dist/drain-pipeline.d.ts.map +1 -0
- package/dist/drain-pipeline.js +111 -2
- package/dist/drain-pipeline.js.map +1 -1
- package/dist/enrichers.cjs +59 -66
- package/dist/enrichers.cjs.map +1 -1
- package/dist/enrichers.d.cts +15 -13
- package/dist/enrichers.d.cts.map +1 -0
- package/dist/enrichers.d.ts +15 -13
- package/dist/enrichers.d.ts.map +1 -0
- package/dist/enrichers.js +58 -65
- package/dist/enrichers.js.map +1 -1
- package/dist/event-Dlqr4ZNL.cjs +778 -0
- package/dist/event-Dlqr4ZNL.cjs.map +1 -0
- package/dist/event-_58ryBjh.js +761 -0
- package/dist/event-_58ryBjh.js.map +1 -0
- package/dist/event-subscriber-D1XLkPzi.d.cts +223 -0
- package/dist/event-subscriber-D1XLkPzi.d.cts.map +1 -0
- package/dist/event-subscriber-D1XLkPzi.d.ts +223 -0
- package/dist/event-subscriber-D1XLkPzi.d.ts.map +1 -0
- package/dist/event-subscriber.cjs +0 -6
- package/dist/event-subscriber.d.cts +2 -221
- package/dist/event-subscriber.d.ts +2 -221
- package/dist/event-subscriber.js +1 -3
- package/dist/event-testing-BqRnI0z4.d.cts +106 -0
- package/dist/event-testing-BqRnI0z4.d.cts.map +1 -0
- package/dist/event-testing-CfFs3to2.d.ts +106 -0
- package/dist/event-testing-CfFs3to2.d.ts.map +1 -0
- package/dist/event-testing.cjs +93 -17
- package/dist/event-testing.cjs.map +1 -1
- package/dist/event-testing.d.cts +2 -110
- package/dist/event-testing.d.ts +2 -110
- package/dist/event-testing.js +91 -2
- package/dist/event-testing.js.map +1 -1
- package/dist/event.cjs +5 -37
- package/dist/event.d.cts +295 -340
- package/dist/event.d.cts.map +1 -0
- package/dist/event.d.ts +295 -340
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +3 -21
- package/dist/exporters.cjs +12 -16
- package/dist/exporters.d.cts +86 -111
- package/dist/exporters.d.cts.map +1 -0
- package/dist/exporters.d.ts +86 -111
- package/dist/exporters.d.ts.map +1 -0
- package/dist/exporters.js +4 -4
- package/dist/filtering-span-processor-B8R8B7Uk.d.cts +59 -0
- package/dist/filtering-span-processor-B8R8B7Uk.d.cts.map +1 -0
- package/dist/filtering-span-processor-B8R8B7Uk.d.ts +59 -0
- package/dist/filtering-span-processor-B8R8B7Uk.d.ts.map +1 -0
- package/dist/filtering-span-processor.cjs +49 -9
- package/dist/filtering-span-processor.cjs.map +1 -1
- package/dist/filtering-span-processor.d.cts +2 -80
- package/dist/filtering-span-processor.d.ts +2 -80
- package/dist/filtering-span-processor.js +49 -2
- package/dist/filtering-span-processor.js.map +1 -1
- package/dist/functional-BGkT8J-h.js +1265 -0
- package/dist/functional-BGkT8J-h.js.map +1 -0
- package/dist/functional-C4CzoVrX.cjs +1312 -0
- package/dist/functional-C4CzoVrX.cjs.map +1 -0
- package/dist/functional.cjs +11 -57
- package/dist/functional.d.cts +96 -97
- package/dist/functional.d.cts.map +1 -0
- package/dist/functional.d.ts +96 -97
- package/dist/functional.d.ts.map +1 -0
- package/dist/functional.js +3 -20
- package/dist/http.cjs +276 -176
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +17 -37
- package/dist/http.d.cts.map +1 -0
- package/dist/http.d.ts +17 -37
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +275 -174
- package/dist/http.js.map +1 -1
- package/dist/index-Ck06vlW2.d.ts +678 -0
- package/dist/index-Ck06vlW2.d.ts.map +1 -0
- package/dist/index-eKuioqT1.d.cts +678 -0
- package/dist/index-eKuioqT1.d.cts.map +1 -0
- package/dist/index.cjs +751 -1218
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +341 -659
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +341 -659
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +606 -737
- package/dist/index.js.map +1 -1
- package/dist/init-CNp-ee80.d.cts +1157 -0
- package/dist/init-CNp-ee80.d.cts.map +1 -0
- package/dist/init-Ch6t7MNI.js +1015 -0
- package/dist/init-Ch6t7MNI.js.map +1 -0
- package/dist/init-DJQOdVlN.d.ts +1157 -0
- package/dist/init-DJQOdVlN.d.ts.map +1 -0
- package/dist/init-DvapOXCc.cjs +1092 -0
- package/dist/init-DvapOXCc.cjs.map +1 -0
- package/dist/instrumentation.cjs +159 -185
- package/dist/instrumentation.cjs.map +1 -1
- package/dist/instrumentation.d.cts +42 -40
- package/dist/instrumentation.d.cts.map +1 -0
- package/dist/instrumentation.d.ts +42 -40
- package/dist/instrumentation.d.ts.map +1 -0
- package/dist/instrumentation.js +158 -183
- package/dist/instrumentation.js.map +1 -1
- package/dist/logger-BauSUhUv.d.cts +313 -0
- package/dist/logger-BauSUhUv.d.cts.map +1 -0
- package/dist/logger-BauSUhUv.d.ts +313 -0
- package/dist/logger-BauSUhUv.d.ts.map +1 -0
- package/dist/logger.cjs +225 -25
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +2 -348
- package/dist/logger.d.ts +2 -348
- package/dist/logger.js +204 -4
- package/dist/logger.js.map +1 -1
- package/dist/messaging-adapters.cjs +292 -187
- package/dist/messaging-adapters.cjs.map +1 -1
- package/dist/messaging-adapters.d.cts +28 -66
- package/dist/messaging-adapters.d.cts.map +1 -0
- package/dist/messaging-adapters.d.ts +28 -66
- package/dist/messaging-adapters.d.ts.map +1 -0
- package/dist/messaging-adapters.js +291 -185
- package/dist/messaging-adapters.js.map +1 -1
- package/dist/messaging-testing.cjs +306 -372
- package/dist/messaging-testing.cjs.map +1 -1
- package/dist/messaging-testing.d.cts +194 -223
- package/dist/messaging-testing.d.cts.map +1 -0
- package/dist/messaging-testing.d.ts +194 -223
- package/dist/messaging-testing.d.ts.map +1 -0
- package/dist/messaging-testing.js +305 -371
- package/dist/messaging-testing.js.map +1 -1
- package/dist/messaging.cjs +757 -36
- package/dist/messaging.cjs.map +1 -1
- package/dist/messaging.d.cts +603 -644
- package/dist/messaging.d.cts.map +1 -0
- package/dist/messaging.d.ts +603 -644
- package/dist/messaging.d.ts.map +1 -0
- package/dist/messaging.js +756 -21
- package/dist/messaging.js.map +1 -1
- package/dist/metric-helpers.cjs +27 -27
- package/dist/metric-helpers.cjs.map +1 -1
- package/dist/metric-helpers.d.cts +4 -2
- package/dist/metric-helpers.d.cts.map +1 -0
- package/dist/metric-helpers.d.ts +4 -2
- package/dist/metric-helpers.d.ts.map +1 -0
- package/dist/metric-helpers.js +24 -4
- package/dist/metric-helpers.js.map +1 -1
- package/dist/metric-testing-DXdK3-Q3.d.ts +106 -0
- package/dist/metric-testing-DXdK3-Q3.d.ts.map +1 -0
- package/dist/metric-testing-MxvzChDp.d.cts +106 -0
- package/dist/metric-testing-MxvzChDp.d.cts.map +1 -0
- package/dist/metric-testing.cjs +93 -17
- package/dist/metric-testing.cjs.map +1 -1
- package/dist/metric-testing.d.cts +2 -110
- package/dist/metric-testing.d.ts +2 -110
- package/dist/metric-testing.js +91 -2
- package/dist/metric-testing.js.map +1 -1
- package/dist/metric.cjs +306 -22
- package/dist/metric.cjs.map +1 -1
- package/dist/metric.d.cts +170 -198
- package/dist/metric.d.cts.map +1 -0
- package/dist/metric.d.ts +170 -198
- package/dist/metric.d.ts.map +1 -0
- package/dist/metric.js +277 -7
- package/dist/metric.js.map +1 -1
- package/dist/node-require-DF5QBX6z.cjs +99 -0
- package/dist/node-require-DF5QBX6z.cjs.map +1 -0
- package/dist/node-require-Db1oDpLj.js +88 -0
- package/dist/node-require-Db1oDpLj.js.map +1 -0
- package/dist/operation-context-C-2hmmtP.js +59 -0
- package/dist/operation-context-C-2hmmtP.js.map +1 -0
- package/dist/operation-context-n4_obUwq.cjs +70 -0
- package/dist/operation-context-n4_obUwq.cjs.map +1 -0
- package/dist/parse-error.cjs +55 -9
- package/dist/parse-error.cjs.map +1 -1
- package/dist/parse-error.d.cts +12 -10
- package/dist/parse-error.d.cts.map +1 -0
- package/dist/parse-error.d.ts +12 -10
- package/dist/parse-error.d.ts.map +1 -0
- package/dist/parse-error.js +55 -2
- package/dist/parse-error.js.map +1 -1
- package/dist/pretty-console-exporter-CMzlrRNg.cjs +232 -0
- package/dist/pretty-console-exporter-CMzlrRNg.cjs.map +1 -0
- package/dist/pretty-console-exporter-DqKl_q9z.js +227 -0
- package/dist/pretty-console-exporter-DqKl_q9z.js.map +1 -0
- package/dist/processors.cjs +13 -17
- package/dist/processors.d.cts +3 -171
- package/dist/processors.d.ts +3 -171
- package/dist/processors.js +4 -4
- package/dist/register.cjs +35 -6
- package/dist/register.cjs.map +1 -1
- package/dist/register.d.cts +1 -2
- package/dist/register.d.ts +1 -2
- package/dist/register.js +36 -3
- package/dist/register.js.map +1 -1
- package/dist/registry-DVSmWg6Y.js +175 -0
- package/dist/registry-DVSmWg6Y.js.map +1 -0
- package/dist/registry-DYgvb62e.cjs +319 -0
- package/dist/registry-DYgvb62e.cjs.map +1 -0
- package/dist/sampling-CR0Va1VB.d.ts +351 -0
- package/dist/sampling-CR0Va1VB.d.ts.map +1 -0
- package/dist/sampling-DfYhDJij.d.cts +351 -0
- package/dist/sampling-DfYhDJij.d.cts.map +1 -0
- package/dist/sampling.cjs +452 -60
- package/dist/sampling.cjs.map +1 -1
- package/dist/sampling.d.cts +2 -379
- package/dist/sampling.d.ts +2 -379
- package/dist/sampling.js +441 -5
- package/dist/sampling.js.map +1 -1
- package/dist/security-schema.cjs +65 -46
- package/dist/security-schema.cjs.map +1 -1
- package/dist/security-schema.d.cts +23 -26
- package/dist/security-schema.d.cts.map +1 -0
- package/dist/security-schema.d.ts +23 -26
- package/dist/security-schema.d.ts.map +1 -0
- package/dist/security-schema.js +64 -45
- package/dist/security-schema.js.map +1 -1
- package/dist/semantic-conventions-FhSxv-bK.d.cts +32 -0
- package/dist/semantic-conventions-FhSxv-bK.d.cts.map +1 -0
- package/dist/semantic-conventions-FhSxv-bK.d.ts +32 -0
- package/dist/semantic-conventions-FhSxv-bK.d.ts.map +1 -0
- package/dist/semantic-conventions.cjs +15 -26
- package/dist/semantic-conventions.cjs.map +1 -1
- package/dist/semantic-conventions.d.cts +2 -29
- package/dist/semantic-conventions.d.ts +2 -29
- package/dist/semantic-conventions.js +12 -3
- package/dist/semantic-conventions.js.map +1 -1
- package/dist/semantic-helpers.cjs +327 -39
- package/dist/semantic-helpers.cjs.map +1 -1
- package/dist/semantic-helpers.d.cts +30 -150
- package/dist/semantic-helpers.d.cts.map +1 -0
- package/dist/semantic-helpers.d.ts +30 -150
- package/dist/semantic-helpers.d.ts.map +1 -0
- package/dist/semantic-helpers.js +326 -20
- package/dist/semantic-helpers.js.map +1 -1
- package/dist/span-name-normalizer-8ZOGJuwv.d.cts +70 -0
- package/dist/span-name-normalizer-8ZOGJuwv.d.cts.map +1 -0
- package/dist/span-name-normalizer-8ZOGJuwv.d.ts +70 -0
- package/dist/span-name-normalizer-8ZOGJuwv.d.ts.map +1 -0
- package/dist/span-name-normalizer.cjs +95 -17
- package/dist/span-name-normalizer.cjs.map +1 -1
- package/dist/span-name-normalizer.d.cts +2 -94
- package/dist/span-name-normalizer.d.ts +2 -94
- package/dist/span-name-normalizer.js +93 -2
- package/dist/span-name-normalizer.js.map +1 -1
- package/dist/stable-hash-BNTMrmdB.cjs +28 -0
- package/dist/stable-hash-BNTMrmdB.cjs.map +1 -0
- package/dist/stable-hash-Cg5cT34Q.js +23 -0
- package/dist/stable-hash-Cg5cT34Q.js.map +1 -0
- package/dist/structured-error-9--cxBay.js +143 -0
- package/dist/structured-error-9--cxBay.js.map +1 -0
- package/dist/structured-error-CHg7DoIQ.cjs +178 -0
- package/dist/structured-error-CHg7DoIQ.cjs.map +1 -0
- package/dist/tail-sampling-processor.cjs +26 -13
- package/dist/tail-sampling-processor.cjs.map +1 -1
- package/dist/tail-sampling-processor.d.cts +11 -23
- package/dist/tail-sampling-processor.d.cts.map +1 -0
- package/dist/tail-sampling-processor.d.ts +11 -23
- package/dist/tail-sampling-processor.d.ts.map +1 -0
- package/dist/tail-sampling-processor.js +27 -6
- package/dist/tail-sampling-processor.js.map +1 -1
- package/dist/test-span-collector.cjs +70 -72
- package/dist/test-span-collector.cjs.map +1 -1
- package/dist/test-span-collector.d.cts +25 -43
- package/dist/test-span-collector.d.cts.map +1 -0
- package/dist/test-span-collector.d.ts +25 -43
- package/dist/test-span-collector.d.ts.map +1 -0
- package/dist/test-span-collector.js +69 -70
- package/dist/test-span-collector.js.map +1 -1
- package/dist/testing.cjs +389 -278
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +39 -62
- package/dist/testing.d.cts.map +1 -0
- package/dist/testing.d.ts +39 -62
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +386 -265
- package/dist/testing.js.map +1 -1
- package/dist/trace-context-Cijqoi6e.d.cts +212 -0
- package/dist/trace-context-Cijqoi6e.d.cts.map +1 -0
- package/dist/trace-context-Cijqoi6e.d.ts +212 -0
- package/dist/trace-context-Cijqoi6e.d.ts.map +1 -0
- package/dist/trace-helpers.cjs +634 -54
- package/dist/trace-helpers.cjs.map +1 -1
- package/dist/trace-helpers.d.cts +17 -49
- package/dist/trace-helpers.d.cts.map +1 -0
- package/dist/trace-helpers.d.ts +17 -49
- package/dist/trace-helpers.d.ts.map +1 -0
- package/dist/trace-helpers.js +624 -3
- package/dist/trace-helpers.js.map +1 -1
- package/dist/tracer-provider.cjs +227 -16
- package/dist/tracer-provider.cjs.map +1 -1
- package/dist/tracer-provider.d.cts +5 -4
- package/dist/tracer-provider.d.cts.map +1 -0
- package/dist/tracer-provider.d.ts +5 -4
- package/dist/tracer-provider.d.ts.map +1 -0
- package/dist/tracer-provider.js +227 -2
- package/dist/tracer-provider.js.map +1 -1
- package/dist/track-3HY4NGV-.cjs +1212 -0
- package/dist/track-3HY4NGV-.cjs.map +1 -0
- package/dist/track-nsKVy-pj.js +1111 -0
- package/dist/track-nsKVy-pj.js.map +1 -0
- package/dist/validate.cjs +178 -115
- package/dist/validate.cjs.map +1 -1
- package/dist/validate.d.cts +40 -64
- package/dist/validate.d.cts.map +1 -0
- package/dist/validate.d.ts +40 -64
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +177 -113
- package/dist/validate.js.map +1 -1
- package/dist/validation-attributes.cjs +42 -17
- package/dist/validation-attributes.cjs.map +1 -1
- package/dist/validation-attributes.d.cts +13 -20
- package/dist/validation-attributes.d.cts.map +1 -0
- package/dist/validation-attributes.d.ts +13 -20
- package/dist/validation-attributes.d.ts.map +1 -0
- package/dist/validation-attributes.js +40 -2
- package/dist/validation-attributes.js.map +1 -1
- package/dist/webhook.cjs +286 -256
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +157 -192
- package/dist/webhook.d.cts.map +1 -0
- package/dist/webhook.d.ts +157 -192
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +285 -254
- package/dist/webhook.js.map +1 -1
- package/dist/workflow-distributed.cjs +498 -412
- package/dist/workflow-distributed.cjs.map +1 -1
- package/dist/workflow-distributed.d.cts +163 -173
- package/dist/workflow-distributed.d.cts.map +1 -0
- package/dist/workflow-distributed.d.ts +163 -173
- package/dist/workflow-distributed.d.ts.map +1 -0
- package/dist/workflow-distributed.js +497 -410
- package/dist/workflow-distributed.js.map +1 -1
- package/dist/workflow.cjs +405 -40
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +78 -131
- package/dist/workflow.d.cts.map +1 -0
- package/dist/workflow.d.ts +78 -131
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +403 -21
- package/dist/workflow.js.map +1 -1
- package/dist/yaml-config-B3dQ82GR.cjs +272 -0
- package/dist/yaml-config-B3dQ82GR.cjs.map +1 -0
- package/dist/yaml-config.cjs +5 -24
- package/dist/yaml-config.d.cts +30 -64
- package/dist/yaml-config.d.cts.map +1 -0
- package/dist/yaml-config.d.ts +30 -64
- package/dist/yaml-config.d.ts.map +1 -0
- package/dist/yaml-config.js +226 -7
- package/dist/yaml-config.js.map +1 -1
- package/package.json +4 -4
- package/skills/analyze-traces/SKILL.md +14 -12
- package/skills/review-otel-patterns/SKILL.md +4 -2
- package/skills/tune-sampling/SKILL.md +8 -3
- package/src/attributes/builders.ts +2 -20
- package/src/attributes/index.ts +0 -1
- package/src/attributes/registry.ts +2 -9
- package/src/attributes/types.ts +0 -8
- package/src/index.ts +7 -41
- package/src/request-logger.test.ts +53 -1
- package/src/request-logger.ts +58 -0
- package/src/semantic-helpers.test.ts +2 -87
- package/src/semantic-helpers.ts +0 -146
- package/src/validate.test.ts +3 -1
- package/src/validate.ts +9 -3
- package/dist/attributes.cjs.map +0 -1
- package/dist/attributes.js.map +0 -1
- package/dist/chunk-2ZKEORFN.cjs +0 -14
- package/dist/chunk-2ZKEORFN.cjs.map +0 -1
- package/dist/chunk-3QXBFGKP.js +0 -344
- package/dist/chunk-3QXBFGKP.js.map +0 -1
- package/dist/chunk-454CH4OV.js +0 -744
- package/dist/chunk-454CH4OV.js.map +0 -1
- package/dist/chunk-4A53YIAX.js +0 -180
- package/dist/chunk-4A53YIAX.js.map +0 -1
- package/dist/chunk-4IFSYQVX.js +0 -337
- package/dist/chunk-4IFSYQVX.js.map +0 -1
- package/dist/chunk-4P6ZOARG.cjs +0 -33
- package/dist/chunk-4P6ZOARG.cjs.map +0 -1
- package/dist/chunk-55ER2KD5.js +0 -228
- package/dist/chunk-55ER2KD5.js.map +0 -1
- package/dist/chunk-5ZN622AO.js +0 -73
- package/dist/chunk-5ZN622AO.js.map +0 -1
- package/dist/chunk-66YJ66GG.js +0 -1021
- package/dist/chunk-66YJ66GG.js.map +0 -1
- package/dist/chunk-6S5RUKU3.cjs +0 -347
- package/dist/chunk-6S5RUKU3.cjs.map +0 -1
- package/dist/chunk-6UQRVUN3.js +0 -222
- package/dist/chunk-6UQRVUN3.js.map +0 -1
- package/dist/chunk-7552UTQW.js +0 -11
- package/dist/chunk-7552UTQW.js.map +0 -1
- package/dist/chunk-7EQ4G4SI.cjs +0 -146
- package/dist/chunk-7EQ4G4SI.cjs.map +0 -1
- package/dist/chunk-7SAWIN74.js +0 -285
- package/dist/chunk-7SAWIN74.js.map +0 -1
- package/dist/chunk-A4E5AQFK.js +0 -30
- package/dist/chunk-A4E5AQFK.js.map +0 -1
- package/dist/chunk-ALPYR2GC.js +0 -1061
- package/dist/chunk-ALPYR2GC.js.map +0 -1
- package/dist/chunk-B7SWBE4P.cjs +0 -799
- package/dist/chunk-B7SWBE4P.cjs.map +0 -1
- package/dist/chunk-BZHG5IZ4.js +0 -73
- package/dist/chunk-BZHG5IZ4.js.map +0 -1
- package/dist/chunk-CEAQK2QY.cjs +0 -32
- package/dist/chunk-CEAQK2QY.cjs.map +0 -1
- package/dist/chunk-CMHVQR6P.js +0 -170
- package/dist/chunk-CMHVQR6P.js.map +0 -1
- package/dist/chunk-CU6IDACR.cjs +0 -224
- package/dist/chunk-CU6IDACR.cjs.map +0 -1
- package/dist/chunk-D4TM63S3.js +0 -795
- package/dist/chunk-D4TM63S3.js.map +0 -1
- package/dist/chunk-DCEDJQGG.js +0 -28
- package/dist/chunk-DCEDJQGG.js.map +0 -1
- package/dist/chunk-DPSA4QLA.js +0 -344
- package/dist/chunk-DPSA4QLA.js.map +0 -1
- package/dist/chunk-E6TERL5O.cjs +0 -23
- package/dist/chunk-E6TERL5O.cjs.map +0 -1
- package/dist/chunk-EE6CPXKH.cjs +0 -164
- package/dist/chunk-EE6CPXKH.cjs.map +0 -1
- package/dist/chunk-EOFB7XCL.cjs +0 -837
- package/dist/chunk-EOFB7XCL.cjs.map +0 -1
- package/dist/chunk-ESLWRGAG.cjs +0 -92
- package/dist/chunk-ESLWRGAG.cjs.map +0 -1
- package/dist/chunk-ESMHTKLJ.cjs +0 -206
- package/dist/chunk-ESMHTKLJ.cjs.map +0 -1
- package/dist/chunk-FMTHVSYY.cjs +0 -1039
- package/dist/chunk-FMTHVSYY.cjs.map +0 -1
- package/dist/chunk-FU6R566Y.cjs +0 -236
- package/dist/chunk-FU6R566Y.cjs.map +0 -1
- package/dist/chunk-GYR5K654.js +0 -91
- package/dist/chunk-GYR5K654.js.map +0 -1
- package/dist/chunk-HA2WBOGQ.js +0 -57
- package/dist/chunk-HA2WBOGQ.js.map +0 -1
- package/dist/chunk-HT5JQKN2.js +0 -118
- package/dist/chunk-HT5JQKN2.js.map +0 -1
- package/dist/chunk-INJD3G4K.cjs +0 -340
- package/dist/chunk-INJD3G4K.cjs.map +0 -1
- package/dist/chunk-IOYFAFHJ.cjs +0 -95
- package/dist/chunk-IOYFAFHJ.cjs.map +0 -1
- package/dist/chunk-J5QENANM.js +0 -87
- package/dist/chunk-J5QENANM.js.map +0 -1
- package/dist/chunk-J7VGRIAJ.js +0 -64
- package/dist/chunk-J7VGRIAJ.js.map +0 -1
- package/dist/chunk-KFOHQK7X.js +0 -144
- package/dist/chunk-KFOHQK7X.js.map +0 -1
- package/dist/chunk-KIL5CUN6.js +0 -31
- package/dist/chunk-KIL5CUN6.js.map +0 -1
- package/dist/chunk-KYXZS3EA.cjs +0 -100
- package/dist/chunk-KYXZS3EA.cjs.map +0 -1
- package/dist/chunk-LITNXTTT.js +0 -3
- package/dist/chunk-LITNXTTT.js.map +0 -1
- package/dist/chunk-LVIPBYFE.js +0 -157
- package/dist/chunk-LVIPBYFE.js.map +0 -1
- package/dist/chunk-M3LFHHTN.cjs +0 -764
- package/dist/chunk-M3LFHHTN.cjs.map +0 -1
- package/dist/chunk-N25JDZSC.js +0 -95
- package/dist/chunk-N25JDZSC.js.map +0 -1
- package/dist/chunk-NEIB3TLD.cjs +0 -360
- package/dist/chunk-NEIB3TLD.cjs.map +0 -1
- package/dist/chunk-NENU7E6V.cjs +0 -344
- package/dist/chunk-NENU7E6V.cjs.map +0 -1
- package/dist/chunk-NVAI5CCN.cjs +0 -39
- package/dist/chunk-NVAI5CCN.cjs.map +0 -1
- package/dist/chunk-NZ72VDNY.cjs +0 -4
- package/dist/chunk-NZ72VDNY.cjs.map +0 -1
- package/dist/chunk-OPPXYVEZ.cjs +0 -131
- package/dist/chunk-OPPXYVEZ.cjs.map +0 -1
- package/dist/chunk-Q4EULJQY.js +0 -35
- package/dist/chunk-Q4EULJQY.js.map +0 -1
- package/dist/chunk-QF7ARNUM.js +0 -339
- package/dist/chunk-QF7ARNUM.js.map +0 -1
- package/dist/chunk-QWW3E3JM.cjs +0 -178
- package/dist/chunk-QWW3E3JM.cjs.map +0 -1
- package/dist/chunk-R7QYGZUP.cjs +0 -1075
- package/dist/chunk-R7QYGZUP.cjs.map +0 -1
- package/dist/chunk-RUPKBKUF.js +0 -352
- package/dist/chunk-RUPKBKUF.js.map +0 -1
- package/dist/chunk-SEO6NAQT.js +0 -14
- package/dist/chunk-SEO6NAQT.js.map +0 -1
- package/dist/chunk-T4B5LB6E.cjs +0 -66
- package/dist/chunk-T4B5LB6E.cjs.map +0 -1
- package/dist/chunk-T5WRA76K.cjs +0 -32
- package/dist/chunk-T5WRA76K.cjs.map +0 -1
- package/dist/chunk-T7JO2TCP.js +0 -1233
- package/dist/chunk-T7JO2TCP.js.map +0 -1
- package/dist/chunk-TC5ZPWM4.cjs +0 -289
- package/dist/chunk-TC5ZPWM4.cjs.map +0 -1
- package/dist/chunk-TQ5UWA7S.js +0 -26
- package/dist/chunk-TQ5UWA7S.js.map +0 -1
- package/dist/chunk-UIKYE2QZ.js +0 -833
- package/dist/chunk-UIKYE2QZ.js.map +0 -1
- package/dist/chunk-UNPLAVE7.js +0 -21
- package/dist/chunk-UNPLAVE7.js.map +0 -1
- package/dist/chunk-UY3UYPBZ.cjs +0 -77
- package/dist/chunk-UY3UYPBZ.cjs.map +0 -1
- package/dist/chunk-V7UBMJAB.cjs +0 -1242
- package/dist/chunk-V7UBMJAB.cjs.map +0 -1
- package/dist/chunk-VH77IPJN.cjs +0 -358
- package/dist/chunk-VH77IPJN.cjs.map +0 -1
- package/dist/chunk-VQTCQKHQ.cjs +0 -17
- package/dist/chunk-VQTCQKHQ.cjs.map +0 -1
- package/dist/chunk-WGWSHJ2N.js +0 -38
- package/dist/chunk-WGWSHJ2N.js.map +0 -1
- package/dist/chunk-WJH6IYU2.cjs +0 -32
- package/dist/chunk-WJH6IYU2.cjs.map +0 -1
- package/dist/chunk-YREV3LGG.cjs +0 -61
- package/dist/chunk-YREV3LGG.cjs.map +0 -1
- package/dist/chunk-YTXEZ4SD.cjs +0 -77
- package/dist/chunk-YTXEZ4SD.cjs.map +0 -1
- package/dist/chunk-ZNMBW67B.cjs +0 -40
- package/dist/chunk-ZNMBW67B.cjs.map +0 -1
- package/dist/correlation-id.cjs.map +0 -1
- package/dist/correlation-id.js.map +0 -1
- package/dist/define-event-BL6Li7CM.d.ts +0 -23
- package/dist/define-event-ClP3T1Jx.d.cts +0 -23
- package/dist/event-subscriber.cjs.map +0 -1
- package/dist/event-subscriber.js.map +0 -1
- package/dist/event.cjs.map +0 -1
- package/dist/event.js.map +0 -1
- package/dist/exporters.cjs.map +0 -1
- package/dist/exporters.js.map +0 -1
- package/dist/functional.cjs.map +0 -1
- package/dist/functional.js.map +0 -1
- package/dist/init-DIowiiCh.d.ts +0 -1167
- package/dist/init-j-A1zI16.d.cts +0 -1167
- package/dist/processors.cjs.map +0 -1
- package/dist/processors.js.map +0 -1
- package/dist/trace-context-DbGKd1Rn.d.cts +0 -213
- package/dist/trace-context-DbGKd1Rn.d.ts +0 -213
- package/dist/utils-BahBCFtJ.d.cts +0 -712
- package/dist/utils-CLKwaUlG.d.ts +0 -712
- package/dist/yaml-config.cjs.map +0 -1
- package/src/gen-ai-cost.test.ts +0 -81
- package/src/gen-ai-cost.ts +0 -145
- package/src/gen-ai-events.test.ts +0 -135
- package/src/gen-ai-events.ts +0 -208
- package/src/gen-ai-metrics.test.ts +0 -96
- package/src/gen-ai-metrics.ts +0 -128
package/src/gen-ai-cost.test.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
estimateLLMCost,
|
|
4
|
-
recordLLMCost,
|
|
5
|
-
GEN_AI_COST_ATTRIBUTE,
|
|
6
|
-
} from './gen-ai-cost';
|
|
7
|
-
|
|
8
|
-
describe('estimateLLMCost', () => {
|
|
9
|
-
it('estimates cost from input and output tokens', () => {
|
|
10
|
-
// claude-sonnet-4: $3 / 1M in, $15 / 1M out
|
|
11
|
-
const cost = estimateLLMCost('claude-sonnet-4', {
|
|
12
|
-
inputTokens: 1_000_000,
|
|
13
|
-
outputTokens: 1_000_000,
|
|
14
|
-
});
|
|
15
|
-
expect(cost).toBe(18);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('matches versioned model ids by longest prefix', () => {
|
|
19
|
-
const cost = estimateLLMCost('claude-sonnet-4-6-20251101', {
|
|
20
|
-
inputTokens: 1_000_000,
|
|
21
|
-
outputTokens: 0,
|
|
22
|
-
});
|
|
23
|
-
expect(cost).toBe(3);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('returns undefined for an unknown model', () => {
|
|
27
|
-
expect(
|
|
28
|
-
estimateLLMCost('totally-made-up', { inputTokens: 1000 }),
|
|
29
|
-
).toBeUndefined();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('bills cached input tokens at the cached rate', () => {
|
|
33
|
-
const pricing = {
|
|
34
|
-
custom: { inputPer1M: 10, outputPer1M: 30, cachedInputPer1M: 1 },
|
|
35
|
-
};
|
|
36
|
-
// 1M input, of which 800k cached: 200k @ $10/M + 800k @ $1/M = 2 + 0.8
|
|
37
|
-
const cost = estimateLLMCost(
|
|
38
|
-
'custom',
|
|
39
|
-
{ inputTokens: 1_000_000, cachedInputTokens: 800_000 },
|
|
40
|
-
{ pricing },
|
|
41
|
-
);
|
|
42
|
-
expect(cost).toBeCloseTo(2.8, 6);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('accepts a pricing override and extends the table', () => {
|
|
46
|
-
const cost = estimateLLMCost(
|
|
47
|
-
'my-model',
|
|
48
|
-
{ inputTokens: 500_000, outputTokens: 500_000 },
|
|
49
|
-
{ pricing: { 'my-model': { inputPer1M: 4, outputPer1M: 8 } } },
|
|
50
|
-
);
|
|
51
|
-
expect(cost).toBe(6);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('handles partial usage without throwing', () => {
|
|
55
|
-
expect(estimateLLMCost('gpt-4o-mini', {})).toBe(0);
|
|
56
|
-
expect(estimateLLMCost('gpt-4o-mini', { outputTokens: 1_000_000 })).toBe(
|
|
57
|
-
0.6,
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('recordLLMCost', () => {
|
|
63
|
-
it('sets the cost attribute on the context for a known model', () => {
|
|
64
|
-
const setAttribute = vi.fn();
|
|
65
|
-
const cost = recordLLMCost({ setAttribute }, 'gpt-4o', {
|
|
66
|
-
inputTokens: 1_000_000,
|
|
67
|
-
outputTokens: 0,
|
|
68
|
-
});
|
|
69
|
-
expect(cost).toBe(2.5);
|
|
70
|
-
expect(setAttribute).toHaveBeenCalledWith(GEN_AI_COST_ATTRIBUTE, 2.5);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('sets no attribute for an unknown model', () => {
|
|
74
|
-
const setAttribute = vi.fn();
|
|
75
|
-
const cost = recordLLMCost({ setAttribute }, 'unknown-model', {
|
|
76
|
-
inputTokens: 100,
|
|
77
|
-
});
|
|
78
|
-
expect(cost).toBeUndefined();
|
|
79
|
-
expect(setAttribute).not.toHaveBeenCalled();
|
|
80
|
-
});
|
|
81
|
-
});
|
package/src/gen-ai-cost.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-model LLM cost estimation.
|
|
3
|
-
*
|
|
4
|
-
* Estimate the USD cost of an LLM call from its token usage and record it as a
|
|
5
|
-
* span attribute (`gen_ai.usage.cost.usd`). Pair with the
|
|
6
|
-
* `gen_ai.client.cost.usd` metric bucket advice in `gen-ai-metrics`.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { trace, recordLLMCost } from 'autotel';
|
|
11
|
-
*
|
|
12
|
-
* export const chat = trace((ctx) => async (prompt: string) => {
|
|
13
|
-
* const res = await client.messages.create({ model, ... });
|
|
14
|
-
* recordLLMCost(ctx, model, {
|
|
15
|
-
* inputTokens: res.usage.input_tokens,
|
|
16
|
-
* outputTokens: res.usage.output_tokens,
|
|
17
|
-
* });
|
|
18
|
-
* return res;
|
|
19
|
-
* });
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import type { TraceContext } from './trace-context';
|
|
24
|
-
|
|
25
|
-
/** Span attribute key autotel sets for an estimated call cost. */
|
|
26
|
-
export const GEN_AI_COST_ATTRIBUTE = 'gen_ai.usage.cost.usd';
|
|
27
|
-
|
|
28
|
-
/** Pricing for a single model, in USD per 1,000,000 tokens. */
|
|
29
|
-
export interface ModelPricing {
|
|
30
|
-
/** USD per 1M input (prompt) tokens. */
|
|
31
|
-
inputPer1M: number;
|
|
32
|
-
/** USD per 1M output (completion) tokens. */
|
|
33
|
-
outputPer1M: number;
|
|
34
|
-
/** USD per 1M cached input tokens. Defaults to {@link ModelPricing.inputPer1M}. */
|
|
35
|
-
cachedInputPer1M?: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Token counts for a single LLM call. */
|
|
39
|
-
export interface TokenUsage {
|
|
40
|
-
inputTokens?: number;
|
|
41
|
-
outputTokens?: number;
|
|
42
|
-
/** Cached input tokens, billed at {@link ModelPricing.cachedInputPer1M}. */
|
|
43
|
-
cachedInputTokens?: number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface EstimateCostOptions {
|
|
47
|
-
/** Override or extend {@link MODEL_PRICING}. Keys are matched first. */
|
|
48
|
-
pricing?: Record<string, ModelPricing>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Approximate public list prices (USD per 1M tokens) at the time of writing.
|
|
53
|
-
* Prices change; treat these as convenience defaults, not a billing source of
|
|
54
|
-
* truth. Override per call via `options.pricing` or mutate this table at init.
|
|
55
|
-
* Matching is exact first, then by longest key prefix, so versioned model ids
|
|
56
|
-
* (`claude-sonnet-4-6-20251101`) resolve to a base entry (`claude-sonnet-4-6`).
|
|
57
|
-
*/
|
|
58
|
-
export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
59
|
-
// OpenAI
|
|
60
|
-
'gpt-4o': { inputPer1M: 2.5, outputPer1M: 10 },
|
|
61
|
-
'gpt-4o-mini': { inputPer1M: 0.15, outputPer1M: 0.6 },
|
|
62
|
-
'gpt-4.1': { inputPer1M: 2, outputPer1M: 8 },
|
|
63
|
-
'gpt-4.1-mini': { inputPer1M: 0.4, outputPer1M: 1.6 },
|
|
64
|
-
'gpt-4.1-nano': { inputPer1M: 0.1, outputPer1M: 0.4 },
|
|
65
|
-
'o3-mini': { inputPer1M: 1.1, outputPer1M: 4.4 },
|
|
66
|
-
// Anthropic Claude
|
|
67
|
-
'claude-opus-4': { inputPer1M: 15, outputPer1M: 75 },
|
|
68
|
-
'claude-sonnet-4': { inputPer1M: 3, outputPer1M: 15 },
|
|
69
|
-
'claude-3-5-sonnet': { inputPer1M: 3, outputPer1M: 15 },
|
|
70
|
-
'claude-3-5-haiku': { inputPer1M: 0.8, outputPer1M: 4 },
|
|
71
|
-
'claude-3-opus': { inputPer1M: 15, outputPer1M: 75 },
|
|
72
|
-
'claude-3-haiku': { inputPer1M: 0.25, outputPer1M: 1.25 },
|
|
73
|
-
// Google Gemini
|
|
74
|
-
'gemini-1.5-pro': { inputPer1M: 1.25, outputPer1M: 5 },
|
|
75
|
-
'gemini-1.5-flash': { inputPer1M: 0.075, outputPer1M: 0.3 },
|
|
76
|
-
'gemini-2.0-flash': { inputPer1M: 0.1, outputPer1M: 0.4 },
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
function resolvePricing(
|
|
80
|
-
table: Record<string, ModelPricing>,
|
|
81
|
-
model: string,
|
|
82
|
-
): ModelPricing | undefined {
|
|
83
|
-
const exact = table[model];
|
|
84
|
-
if (exact) return exact;
|
|
85
|
-
|
|
86
|
-
let best: ModelPricing | undefined;
|
|
87
|
-
let bestLength = 0;
|
|
88
|
-
for (const key of Object.keys(table)) {
|
|
89
|
-
if (model.startsWith(key) && key.length > bestLength) {
|
|
90
|
-
best = table[key];
|
|
91
|
-
bestLength = key.length;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return best;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function round(value: number): number {
|
|
98
|
-
return Math.round(value * 1e6) / 1e6;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Estimate the USD cost of an LLM call. Returns `undefined` when the model has
|
|
103
|
-
* no known pricing (supply one via `options.pricing`).
|
|
104
|
-
*/
|
|
105
|
-
export function estimateLLMCost(
|
|
106
|
-
model: string,
|
|
107
|
-
usage: TokenUsage,
|
|
108
|
-
options?: EstimateCostOptions,
|
|
109
|
-
): number | undefined {
|
|
110
|
-
const table = options?.pricing
|
|
111
|
-
? { ...MODEL_PRICING, ...options.pricing }
|
|
112
|
-
: MODEL_PRICING;
|
|
113
|
-
const price = resolvePricing(table, model);
|
|
114
|
-
if (!price) return undefined;
|
|
115
|
-
|
|
116
|
-
const cachedInput = usage.cachedInputTokens ?? 0;
|
|
117
|
-
const billedInput = Math.max(0, (usage.inputTokens ?? 0) - cachedInput);
|
|
118
|
-
const output = usage.outputTokens ?? 0;
|
|
119
|
-
const cachedRate = price.cachedInputPer1M ?? price.inputPer1M;
|
|
120
|
-
|
|
121
|
-
const cost =
|
|
122
|
-
(billedInput / 1_000_000) * price.inputPer1M +
|
|
123
|
-
(cachedInput / 1_000_000) * cachedRate +
|
|
124
|
-
(output / 1_000_000) * price.outputPer1M;
|
|
125
|
-
|
|
126
|
-
return round(cost);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Estimate cost and record it on `ctx` as the `gen_ai.usage.cost.usd` span
|
|
131
|
-
* attribute. Returns the estimated cost, or `undefined` when the model is
|
|
132
|
-
* unknown (in which case no attribute is set).
|
|
133
|
-
*/
|
|
134
|
-
export function recordLLMCost(
|
|
135
|
-
ctx: Pick<TraceContext, 'setAttribute'>,
|
|
136
|
-
model: string,
|
|
137
|
-
usage: TokenUsage,
|
|
138
|
-
options?: EstimateCostOptions,
|
|
139
|
-
): number | undefined {
|
|
140
|
-
const cost = estimateLLMCost(model, usage, options);
|
|
141
|
-
if (cost !== undefined) {
|
|
142
|
-
ctx.setAttribute(GEN_AI_COST_ATTRIBUTE, cost);
|
|
143
|
-
}
|
|
144
|
-
return cost;
|
|
145
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { TraceContext } from './trace-context';
|
|
3
|
-
import {
|
|
4
|
-
recordPromptSent,
|
|
5
|
-
recordResponseReceived,
|
|
6
|
-
recordRetry,
|
|
7
|
-
recordStreamFirstToken,
|
|
8
|
-
recordToolCall,
|
|
9
|
-
} from './gen-ai-events';
|
|
10
|
-
|
|
11
|
-
type CapturedEvent = { name: string; attrs?: Record<string, unknown> };
|
|
12
|
-
|
|
13
|
-
function captureCtx(): {
|
|
14
|
-
ctx: TraceContext;
|
|
15
|
-
events: CapturedEvent[];
|
|
16
|
-
} {
|
|
17
|
-
const events: CapturedEvent[] = [];
|
|
18
|
-
const ctx = {
|
|
19
|
-
addEvent: (name: string, attrs?: Record<string, unknown>) => {
|
|
20
|
-
events.push({ name, attrs });
|
|
21
|
-
},
|
|
22
|
-
setAttribute: () => {},
|
|
23
|
-
setAttributes: () => {},
|
|
24
|
-
setStatus: () => {},
|
|
25
|
-
recordException: () => {},
|
|
26
|
-
addLink: () => {},
|
|
27
|
-
addLinks: () => {},
|
|
28
|
-
updateName: () => {},
|
|
29
|
-
isRecording: () => true,
|
|
30
|
-
end: () => {},
|
|
31
|
-
} as unknown as TraceContext;
|
|
32
|
-
return { ctx, events };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
describe('GenAI span event helpers', () => {
|
|
36
|
-
it('recordPromptSent emits gen_ai.prompt.sent with canonical attrs', () => {
|
|
37
|
-
const { ctx, events } = captureCtx();
|
|
38
|
-
recordPromptSent(ctx, {
|
|
39
|
-
model: 'gpt-4o',
|
|
40
|
-
promptTokens: 1200,
|
|
41
|
-
messageCount: 3,
|
|
42
|
-
operation: 'chat',
|
|
43
|
-
});
|
|
44
|
-
expect(events).toHaveLength(1);
|
|
45
|
-
expect(events[0]).toEqual({
|
|
46
|
-
name: 'gen_ai.prompt.sent',
|
|
47
|
-
attrs: {
|
|
48
|
-
'gen_ai.request.model': 'gpt-4o',
|
|
49
|
-
'gen_ai.usage.input_tokens': 1200,
|
|
50
|
-
'gen_ai.request.message_count': 3,
|
|
51
|
-
'gen_ai.operation.name': 'chat',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('recordPromptSent omits unset fields rather than writing undefined', () => {
|
|
57
|
-
const { ctx, events } = captureCtx();
|
|
58
|
-
recordPromptSent(ctx);
|
|
59
|
-
expect(events[0]?.attrs).toEqual({});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('recordResponseReceived joins finish reasons into a CSV for attribute compat', () => {
|
|
63
|
-
const { ctx, events } = captureCtx();
|
|
64
|
-
recordResponseReceived(ctx, {
|
|
65
|
-
model: 'gpt-4o-2024-11-20',
|
|
66
|
-
promptTokens: 1200,
|
|
67
|
-
completionTokens: 400,
|
|
68
|
-
totalTokens: 1600,
|
|
69
|
-
finishReasons: ['stop', 'tool_calls'],
|
|
70
|
-
});
|
|
71
|
-
expect(events[0]).toEqual({
|
|
72
|
-
name: 'gen_ai.response.received',
|
|
73
|
-
attrs: {
|
|
74
|
-
'gen_ai.response.model': 'gpt-4o-2024-11-20',
|
|
75
|
-
'gen_ai.usage.input_tokens': 1200,
|
|
76
|
-
'gen_ai.usage.output_tokens': 400,
|
|
77
|
-
'gen_ai.usage.total_tokens': 1600,
|
|
78
|
-
'gen_ai.response.finish_reasons': 'stop,tool_calls',
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('recordResponseReceived omits finish_reasons when empty', () => {
|
|
84
|
-
const { ctx, events } = captureCtx();
|
|
85
|
-
recordResponseReceived(ctx, { model: 'claude-sonnet-4-6' });
|
|
86
|
-
expect(events[0]?.attrs).not.toHaveProperty(
|
|
87
|
-
'gen_ai.response.finish_reasons',
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('recordRetry captures attempt, reason, delay, and status code', () => {
|
|
92
|
-
const { ctx, events } = captureCtx();
|
|
93
|
-
recordRetry(ctx, {
|
|
94
|
-
attempt: 2,
|
|
95
|
-
reason: 'rate_limit',
|
|
96
|
-
delayMs: 1000,
|
|
97
|
-
statusCode: 429,
|
|
98
|
-
});
|
|
99
|
-
expect(events[0]).toEqual({
|
|
100
|
-
name: 'gen_ai.retry',
|
|
101
|
-
attrs: {
|
|
102
|
-
'retry.attempt': 2,
|
|
103
|
-
'retry.reason': 'rate_limit',
|
|
104
|
-
'retry.delay_ms': 1000,
|
|
105
|
-
'http.response.status_code': 429,
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('recordToolCall writes canonical gen_ai.tool.* keys', () => {
|
|
111
|
-
const { ctx, events } = captureCtx();
|
|
112
|
-
recordToolCall(ctx, {
|
|
113
|
-
toolName: 'search_traces',
|
|
114
|
-
toolCallId: 'call-123',
|
|
115
|
-
arguments: '{"serviceName":"api"}',
|
|
116
|
-
});
|
|
117
|
-
expect(events[0]).toEqual({
|
|
118
|
-
name: 'gen_ai.tool.call',
|
|
119
|
-
attrs: {
|
|
120
|
-
'gen_ai.tool.name': 'search_traces',
|
|
121
|
-
'gen_ai.tool.call.id': 'call-123',
|
|
122
|
-
'gen_ai.tool.arguments': '{"serviceName":"api"}',
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('recordStreamFirstToken is the bare marker for TTFT', () => {
|
|
128
|
-
const { ctx, events } = captureCtx();
|
|
129
|
-
recordStreamFirstToken(ctx, { tokensSoFar: 1 });
|
|
130
|
-
expect(events[0]).toEqual({
|
|
131
|
-
name: 'gen_ai.stream.first_token',
|
|
132
|
-
attrs: { 'gen_ai.stream.tokens_so_far': 1 },
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
package/src/gen-ai-events.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Span event helpers for LLM lifecycle, aligned with the OpenTelemetry
|
|
3
|
-
* GenAI semantic conventions.
|
|
4
|
-
*
|
|
5
|
-
* Span events are timestamped points within a span — they render as dots
|
|
6
|
-
* on the trace timeline in Jaeger / Tempo / Langfuse / Arize. Use them
|
|
7
|
-
* to mark lifecycle moments the span attributes alone can't express:
|
|
8
|
-
*
|
|
9
|
-
* - When the prompt was sent (vs. when the first token arrived)
|
|
10
|
-
* - When each retry attempt started, and why
|
|
11
|
-
* - When a streaming response produced its first token (TTFT)
|
|
12
|
-
* - When a tool was invoked
|
|
13
|
-
*
|
|
14
|
-
* Every helper pins the event name + attribute keys to the published
|
|
15
|
-
* spec so downstream tooling (autotel-mcp, Langfuse, vendor UIs) can
|
|
16
|
-
* render them consistently.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* import { trace, recordPromptSent, recordResponseReceived, recordRetry } from 'autotel';
|
|
21
|
-
*
|
|
22
|
-
* export const chat = trace('chat', ctx => async (prompt: string) => {
|
|
23
|
-
* recordPromptSent(ctx, { model: 'gpt-4o', messageCount: 1 });
|
|
24
|
-
*
|
|
25
|
-
* for (let attempt = 1; attempt <= 3; attempt++) {
|
|
26
|
-
* try {
|
|
27
|
-
* const res = await openai.chat.completions.create({...});
|
|
28
|
-
* recordResponseReceived(ctx, {
|
|
29
|
-
* model: res.model,
|
|
30
|
-
* promptTokens: res.usage?.prompt_tokens,
|
|
31
|
-
* completionTokens: res.usage?.completion_tokens,
|
|
32
|
-
* finishReasons: res.choices.map(c => c.finish_reason),
|
|
33
|
-
* });
|
|
34
|
-
* return res;
|
|
35
|
-
* } catch (err) {
|
|
36
|
-
* recordRetry(ctx, { attempt, reason: 'rate_limit', delayMs: 500 });
|
|
37
|
-
* await sleep(500 * attempt);
|
|
38
|
-
* }
|
|
39
|
-
* }
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
import type { TraceContext } from './trace-context';
|
|
45
|
-
import { emitCorrelatedEvent } from './correlated-events';
|
|
46
|
-
|
|
47
|
-
type EventAttrs = Record<string, string | number | boolean>;
|
|
48
|
-
|
|
49
|
-
/** Attributes expected on a `gen_ai.prompt.sent` event. */
|
|
50
|
-
export interface PromptSentEvent {
|
|
51
|
-
/** Model the caller intends to invoke (may differ from response model). */
|
|
52
|
-
model?: string;
|
|
53
|
-
/** Estimated input token count, when known before the call. */
|
|
54
|
-
promptTokens?: number;
|
|
55
|
-
/** Number of messages in a chat request (system + user + assistant). */
|
|
56
|
-
messageCount?: number;
|
|
57
|
-
/** Free-form operation kind — `chat` / `completion` / `embedding`. */
|
|
58
|
-
operation?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Attributes expected on a `gen_ai.response.received` event. */
|
|
62
|
-
export interface ResponseReceivedEvent {
|
|
63
|
-
/** Model the provider actually served (may be more specific than requested). */
|
|
64
|
-
model?: string;
|
|
65
|
-
promptTokens?: number;
|
|
66
|
-
completionTokens?: number;
|
|
67
|
-
totalTokens?: number;
|
|
68
|
-
/** `stop`, `length`, `content_filter`, `tool_calls`, etc. */
|
|
69
|
-
finishReasons?: string[];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Attributes expected on a `gen_ai.retry` event. */
|
|
73
|
-
export interface RetryEvent {
|
|
74
|
-
attempt: number;
|
|
75
|
-
/** `rate_limit` | `timeout` | `provider_error` | custom label. */
|
|
76
|
-
reason?: string;
|
|
77
|
-
/** How long we'll wait before the next attempt. */
|
|
78
|
-
delayMs?: number;
|
|
79
|
-
/** HTTP status that triggered the retry, when applicable. */
|
|
80
|
-
statusCode?: number;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Attributes expected on a `gen_ai.tool.call` event. */
|
|
84
|
-
export interface ToolCallEvent {
|
|
85
|
-
toolName: string;
|
|
86
|
-
/** Call identifier so responses can be correlated back to calls. */
|
|
87
|
-
toolCallId?: string;
|
|
88
|
-
/** Pre-serialised tool arguments; omit if sensitive. */
|
|
89
|
-
arguments?: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** Attributes expected on a `gen_ai.stream.first_token` event. */
|
|
93
|
-
export interface StreamFirstTokenEvent {
|
|
94
|
-
/** Tokens streamed so far, if the caller tracks that. */
|
|
95
|
-
tokensSoFar?: number;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Record that a prompt was dispatched to the provider. Typically called
|
|
100
|
-
* before `await provider.chat.completions.create(...)`.
|
|
101
|
-
*/
|
|
102
|
-
export function recordPromptSent(
|
|
103
|
-
ctx: TraceContext,
|
|
104
|
-
event: PromptSentEvent = {},
|
|
105
|
-
): void {
|
|
106
|
-
emitCorrelatedEvent(ctx, 'gen_ai.prompt.sent', buildPromptSentAttrs(event));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Record a successful provider response. Call after the response arrives
|
|
111
|
-
* (for non-streaming) or after the stream completes.
|
|
112
|
-
*/
|
|
113
|
-
export function recordResponseReceived(
|
|
114
|
-
ctx: TraceContext,
|
|
115
|
-
event: ResponseReceivedEvent = {},
|
|
116
|
-
): void {
|
|
117
|
-
emitCorrelatedEvent(
|
|
118
|
-
ctx,
|
|
119
|
-
'gen_ai.response.received',
|
|
120
|
-
buildResponseAttrs(event),
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Record a retry attempt on an LLM call. Call *before* sleeping for
|
|
126
|
-
* `delayMs` so the event timestamp accurately marks when the retry
|
|
127
|
-
* decision was made.
|
|
128
|
-
*/
|
|
129
|
-
export function recordRetry(ctx: TraceContext, event: RetryEvent): void {
|
|
130
|
-
emitCorrelatedEvent(ctx, 'gen_ai.retry', buildRetryAttrs(event));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Record a tool / function call made in the course of an agent step.
|
|
135
|
-
* Emits an event rather than a child span because many frameworks fire
|
|
136
|
-
* several tool calls within a single provider response.
|
|
137
|
-
*/
|
|
138
|
-
export function recordToolCall(ctx: TraceContext, event: ToolCallEvent): void {
|
|
139
|
-
emitCorrelatedEvent(ctx, 'gen_ai.tool.call', buildToolCallAttrs(event));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Record the time-to-first-token for a streaming response. Pair with
|
|
144
|
-
* `recordResponseReceived` at the end so the span carries both the TTFT
|
|
145
|
-
* marker and the final usage numbers.
|
|
146
|
-
*/
|
|
147
|
-
export function recordStreamFirstToken(
|
|
148
|
-
ctx: TraceContext,
|
|
149
|
-
event: StreamFirstTokenEvent = {},
|
|
150
|
-
): void {
|
|
151
|
-
emitCorrelatedEvent(
|
|
152
|
-
ctx,
|
|
153
|
-
'gen_ai.stream.first_token',
|
|
154
|
-
buildStreamFirstTokenAttrs(event),
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// ---- Attribute builders -------------------------------------------------
|
|
159
|
-
|
|
160
|
-
function buildPromptSentAttrs(event: PromptSentEvent): EventAttrs {
|
|
161
|
-
const attrs: EventAttrs = {};
|
|
162
|
-
if (event.model) attrs['gen_ai.request.model'] = event.model;
|
|
163
|
-
if (event.promptTokens !== undefined)
|
|
164
|
-
attrs['gen_ai.usage.input_tokens'] = event.promptTokens;
|
|
165
|
-
if (event.messageCount !== undefined)
|
|
166
|
-
attrs['gen_ai.request.message_count'] = event.messageCount;
|
|
167
|
-
if (event.operation) attrs['gen_ai.operation.name'] = event.operation;
|
|
168
|
-
return attrs;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function buildResponseAttrs(event: ResponseReceivedEvent): EventAttrs {
|
|
172
|
-
const attrs: EventAttrs = {};
|
|
173
|
-
if (event.model) attrs['gen_ai.response.model'] = event.model;
|
|
174
|
-
if (event.promptTokens !== undefined)
|
|
175
|
-
attrs['gen_ai.usage.input_tokens'] = event.promptTokens;
|
|
176
|
-
if (event.completionTokens !== undefined)
|
|
177
|
-
attrs['gen_ai.usage.output_tokens'] = event.completionTokens;
|
|
178
|
-
if (event.totalTokens !== undefined)
|
|
179
|
-
attrs['gen_ai.usage.total_tokens'] = event.totalTokens;
|
|
180
|
-
if (event.finishReasons && event.finishReasons.length > 0) {
|
|
181
|
-
// Arrays aren't primitive AttributeValues on this context, so join.
|
|
182
|
-
attrs['gen_ai.response.finish_reasons'] = event.finishReasons.join(',');
|
|
183
|
-
}
|
|
184
|
-
return attrs;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function buildRetryAttrs(event: RetryEvent): EventAttrs {
|
|
188
|
-
const attrs: EventAttrs = { 'retry.attempt': event.attempt };
|
|
189
|
-
if (event.reason) attrs['retry.reason'] = event.reason;
|
|
190
|
-
if (event.delayMs !== undefined) attrs['retry.delay_ms'] = event.delayMs;
|
|
191
|
-
if (event.statusCode !== undefined)
|
|
192
|
-
attrs['http.response.status_code'] = event.statusCode;
|
|
193
|
-
return attrs;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function buildToolCallAttrs(event: ToolCallEvent): EventAttrs {
|
|
197
|
-
const attrs: EventAttrs = { 'gen_ai.tool.name': event.toolName };
|
|
198
|
-
if (event.toolCallId) attrs['gen_ai.tool.call.id'] = event.toolCallId;
|
|
199
|
-
if (event.arguments) attrs['gen_ai.tool.arguments'] = event.arguments;
|
|
200
|
-
return attrs;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function buildStreamFirstTokenAttrs(event: StreamFirstTokenEvent): EventAttrs {
|
|
204
|
-
const attrs: EventAttrs = {};
|
|
205
|
-
if (event.tokensSoFar !== undefined)
|
|
206
|
-
attrs['gen_ai.stream.tokens_so_far'] = event.tokensSoFar;
|
|
207
|
-
return attrs;
|
|
208
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { AggregationType } from '@opentelemetry/sdk-metrics';
|
|
3
|
-
import {
|
|
4
|
-
GEN_AI_COST_USD_BUCKETS,
|
|
5
|
-
GEN_AI_DURATION_BUCKETS_SECONDS,
|
|
6
|
-
GEN_AI_TOKEN_USAGE_BUCKETS,
|
|
7
|
-
genAiMetricViews,
|
|
8
|
-
llmHistogramAdvice,
|
|
9
|
-
} from './gen-ai-metrics';
|
|
10
|
-
|
|
11
|
-
describe('gen-ai-metrics', () => {
|
|
12
|
-
it('bucket arrays are strictly ascending (required by Prometheus + OTel)', () => {
|
|
13
|
-
for (const buckets of [
|
|
14
|
-
GEN_AI_DURATION_BUCKETS_SECONDS,
|
|
15
|
-
GEN_AI_TOKEN_USAGE_BUCKETS,
|
|
16
|
-
GEN_AI_COST_USD_BUCKETS,
|
|
17
|
-
]) {
|
|
18
|
-
for (let i = 1; i < buckets.length; i++) {
|
|
19
|
-
expect(
|
|
20
|
-
buckets[i]! > buckets[i - 1]!,
|
|
21
|
-
`index ${i} not ascending: ${buckets[i - 1]} → ${buckets[i]}`,
|
|
22
|
-
).toBe(true);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('duration buckets cover tail through 5 minutes for reasoning models', () => {
|
|
28
|
-
expect(GEN_AI_DURATION_BUCKETS_SECONDS[0]).toBeLessThanOrEqual(0.05);
|
|
29
|
-
expect(
|
|
30
|
-
GEN_AI_DURATION_BUCKETS_SECONDS[
|
|
31
|
-
GEN_AI_DURATION_BUCKETS_SECONDS.length - 1
|
|
32
|
-
],
|
|
33
|
-
).toBeGreaterThanOrEqual(300);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('token buckets cover up to a million-token context window', () => {
|
|
37
|
-
expect(
|
|
38
|
-
GEN_AI_TOKEN_USAGE_BUCKETS[GEN_AI_TOKEN_USAGE_BUCKETS.length - 1],
|
|
39
|
-
).toBeGreaterThanOrEqual(1_000_000);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('cost buckets resolve sub-cent spend', () => {
|
|
43
|
-
expect(GEN_AI_COST_USD_BUCKETS[0]).toBeLessThan(0.001);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('bucket arrays are frozen — consumers cannot mutate shared state', () => {
|
|
47
|
-
expect(() => {
|
|
48
|
-
(GEN_AI_DURATION_BUCKETS_SECONDS as number[]).push(999);
|
|
49
|
-
}).toThrow();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('llmHistogramAdvice returns explicitBucketBoundaries advice shape', () => {
|
|
53
|
-
const advice = llmHistogramAdvice('duration');
|
|
54
|
-
expect(advice.advice.explicitBucketBoundaries).toEqual([
|
|
55
|
-
...GEN_AI_DURATION_BUCKETS_SECONDS,
|
|
56
|
-
]);
|
|
57
|
-
// The returned array is a fresh copy so callers can mutate without
|
|
58
|
-
// affecting the shared constant.
|
|
59
|
-
advice.advice.explicitBucketBoundaries.push(0);
|
|
60
|
-
expect([...GEN_AI_DURATION_BUCKETS_SECONDS]).not.toContain(0);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('genAiMetricViews targets the OTel GenAI instrument names with the right buckets', () => {
|
|
64
|
-
const views = genAiMetricViews();
|
|
65
|
-
expect(views).toHaveLength(3);
|
|
66
|
-
|
|
67
|
-
const byInstrument = Object.fromEntries(
|
|
68
|
-
views.map((v) => [v.instrumentName, v]),
|
|
69
|
-
);
|
|
70
|
-
expect(
|
|
71
|
-
byInstrument['gen_ai.client.operation.duration']?.aggregation,
|
|
72
|
-
).toEqual({
|
|
73
|
-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
|
|
74
|
-
options: { boundaries: [...GEN_AI_DURATION_BUCKETS_SECONDS] },
|
|
75
|
-
});
|
|
76
|
-
expect(byInstrument['gen_ai.client.token.usage']?.aggregation).toEqual({
|
|
77
|
-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
|
|
78
|
-
options: { boundaries: [...GEN_AI_TOKEN_USAGE_BUCKETS] },
|
|
79
|
-
});
|
|
80
|
-
expect(byInstrument['gen_ai.client.cost.usd']?.aggregation).toEqual({
|
|
81
|
-
type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
|
|
82
|
-
options: { boundaries: [...GEN_AI_COST_USD_BUCKETS] },
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('genAiMetricViews accepts extra instruments', () => {
|
|
87
|
-
const views = genAiMetricViews([
|
|
88
|
-
{ instrumentName: 'custom.llm.prompt_tokens', kind: 'tokens' },
|
|
89
|
-
]);
|
|
90
|
-
expect(views).toHaveLength(4);
|
|
91
|
-
const custom = views.find(
|
|
92
|
-
(v) => v.instrumentName === 'custom.llm.prompt_tokens',
|
|
93
|
-
);
|
|
94
|
-
expect(custom).toBeDefined();
|
|
95
|
-
});
|
|
96
|
-
});
|