@smoothbricks/lmao 0.1.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 +269 -0
- package/dist/allocator.wasm +0 -0
- package/dist/bun/preload.d.ts +11 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +10 -0
- package/dist/bun/trace-preload.d.ts +8 -0
- package/dist/bun/trace-preload.d.ts.map +1 -0
- package/dist/bun/trace-preload.js +12 -0
- package/dist/es.d.ts +8 -0
- package/dist/es.d.ts.map +1 -0
- package/dist/es.js +9 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/lib/JsBufferStrategy.d.ts +49 -0
- package/dist/lib/JsBufferStrategy.d.ts.map +1 -0
- package/dist/lib/JsBufferStrategy.js +60 -0
- package/dist/lib/archive/chunkCompaction.d.ts +15 -0
- package/dist/lib/archive/chunkCompaction.d.ts.map +1 -0
- package/dist/lib/archive/chunkCompaction.js +24 -0
- package/dist/lib/archive/chunkEnvelope.d.ts +21 -0
- package/dist/lib/archive/chunkEnvelope.d.ts.map +1 -0
- package/dist/lib/archive/chunkEnvelope.js +55 -0
- package/dist/lib/archive/chunkRouting.d.ts +10 -0
- package/dist/lib/archive/chunkRouting.d.ts.map +1 -0
- package/dist/lib/archive/chunkRouting.js +47 -0
- package/dist/lib/archive/chunkStats.d.ts +12 -0
- package/dist/lib/archive/chunkStats.d.ts.map +1 -0
- package/dist/lib/archive/chunkStats.js +10 -0
- package/dist/lib/archive/index.d.ts +5 -0
- package/dist/lib/archive/index.d.ts.map +1 -0
- package/dist/lib/archive/index.js +4 -0
- package/dist/lib/arrow/capacityStats.d.ts +9 -0
- package/dist/lib/arrow/capacityStats.d.ts.map +1 -0
- package/dist/lib/arrow/capacityStats.js +231 -0
- package/dist/lib/arrow/dictionaries.d.ts +27 -0
- package/dist/lib/arrow/dictionaries.d.ts.map +1 -0
- package/dist/lib/arrow/dictionaries.js +135 -0
- package/dist/lib/arrow/flechette.d.ts +40 -0
- package/dist/lib/arrow/flechette.d.ts.map +1 -0
- package/dist/lib/arrow/flechette.js +67 -0
- package/dist/lib/arrow/utils.d.ts +38 -0
- package/dist/lib/arrow/utils.d.ts.map +1 -0
- package/dist/lib/arrow/utils.js +112 -0
- package/dist/lib/buffer/Nanoseconds.d.ts +109 -0
- package/dist/lib/buffer/Nanoseconds.d.ts.map +1 -0
- package/dist/lib/buffer/Nanoseconds.js +86 -0
- package/dist/lib/bufferStrategy.d.ts +95 -0
- package/dist/lib/bufferStrategy.d.ts.map +1 -0
- package/dist/lib/bufferStrategy.js +1 -0
- package/dist/lib/capacityTuning.d.ts +50 -0
- package/dist/lib/capacityTuning.d.ts.map +1 -0
- package/dist/lib/capacityTuning.js +65 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts +35 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/evaluatorGenerator.js +199 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +139 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.js +289 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts +115 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/spanLoggerGenerator.js +575 -0
- package/dist/lib/convertToArrow.d.ts +40 -0
- package/dist/lib/convertToArrow.d.ts.map +1 -0
- package/dist/lib/convertToArrow.js +1467 -0
- package/dist/lib/defineOpContext.d.ts +96 -0
- package/dist/lib/defineOpContext.d.ts.map +1 -0
- package/dist/lib/defineOpContext.js +227 -0
- package/dist/lib/errors/Blocked.d.ts +113 -0
- package/dist/lib/errors/Blocked.d.ts.map +1 -0
- package/dist/lib/errors/Blocked.js +68 -0
- package/dist/lib/errors/CodeError.d.ts +101 -0
- package/dist/lib/errors/CodeError.d.ts.map +1 -0
- package/dist/lib/errors/CodeError.js +42 -0
- package/dist/lib/errors/RetriesExhausted.d.ts +67 -0
- package/dist/lib/errors/RetriesExhausted.d.ts.map +1 -0
- package/dist/lib/errors/RetriesExhausted.js +31 -0
- package/dist/lib/errors/Transient.d.ts +115 -0
- package/dist/lib/errors/Transient.d.ts.map +1 -0
- package/dist/lib/errors/Transient.js +54 -0
- package/dist/lib/errors/index.d.ts +14 -0
- package/dist/lib/errors/index.d.ts.map +1 -0
- package/dist/lib/errors/index.js +16 -0
- package/dist/lib/errors/retry-policy.d.ts +60 -0
- package/dist/lib/errors/retry-policy.d.ts.map +1 -0
- package/dist/lib/errors/retry-policy.js +54 -0
- package/dist/lib/flushScheduler.d.ts +162 -0
- package/dist/lib/flushScheduler.d.ts.map +1 -0
- package/dist/lib/flushScheduler.js +388 -0
- package/dist/lib/library.d.ts +149 -0
- package/dist/lib/library.d.ts.map +1 -0
- package/dist/lib/library.js +588 -0
- package/dist/lib/logApi.d.ts +61 -0
- package/dist/lib/logApi.d.ts.map +1 -0
- package/dist/lib/logApi.js +12 -0
- package/dist/lib/logBinding.d.ts +63 -0
- package/dist/lib/logBinding.d.ts.map +1 -0
- package/dist/lib/logBinding.js +1 -0
- package/dist/lib/op.d.ts +105 -0
- package/dist/lib/op.d.ts.map +1 -0
- package/dist/lib/op.js +59 -0
- package/dist/lib/opContext/contextTypes.d.ts +88 -0
- package/dist/lib/opContext/contextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/contextTypes.js +34 -0
- package/dist/lib/opContext/createOpGroup.d.ts +57 -0
- package/dist/lib/opContext/createOpGroup.d.ts.map +1 -0
- package/dist/lib/opContext/createOpGroup.js +341 -0
- package/dist/lib/opContext/defineOp.d.ts +83 -0
- package/dist/lib/opContext/defineOp.d.ts.map +1 -0
- package/dist/lib/opContext/defineOp.js +197 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts +58 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts.map +1 -0
- package/dist/lib/opContext/featureFlagTypes.js +1 -0
- package/dist/lib/opContext/index.d.ts +13 -0
- package/dist/lib/opContext/index.d.ts.map +1 -0
- package/dist/lib/opContext/index.js +15 -0
- package/dist/lib/opContext/opGroupTypes.d.ts +250 -0
- package/dist/lib/opContext/opGroupTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opGroupTypes.js +31 -0
- package/dist/lib/opContext/opTypes.d.ts +48 -0
- package/dist/lib/opContext/opTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opTypes.js +7 -0
- package/dist/lib/opContext/spanContextTypes.d.ts +347 -0
- package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/spanContextTypes.js +1 -0
- package/dist/lib/opContext/types.d.ts +297 -0
- package/dist/lib/opContext/types.d.ts.map +1 -0
- package/dist/lib/opContext/types.js +16 -0
- package/dist/lib/result.d.ts +308 -0
- package/dist/lib/result.d.ts.map +1 -0
- package/dist/lib/result.js +359 -0
- package/dist/lib/schema/LogSchema.d.ts +62 -0
- package/dist/lib/schema/LogSchema.d.ts.map +1 -0
- package/dist/lib/schema/LogSchema.js +134 -0
- package/dist/lib/schema/builder.d.ts +12 -0
- package/dist/lib/schema/builder.d.ts.map +1 -0
- package/dist/lib/schema/builder.js +169 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts +60 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts.map +1 -0
- package/dist/lib/schema/defineFeatureFlags.js +29 -0
- package/dist/lib/schema/defineLogSchema.d.ts +87 -0
- package/dist/lib/schema/defineLogSchema.d.ts.map +1 -0
- package/dist/lib/schema/defineLogSchema.js +171 -0
- package/dist/lib/schema/evaluator.d.ts +267 -0
- package/dist/lib/schema/evaluator.d.ts.map +1 -0
- package/dist/lib/schema/evaluator.js +169 -0
- package/dist/lib/schema/extend.d.ts +14 -0
- package/dist/lib/schema/extend.d.ts.map +1 -0
- package/dist/lib/schema/extend.js +51 -0
- package/dist/lib/schema/systemSchema.d.ts +112 -0
- package/dist/lib/schema/systemSchema.d.ts.map +1 -0
- package/dist/lib/schema/systemSchema.js +260 -0
- package/dist/lib/schema/typeGuards.d.ts +52 -0
- package/dist/lib/schema/typeGuards.d.ts.map +1 -0
- package/dist/lib/schema/typeGuards.js +127 -0
- package/dist/lib/schema/types.d.ts +156 -0
- package/dist/lib/schema/types.d.ts.map +1 -0
- package/dist/lib/schema/types.js +4 -0
- package/dist/lib/spanBuffer.d.ts +133 -0
- package/dist/lib/spanBuffer.d.ts.map +1 -0
- package/dist/lib/spanBuffer.js +442 -0
- package/dist/lib/spanBufferHelpers.d.ts +53 -0
- package/dist/lib/spanBufferHelpers.d.ts.map +1 -0
- package/dist/lib/spanBufferHelpers.js +65 -0
- package/dist/lib/spanBufferStats.d.ts +38 -0
- package/dist/lib/spanBufferStats.d.ts.map +1 -0
- package/dist/lib/spanBufferStats.js +1 -0
- package/dist/lib/spanContext.d.ts +141 -0
- package/dist/lib/spanContext.d.ts.map +1 -0
- package/dist/lib/spanContext.js +763 -0
- package/dist/lib/sqlite/index.d.ts +14 -0
- package/dist/lib/sqlite/index.d.ts.map +1 -0
- package/dist/lib/sqlite/index.js +12 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts +24 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-async-writer.js +65 -0
- package/dist/lib/sqlite/sqlite-common.d.ts +37 -0
- package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-common.js +207 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts +25 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-d1.js +67 -0
- package/dist/lib/sqlite/sqlite-db.d.ts +29 -0
- package/dist/lib/sqlite/sqlite-db.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-db.js +1 -0
- package/dist/lib/sqlite/sqlite-node.d.ts +16 -0
- package/dist/lib/sqlite/sqlite-node.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-node.js +68 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts +39 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-writer.js +78 -0
- package/dist/lib/testing/bun-harness.d.ts +150 -0
- package/dist/lib/testing/bun-harness.d.ts.map +1 -0
- package/dist/lib/testing/bun-harness.js +729 -0
- package/dist/lib/testing/extractFacts.d.ts +73 -0
- package/dist/lib/testing/extractFacts.d.ts.map +1 -0
- package/dist/lib/testing/extractFacts.js +237 -0
- package/dist/lib/testing/facts.d.ts +235 -0
- package/dist/lib/testing/facts.d.ts.map +1 -0
- package/dist/lib/testing/facts.js +209 -0
- package/dist/lib/testing/index.d.ts +58 -0
- package/dist/lib/testing/index.d.ts.map +1 -0
- package/dist/lib/testing/index.js +74 -0
- package/dist/lib/testing/queryable-span.d.ts +39 -0
- package/dist/lib/testing/queryable-span.d.ts.map +1 -0
- package/dist/lib/testing/queryable-span.js +58 -0
- package/dist/lib/testing/span-query.d.ts +21 -0
- package/dist/lib/testing/span-query.d.ts.map +1 -0
- package/dist/lib/testing/span-query.js +47 -0
- package/dist/lib/testing/stdio-replay.d.ts +4 -0
- package/dist/lib/testing/stdio-replay.d.ts.map +1 -0
- package/dist/lib/testing/stdio-replay.js +42 -0
- package/dist/lib/testing/trace-query.d.ts +59 -0
- package/dist/lib/testing/trace-query.d.ts.map +1 -0
- package/dist/lib/testing/trace-query.js +462 -0
- package/dist/lib/testing/vitest-harness.d.ts +135 -0
- package/dist/lib/testing/vitest-harness.d.ts.map +1 -0
- package/dist/lib/testing/vitest-harness.js +486 -0
- package/dist/lib/threadId.d.ts +58 -0
- package/dist/lib/threadId.d.ts.map +1 -0
- package/dist/lib/threadId.js +123 -0
- package/dist/lib/traceContext.d.ts +116 -0
- package/dist/lib/traceContext.d.ts.map +1 -0
- package/dist/lib/traceContext.js +37 -0
- package/dist/lib/traceId.d.ts +78 -0
- package/dist/lib/traceId.d.ts.map +1 -0
- package/dist/lib/traceId.js +87 -0
- package/dist/lib/traceRoot.d.ts +133 -0
- package/dist/lib/traceRoot.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.d.ts +75 -0
- package/dist/lib/traceRoot.es.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.js +129 -0
- package/dist/lib/traceRoot.js +19 -0
- package/dist/lib/traceRoot.node.d.ts +77 -0
- package/dist/lib/traceRoot.node.d.ts.map +1 -0
- package/dist/lib/traceRoot.node.js +133 -0
- package/dist/lib/traceRoot.universal.d.ts +3 -0
- package/dist/lib/traceRoot.universal.d.ts.map +1 -0
- package/dist/lib/traceRoot.universal.js +17 -0
- package/dist/lib/tracer.d.ts +296 -0
- package/dist/lib/tracer.d.ts.map +1 -0
- package/dist/lib/tracer.js +346 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts +56 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts.map +1 -0
- package/dist/lib/tracers/ArrayQueueTracer.js +67 -0
- package/dist/lib/tracers/CompositeTracer.d.ts +24 -0
- package/dist/lib/tracers/CompositeTracer.d.ts.map +1 -0
- package/dist/lib/tracers/CompositeTracer.js +57 -0
- package/dist/lib/tracers/NoOpTracer.d.ts +58 -0
- package/dist/lib/tracers/NoOpTracer.d.ts.map +1 -0
- package/dist/lib/tracers/NoOpTracer.js +41 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts +42 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts.map +1 -0
- package/dist/lib/tracers/SQLiteTracer.js +84 -0
- package/dist/lib/tracers/StdioTracer.d.ts +83 -0
- package/dist/lib/tracers/StdioTracer.d.ts.map +1 -0
- package/dist/lib/tracers/StdioTracer.js +270 -0
- package/dist/lib/tracers/TestTracer.d.ts +95 -0
- package/dist/lib/tracers/TestTracer.d.ts.map +1 -0
- package/dist/lib/tracers/TestTracer.js +87 -0
- package/dist/lib/tracers/index.d.ts +12 -0
- package/dist/lib/tracers/index.d.ts.map +1 -0
- package/dist/lib/tracers/index.js +11 -0
- package/dist/lib/types.d.ts +366 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/utf8Cache.d.ts +111 -0
- package/dist/lib/utf8Cache.d.ts.map +1 -0
- package/dist/lib/utf8Cache.js +177 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts +88 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -0
- package/dist/lib/wasm/WasmBufferStrategy.js +138 -0
- package/dist/lib/wasm/wasmAllocator.d.ts +109 -0
- package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -0
- package/dist/lib/wasm/wasmAllocator.js +227 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts +123 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -0
- package/dist/lib/wasm/wasmSpanBuffer.js +772 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts +167 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -0
- package/dist/lib/wasm/wasmTraceRoot.js +264 -0
- package/dist/node.d.ts +7 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +8 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +17 -0
- package/package.json +193 -0
- package/src/bun/preload.ts +11 -0
- package/src/bun/trace-preload.ts +14 -0
- package/src/es.ts +11 -0
- package/src/index.ts +194 -0
- package/src/lib/JsBufferStrategy.ts +102 -0
- package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +485 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +390 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +647 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +292 -0
- package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +354 -0
- package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +127 -0
- package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +392 -0
- package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +389 -0
- package/src/lib/__tests__/arrow-conversion-algorithms.test.ts +54 -0
- package/src/lib/__tests__/arrow-test-helpers.ts +71 -0
- package/src/lib/__tests__/binary-e2e.test.ts +203 -0
- package/src/lib/__tests__/buffer-overflow-op-api.test.ts +608 -0
- package/src/lib/__tests__/buffer-overflow.test.ts +612 -0
- package/src/lib/__tests__/capacity-tuning.test.ts +544 -0
- package/src/lib/__tests__/effective-schema.test.ts +439 -0
- package/src/lib/__tests__/flechette.test.ts +42 -0
- package/src/lib/__tests__/flushScheduler.test.ts +537 -0
- package/src/lib/__tests__/integration.test.ts +600 -0
- package/src/lib/__tests__/library.test.ts +934 -0
- package/src/lib/__tests__/nested-library-tasks.test.ts +849 -0
- package/src/lib/__tests__/op-context-binding.test.ts +135 -0
- package/src/lib/__tests__/op-metadata.test.ts +198 -0
- package/src/lib/__tests__/op-type-safety.test.ts +71 -0
- package/src/lib/__tests__/package-exports.test.ts +57 -0
- package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +319 -0
- package/src/lib/__tests__/remapped-buffer-view.test.ts +635 -0
- package/src/lib/__tests__/scope-attributes.test.ts +348 -0
- package/src/lib/__tests__/span-lifecycle.test.ts +680 -0
- package/src/lib/__tests__/sync-async-trace.test.ts +435 -0
- package/src/lib/__tests__/test-helpers.ts +318 -0
- package/src/lib/__tests__/timestamp.test.ts +259 -0
- package/src/lib/__tests__/trace-archive-primitives.test.ts +98 -0
- package/src/lib/__tests__/traceContext-type-enforcement.test.ts +271 -0
- package/src/lib/__tests__/tracer.test.ts +211 -0
- package/src/lib/__tests__/type-narrowing.test.ts +137 -0
- package/src/lib/archive/chunkCompaction.ts +44 -0
- package/src/lib/archive/chunkEnvelope.ts +79 -0
- package/src/lib/archive/chunkRouting.ts +70 -0
- package/src/lib/archive/chunkStats.ts +25 -0
- package/src/lib/archive/index.ts +4 -0
- package/src/lib/arrow/capacityStats.ts +340 -0
- package/src/lib/arrow/dictionaries.ts +159 -0
- package/src/lib/arrow/flechette.ts +114 -0
- package/src/lib/arrow/utils.ts +126 -0
- package/src/lib/buffer/Nanoseconds.ts +131 -0
- package/src/lib/bufferStrategy.ts +106 -0
- package/src/lib/capacityTuning.ts +102 -0
- package/src/lib/codegen/__tests__/__snapshots__/evaluatorGenerator.test.ts.snap +160 -0
- package/src/lib/codegen/__tests__/__snapshots__/scopeGenerator.test.ts.snap +196 -0
- package/src/lib/codegen/__tests__/__snapshots__/spanLoggerGenerator.test.ts.snap +1965 -0
- package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +516 -0
- package/src/lib/codegen/__tests__/nullBitmap.test.ts +207 -0
- package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +237 -0
- package/src/lib/codegen/evaluatorGenerator.ts +309 -0
- package/src/lib/codegen/fixedPositionWriterGenerator.ts +444 -0
- package/src/lib/codegen/spanLoggerGenerator.ts +715 -0
- package/src/lib/convertToArrow.ts +1805 -0
- package/src/lib/defineOpContext.ts +398 -0
- package/src/lib/errors/Blocked.ts +165 -0
- package/src/lib/errors/CodeError.ts +132 -0
- package/src/lib/errors/RetriesExhausted.ts +78 -0
- package/src/lib/errors/Transient.ts +168 -0
- package/src/lib/errors/__tests__/Blocked-config.test.ts +152 -0
- package/src/lib/errors/__tests__/Transient.test.ts +129 -0
- package/src/lib/errors/__tests__/retry-policy.test.ts +85 -0
- package/src/lib/errors/index.ts +24 -0
- package/src/lib/errors/retry-policy.ts +87 -0
- package/src/lib/flushScheduler.ts +509 -0
- package/src/lib/library.ts +682 -0
- package/src/lib/logApi.ts +70 -0
- package/src/lib/logBinding.ts +67 -0
- package/src/lib/op.ts +103 -0
- package/src/lib/opContext/__tests__/retry.test.ts +764 -0
- package/src/lib/opContext/contextTypes.ts +130 -0
- package/src/lib/opContext/createOpGroup.ts +456 -0
- package/src/lib/opContext/defineOp.ts +281 -0
- package/src/lib/opContext/featureFlagTypes.ts +54 -0
- package/src/lib/opContext/index.ts +16 -0
- package/src/lib/opContext/opGroupTypes.ts +342 -0
- package/src/lib/opContext/opTypes.ts +80 -0
- package/src/lib/opContext/spanContextTypes.ts +398 -0
- package/src/lib/opContext/types.ts +403 -0
- package/src/lib/result.ts +550 -0
- package/src/lib/schema/LogSchema.ts +153 -0
- package/src/lib/schema/__tests__/defineLogSchema.test.ts +342 -0
- package/src/lib/schema/__tests__/featureFlags.test.ts +443 -0
- package/src/lib/schema/builder.ts +201 -0
- package/src/lib/schema/defineFeatureFlags.ts +91 -0
- package/src/lib/schema/defineLogSchema.ts +291 -0
- package/src/lib/schema/evaluator.ts +404 -0
- package/src/lib/schema/extend.ts +69 -0
- package/src/lib/schema/systemSchema.ts +339 -0
- package/src/lib/schema/typeGuards.ts +163 -0
- package/src/lib/schema/types.ts +265 -0
- package/src/lib/spanBuffer.ts +571 -0
- package/src/lib/spanBufferHelpers.ts +73 -0
- package/src/lib/spanBufferStats.ts +40 -0
- package/src/lib/spanContext.ts +1566 -0
- package/src/lib/sqlite/__tests__/sqlite-common.test.ts +89 -0
- package/src/lib/sqlite/index.ts +26 -0
- package/src/lib/sqlite/sqlite-async-writer.ts +101 -0
- package/src/lib/sqlite/sqlite-common.ts +309 -0
- package/src/lib/sqlite/sqlite-d1.ts +104 -0
- package/src/lib/sqlite/sqlite-db.ts +32 -0
- package/src/lib/sqlite/sqlite-node.ts +83 -0
- package/src/lib/sqlite/sqlite-writer.ts +128 -0
- package/src/lib/testing/TRACE-TESTING.md +100 -0
- package/src/lib/testing/__tests__/bun-harness.test.ts +108 -0
- package/src/lib/testing/__tests__/extractFacts.test.ts +279 -0
- package/src/lib/testing/__tests__/facts.test.ts +324 -0
- package/src/lib/testing/__tests__/vitest-harness.test.ts +32 -0
- package/src/lib/testing/bun-harness.ts +990 -0
- package/src/lib/testing/extractFacts.ts +362 -0
- package/src/lib/testing/facts.ts +470 -0
- package/src/lib/testing/index.ts +141 -0
- package/src/lib/testing/queryable-span.ts +108 -0
- package/src/lib/testing/span-query.ts +65 -0
- package/src/lib/testing/stdio-replay.ts +50 -0
- package/src/lib/testing/trace-query.ts +329 -0
- package/src/lib/testing/vitest-harness.ts +691 -0
- package/src/lib/threadId.ts +135 -0
- package/src/lib/traceContext.ts +182 -0
- package/src/lib/traceId.ts +142 -0
- package/src/lib/traceRoot.es.ts +157 -0
- package/src/lib/traceRoot.node.ts +170 -0
- package/src/lib/traceRoot.ts +154 -0
- package/src/lib/traceRoot.universal.ts +22 -0
- package/src/lib/tracer.ts +896 -0
- package/src/lib/tracers/ArrayQueueTracer.ts +76 -0
- package/src/lib/tracers/CompositeTracer.ts +76 -0
- package/src/lib/tracers/NoOpTracer.ts +73 -0
- package/src/lib/tracers/SQLiteTracer.ts +115 -0
- package/src/lib/tracers/StdioTracer.ts +380 -0
- package/src/lib/tracers/TestTracer.ts +146 -0
- package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +184 -0
- package/src/lib/tracers/__tests__/NoOpTracer.test.ts +204 -0
- package/src/lib/tracers/__tests__/StdioTracer.test.ts +313 -0
- package/src/lib/tracers/__tests__/TestTracer.test.ts +200 -0
- package/src/lib/tracers/index.ts +12 -0
- package/src/lib/types.ts +498 -0
- package/src/lib/utf8Cache.ts +201 -0
- package/src/lib/wasm/WasmBufferStrategy.ts +219 -0
- package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +256 -0
- package/src/lib/wasm/__tests__/wasm-integration.test.ts +476 -0
- package/src/lib/wasm/__tests__/wasmAllocator.test.ts +699 -0
- package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +449 -0
- package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +390 -0
- package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +444 -0
- package/src/lib/wasm/allocator.zig +945 -0
- package/src/lib/wasm/wasmAllocator.ts +469 -0
- package/src/lib/wasm/wasmSpanBuffer.ts +1014 -0
- package/src/lib/wasm/wasmTraceRoot.ts +315 -0
- package/src/node.ts +10 -0
- package/src/testing.ts +18 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NoOpTracer tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for the NoOpTracer class - a tracer that executes ops but
|
|
5
|
+
* produces no output (no-op lifecycle hooks).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, it } from 'bun:test';
|
|
9
|
+
import { createTestTracerOptions } from '../../__tests__/test-helpers.js';
|
|
10
|
+
import { defineLogSchema, defineOpContext, S } from '../../defineOpContext.js';
|
|
11
|
+
import { defineCodeError } from '../../result.js';
|
|
12
|
+
import { NoOpTracer } from '../NoOpTracer.js';
|
|
13
|
+
|
|
14
|
+
// Test schema
|
|
15
|
+
const testSchema = defineLogSchema({
|
|
16
|
+
userId: S.category(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Error factory for tests
|
|
20
|
+
const VALIDATION_ERROR = defineCodeError('VALIDATION_ERROR')<{ field: string }>();
|
|
21
|
+
|
|
22
|
+
describe('NoOpTracer', () => {
|
|
23
|
+
describe('instantiation', () => {
|
|
24
|
+
it('should create a NoOpTracer instance', () => {
|
|
25
|
+
const ctx = defineOpContext({
|
|
26
|
+
logSchema: testSchema,
|
|
27
|
+
});
|
|
28
|
+
const tracer = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
29
|
+
expect(tracer).toBeDefined();
|
|
30
|
+
expect(tracer.trace).toBeDefined();
|
|
31
|
+
expect(tracer.flush).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should allow destructuring trace and flush', () => {
|
|
35
|
+
const ctx = defineOpContext({
|
|
36
|
+
logSchema: testSchema,
|
|
37
|
+
});
|
|
38
|
+
const { trace, flush } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
39
|
+
expect(typeof trace).toBe('function');
|
|
40
|
+
expect(typeof flush).toBe('function');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('trace execution', () => {
|
|
45
|
+
it('should execute functions and return result', async () => {
|
|
46
|
+
const ctx = defineOpContext({
|
|
47
|
+
logSchema: testSchema,
|
|
48
|
+
});
|
|
49
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
50
|
+
|
|
51
|
+
const result = await trace('test-trace', async (ctx) => {
|
|
52
|
+
ctx.tag.userId('user-123');
|
|
53
|
+
return { success: true, value: 'sync-result' };
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(result).toEqual({ success: true, value: 'sync-result' });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should execute async functions and return result', async () => {
|
|
60
|
+
const ctx = defineOpContext({
|
|
61
|
+
logSchema: testSchema,
|
|
62
|
+
});
|
|
63
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
64
|
+
|
|
65
|
+
const result = await trace('test-trace', async (ctx) => {
|
|
66
|
+
await Promise.resolve();
|
|
67
|
+
ctx.tag.userId('user-456');
|
|
68
|
+
return 'async-result';
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(result).toBe('async-result');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should propagate exceptions from traced functions', async () => {
|
|
75
|
+
const ctx = defineOpContext({
|
|
76
|
+
logSchema: testSchema,
|
|
77
|
+
});
|
|
78
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
79
|
+
|
|
80
|
+
await expect(
|
|
81
|
+
trace('test-trace', async () => {
|
|
82
|
+
throw new Error('test-error');
|
|
83
|
+
}),
|
|
84
|
+
).rejects.toThrow('test-error');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should support nested spans', async () => {
|
|
88
|
+
const ctx = defineOpContext({
|
|
89
|
+
logSchema: testSchema,
|
|
90
|
+
});
|
|
91
|
+
const { defineOp } = ctx;
|
|
92
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
93
|
+
|
|
94
|
+
const childOp = defineOp('child', (ctx) => {
|
|
95
|
+
return ctx.ok('child-done');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const result = await trace('parent-trace', async (ctx) => {
|
|
99
|
+
const childResult = await ctx.span('child-span', childOp);
|
|
100
|
+
expect(childResult.success).toBe(true);
|
|
101
|
+
return 'parent-done';
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(result).toBe('parent-done');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('flush', () => {
|
|
109
|
+
it('should be a no-op that returns resolved promise', async () => {
|
|
110
|
+
const ctx = defineOpContext({
|
|
111
|
+
logSchema: testSchema,
|
|
112
|
+
});
|
|
113
|
+
const { flush } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
114
|
+
|
|
115
|
+
// Should not throw, should resolve immediately
|
|
116
|
+
await expect(flush()).resolves.toBeUndefined();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should clear pending buffers without processing', async () => {
|
|
120
|
+
const ctx = defineOpContext({
|
|
121
|
+
logSchema: testSchema,
|
|
122
|
+
});
|
|
123
|
+
const { trace, flush } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
124
|
+
|
|
125
|
+
// Create a trace
|
|
126
|
+
await trace('test-trace', async () => {
|
|
127
|
+
return 'done';
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Flush should clear without doing anything
|
|
131
|
+
await flush();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('lifecycle hooks', () => {
|
|
136
|
+
it('should not throw when hooks are called (they are no-ops)', async () => {
|
|
137
|
+
const ctx = defineOpContext({
|
|
138
|
+
logSchema: testSchema,
|
|
139
|
+
});
|
|
140
|
+
const { defineOp } = ctx;
|
|
141
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
142
|
+
|
|
143
|
+
const childOp1 = defineOp('c1', (c) => c.ok(1));
|
|
144
|
+
const childOp2 = defineOp('c2', (c) => c.ok(2));
|
|
145
|
+
|
|
146
|
+
// Should complete without any errors
|
|
147
|
+
const result = await trace('test-trace', async (ctx) => {
|
|
148
|
+
// Create multiple nested spans to trigger all hooks
|
|
149
|
+
await ctx.span('child1', childOp1);
|
|
150
|
+
await ctx.span('child2', childOp2);
|
|
151
|
+
return 'done';
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(result).toBe('done');
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('use cases', () => {
|
|
159
|
+
it('should work for tests that do not need trace inspection', async () => {
|
|
160
|
+
// This demonstrates using NoOpTracer for testing business logic
|
|
161
|
+
// without caring about trace output
|
|
162
|
+
const ctx = defineOpContext({
|
|
163
|
+
logSchema: testSchema,
|
|
164
|
+
});
|
|
165
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
166
|
+
|
|
167
|
+
const result = await trace('math-test', async () => {
|
|
168
|
+
return 2 + 2;
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
expect(result).toBe(4);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should support ctx.ok() for successful results', async () => {
|
|
175
|
+
const ctx = defineOpContext({
|
|
176
|
+
logSchema: testSchema,
|
|
177
|
+
});
|
|
178
|
+
const { defineOp } = ctx;
|
|
179
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
180
|
+
|
|
181
|
+
const successOp = defineOp('success', (ctx) => {
|
|
182
|
+
return ctx.ok({ status: 'success' });
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const result = await trace('ok-test', successOp);
|
|
186
|
+
expect(result.success).toBe(true);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should support ctx.err() for error results', async () => {
|
|
190
|
+
const ctx = defineOpContext({
|
|
191
|
+
logSchema: testSchema,
|
|
192
|
+
});
|
|
193
|
+
const { defineOp } = ctx;
|
|
194
|
+
const { trace } = new NoOpTracer(ctx, { ...createTestTracerOptions() });
|
|
195
|
+
|
|
196
|
+
const failingOp = defineOp('failing', (ctx) => {
|
|
197
|
+
return ctx.err(VALIDATION_ERROR({ field: 'email' }));
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const result = await trace('err-test', failingOp);
|
|
201
|
+
expect(result.success).toBe(false);
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StdioTracer tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for the StdioTracer class - a tracer that prints spans to stdout/stderr
|
|
5
|
+
* with color-coded trace IDs, indentation, and human-readable formatting.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Configure Node.js timestamp implementation - MUST be first import
|
|
9
|
+
import '../../__tests__/test-helpers.js';
|
|
10
|
+
|
|
11
|
+
import { describe, expect, it } from 'bun:test';
|
|
12
|
+
import { Writable } from 'node:stream';
|
|
13
|
+
import { createTestTracerOptions } from '../../__tests__/test-helpers.js';
|
|
14
|
+
import { defineOpContext } from '../../defineOpContext.js';
|
|
15
|
+
import { defineCodeError } from '../../result.js';
|
|
16
|
+
import { S } from '../../schema/builder.js';
|
|
17
|
+
import { defineLogSchema } from '../../schema/defineLogSchema.js';
|
|
18
|
+
import { StdioTracer, type StdioWritable } from '../StdioTracer.js';
|
|
19
|
+
|
|
20
|
+
// Error code factory for tests
|
|
21
|
+
const TEST_ERROR = defineCodeError('CODE')<{ message: string }>();
|
|
22
|
+
|
|
23
|
+
type MockStream = { stream: StdioWritable; output: string[] };
|
|
24
|
+
|
|
25
|
+
// Create a mock writable stream that captures output
|
|
26
|
+
function createMockStream(): MockStream {
|
|
27
|
+
const output: string[] = [];
|
|
28
|
+
const writable = new Writable({
|
|
29
|
+
write(chunk, _encoding, callback) {
|
|
30
|
+
output.push(chunk.toString());
|
|
31
|
+
callback();
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const stream: StdioWritable = {
|
|
35
|
+
write(chunk: string): boolean {
|
|
36
|
+
return writable.write(chunk);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
return { stream, output };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('StdioTracer', () => {
|
|
43
|
+
const testSchema = defineLogSchema({
|
|
44
|
+
userId: S.category(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const ctx = defineOpContext({
|
|
48
|
+
logSchema: testSchema,
|
|
49
|
+
});
|
|
50
|
+
const { defineOp } = ctx;
|
|
51
|
+
|
|
52
|
+
describe('basic output', () => {
|
|
53
|
+
it('should write trace start and end to stdout', async () => {
|
|
54
|
+
const { stream: out, output } = createMockStream();
|
|
55
|
+
const { stream: err } = createMockStream();
|
|
56
|
+
|
|
57
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
58
|
+
const { trace } = tracer;
|
|
59
|
+
|
|
60
|
+
const testOp = defineOp('test', (ctx) => ctx.ok('done'));
|
|
61
|
+
await trace('my-trace', testOp);
|
|
62
|
+
|
|
63
|
+
// Should have trace start and trace end lines
|
|
64
|
+
expect(output.length).toBeGreaterThanOrEqual(2);
|
|
65
|
+
expect(output.some((line) => line.includes('my-trace'))).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should include trace_id in output', async () => {
|
|
69
|
+
const { stream: out, output } = createMockStream();
|
|
70
|
+
const { stream: err } = createMockStream();
|
|
71
|
+
|
|
72
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
73
|
+
const { trace } = tracer;
|
|
74
|
+
|
|
75
|
+
const testOp = defineOp('test', (ctx) => ctx.ok('done'));
|
|
76
|
+
await trace('id-test', testOp);
|
|
77
|
+
|
|
78
|
+
// trace_id is W3C format (32 hex chars), should appear in brackets
|
|
79
|
+
expect(output.some((line) => /\[[a-f0-9]{32}\]/.test(line))).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should include timestamp in output', async () => {
|
|
83
|
+
const { stream: out, output } = createMockStream();
|
|
84
|
+
const { stream: err } = createMockStream();
|
|
85
|
+
|
|
86
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
87
|
+
const { trace } = tracer;
|
|
88
|
+
|
|
89
|
+
const testOp = defineOp('test', (ctx) => ctx.ok('done'));
|
|
90
|
+
await trace('ts-test', testOp);
|
|
91
|
+
|
|
92
|
+
// ISO timestamp format
|
|
93
|
+
expect(output.some((line) => /\d{4}-\d{2}-\d{2}T/.test(line))).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should render log message templates using row values', async () => {
|
|
97
|
+
const { stream: out, output } = createMockStream();
|
|
98
|
+
const { stream: err } = createMockStream();
|
|
99
|
+
|
|
100
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
101
|
+
const { trace } = tracer;
|
|
102
|
+
|
|
103
|
+
const testOp = defineOp('test', (ctx) => {
|
|
104
|
+
ctx.log.info('Processing {{userId}}').userId('u-123');
|
|
105
|
+
return ctx.ok('done');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
await trace('format-test', testOp);
|
|
109
|
+
|
|
110
|
+
expect(output.some((line) => line.includes('INFO Processing u-123'))).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('nested spans with indentation', () => {
|
|
115
|
+
it('should indent child spans', async () => {
|
|
116
|
+
const { stream: out, output } = createMockStream();
|
|
117
|
+
const { stream: err } = createMockStream();
|
|
118
|
+
|
|
119
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
120
|
+
const { trace } = tracer;
|
|
121
|
+
|
|
122
|
+
const childOp = defineOp('child', (ctx) => ctx.ok('c'));
|
|
123
|
+
const parentOp = defineOp('parent', async (ctx) => {
|
|
124
|
+
await ctx.span('child-span', childOp);
|
|
125
|
+
return ctx.ok('p');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
await trace('root', parentOp);
|
|
129
|
+
|
|
130
|
+
// Find lines with child-span - should have indentation
|
|
131
|
+
const childLines = output.filter((line) => line.includes('child-span'));
|
|
132
|
+
expect(childLines.length).toBeGreaterThan(0);
|
|
133
|
+
|
|
134
|
+
// Child lines should have leading spaces (indentation)
|
|
135
|
+
const hasIndent = childLines.some((line) => /\s{2,}.*child-span/.test(line));
|
|
136
|
+
expect(hasIndent).toBe(true);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should use tree characters (├─ and └─)', async () => {
|
|
140
|
+
const { stream: out, output } = createMockStream();
|
|
141
|
+
const { stream: err } = createMockStream();
|
|
142
|
+
|
|
143
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
144
|
+
const { trace } = tracer;
|
|
145
|
+
|
|
146
|
+
const childOp = defineOp('child', (ctx) => ctx.ok('c'));
|
|
147
|
+
const parentOp = defineOp('parent', async (ctx) => {
|
|
148
|
+
await ctx.span('tree-child', childOp);
|
|
149
|
+
return ctx.ok('p');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
await trace('tree-root', parentOp);
|
|
153
|
+
|
|
154
|
+
// Should have tree branch characters
|
|
155
|
+
const hasStartBranch = output.some((line) => line.includes('├─'));
|
|
156
|
+
const hasEndBranch = output.some((line) => line.includes('└─'));
|
|
157
|
+
|
|
158
|
+
expect(hasStartBranch).toBe(true);
|
|
159
|
+
expect(hasEndBranch).toBe(true);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('status indicators', () => {
|
|
164
|
+
it('should show [OK] for successful spans', async () => {
|
|
165
|
+
const { stream: out, output } = createMockStream();
|
|
166
|
+
const { stream: err } = createMockStream();
|
|
167
|
+
|
|
168
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
169
|
+
const { trace } = tracer;
|
|
170
|
+
|
|
171
|
+
const testOp = defineOp('test', (ctx) => ctx.ok('done'));
|
|
172
|
+
await trace('ok-test', testOp);
|
|
173
|
+
|
|
174
|
+
expect(output.some((line) => line.includes('[OK]'))).toBe(true);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should show [ERR] for ctx.err() results', async () => {
|
|
178
|
+
const { stream: out, output } = createMockStream();
|
|
179
|
+
const { stream: err } = createMockStream();
|
|
180
|
+
|
|
181
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
182
|
+
const { trace } = tracer;
|
|
183
|
+
|
|
184
|
+
const testOp = defineOp('test', (ctx) => ctx.err(TEST_ERROR({ message: 'error' })));
|
|
185
|
+
await trace('err-test', testOp);
|
|
186
|
+
|
|
187
|
+
expect(output.some((line) => line.includes('[ERR]'))).toBe(true);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('should show [EXCEPTION] and write to stderr for thrown errors', async () => {
|
|
191
|
+
const { stream: out, output: stdout } = createMockStream();
|
|
192
|
+
const { stream: err, output: stderr } = createMockStream();
|
|
193
|
+
|
|
194
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
195
|
+
const { trace } = tracer;
|
|
196
|
+
|
|
197
|
+
const failOp = defineOp('fail', async () => {
|
|
198
|
+
throw new Error('boom');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
await expect(trace('exception-test', failOp)).rejects.toThrow('boom');
|
|
202
|
+
|
|
203
|
+
// EXCEPTION should go to stderr for child spans
|
|
204
|
+
// But root trace might go to stdout
|
|
205
|
+
const allOutput = [...stdout, ...stderr];
|
|
206
|
+
expect(allOutput.some((line) => line.includes('[EXCEPTION]') || line.includes('EXCEPTION'))).toBe(true);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('duration formatting', () => {
|
|
211
|
+
it('should include duration in span end output', async () => {
|
|
212
|
+
const { stream: out, output } = createMockStream();
|
|
213
|
+
const { stream: err } = createMockStream();
|
|
214
|
+
|
|
215
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
216
|
+
const { trace } = tracer;
|
|
217
|
+
|
|
218
|
+
const testOp = defineOp('test', async (ctx) => {
|
|
219
|
+
await new Promise((r) => setTimeout(r, 10)); // Small delay
|
|
220
|
+
return ctx.ok('done');
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
await trace('duration-test', testOp);
|
|
224
|
+
|
|
225
|
+
// Should have duration with unit (ms, µs, ns, or s)
|
|
226
|
+
expect(output.some((line) => /\(\d+\.\d+(?:s|ms|µs|ns)\)/.test(line))).toBe(true);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('concurrent trace isolation', () => {
|
|
231
|
+
it('should track indent per trace_id for concurrent traces', async () => {
|
|
232
|
+
const { stream: out, output } = createMockStream();
|
|
233
|
+
const { stream: err } = createMockStream();
|
|
234
|
+
|
|
235
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
236
|
+
const { trace } = tracer;
|
|
237
|
+
|
|
238
|
+
const childOp = defineOp('child', async (ctx) => {
|
|
239
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
240
|
+
return ctx.ok('c');
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const parentOp = defineOp('parent', async (ctx) => {
|
|
244
|
+
await ctx.span('nested', childOp);
|
|
245
|
+
return ctx.ok('p');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Run two traces concurrently
|
|
249
|
+
await Promise.all([trace('trace-A', parentOp), trace('trace-B', parentOp)]);
|
|
250
|
+
|
|
251
|
+
// Both traces should complete without corrupted indentation
|
|
252
|
+
// This is hard to assert precisely, but at minimum both should appear
|
|
253
|
+
expect(output.some((line) => line.includes('trace-A'))).toBe(true);
|
|
254
|
+
expect(output.some((line) => line.includes('trace-B'))).toBe(true);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
describe('color support', () => {
|
|
259
|
+
it('should include ANSI color codes when enabled', async () => {
|
|
260
|
+
const { stream: out, output } = createMockStream();
|
|
261
|
+
const { stream: err } = createMockStream();
|
|
262
|
+
|
|
263
|
+
// Enable colors
|
|
264
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: true });
|
|
265
|
+
const { trace } = tracer;
|
|
266
|
+
|
|
267
|
+
const testOp = defineOp('test', (ctx) => ctx.ok('done'));
|
|
268
|
+
await trace('color-test', testOp);
|
|
269
|
+
|
|
270
|
+
// Should have ANSI escape codes (ESC character followed by [<number>m)
|
|
271
|
+
const hasAnsi = output.some((line) => {
|
|
272
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: Testing for ANSI escape sequences
|
|
273
|
+
return /\u001b\[\d+m/.test(line);
|
|
274
|
+
});
|
|
275
|
+
expect(hasAnsi).toBe(true);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('should not include ANSI codes when colors disabled', async () => {
|
|
279
|
+
const { stream: out, output } = createMockStream();
|
|
280
|
+
const { stream: err } = createMockStream();
|
|
281
|
+
|
|
282
|
+
// Disable colors
|
|
283
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
284
|
+
const { trace } = tracer;
|
|
285
|
+
|
|
286
|
+
const testOp = defineOp('test', (ctx) => ctx.ok('done'));
|
|
287
|
+
await trace('no-color-test', testOp);
|
|
288
|
+
|
|
289
|
+
// Should NOT have ANSI escape codes
|
|
290
|
+
const hasAnsi = output.some((line) => {
|
|
291
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: Testing for ANSI escape sequences
|
|
292
|
+
return /\u001b\[\d+m/.test(line);
|
|
293
|
+
});
|
|
294
|
+
expect(hasAnsi).toBe(false);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('separator line', () => {
|
|
299
|
+
it('should print separator line at trace end', async () => {
|
|
300
|
+
const { stream: out, output } = createMockStream();
|
|
301
|
+
const { stream: err } = createMockStream();
|
|
302
|
+
|
|
303
|
+
const tracer = new StdioTracer(ctx, { ...createTestTracerOptions(), out, err, colorEnabled: false });
|
|
304
|
+
const { trace } = tracer;
|
|
305
|
+
|
|
306
|
+
const testOp = defineOp('test', (ctx) => ctx.ok('done'));
|
|
307
|
+
await trace('sep-test', testOp);
|
|
308
|
+
|
|
309
|
+
// Should have line of = characters
|
|
310
|
+
expect(output.some((line) => /={10,}/.test(line))).toBe(true);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
});
|