@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,608 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buffer overflow tests - Op-centric API Integration
|
|
3
|
+
*
|
|
4
|
+
* These tests verify buffer chaining behavior through the PUBLIC API:
|
|
5
|
+
* - defineOpContext / defineOp for op definition
|
|
6
|
+
* - Fluent logging API (ctx.log.info().userId().requestId())
|
|
7
|
+
* - trace.span() for span execution
|
|
8
|
+
* - convertSpanTreeToArrowTable for Arrow output
|
|
9
|
+
*
|
|
10
|
+
* Complements buffer-overflow.test.ts which tests low-level buffer mechanics.
|
|
11
|
+
*
|
|
12
|
+
* Key differences from buffer-overflow.test.ts:
|
|
13
|
+
* - Uses public API only (no internal buffer access like _writeIndex)
|
|
14
|
+
* - Verifies behavior via Arrow output, not buffer internals
|
|
15
|
+
* - Tests natural usage patterns, not precise buffer mechanics
|
|
16
|
+
*
|
|
17
|
+
* Property-based testing with fast-check for comprehensive coverage.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, expect, it } from 'bun:test';
|
|
21
|
+
// Must import test-helpers first to initialize timestamp implementation
|
|
22
|
+
import './test-helpers.js';
|
|
23
|
+
import fc from 'fast-check';
|
|
24
|
+
import { convertSpanTreeToArrowTable } from '../convertToArrow.js';
|
|
25
|
+
import { defineOpContext } from '../defineOpContext.js';
|
|
26
|
+
import { defineCodeError } from '../result.js';
|
|
27
|
+
import { S } from '../schema/builder.js';
|
|
28
|
+
import { defineLogSchema } from '../schema/defineLogSchema.js';
|
|
29
|
+
import { TestTracer } from '../tracers/TestTracer.js';
|
|
30
|
+
import type { AnySpanBuffer } from '../types.js';
|
|
31
|
+
import { createTestTracerOptions } from './test-helpers.js';
|
|
32
|
+
|
|
33
|
+
// Error code factory for tests
|
|
34
|
+
const VALIDATION_ERROR = defineCodeError('VALIDATION_ERROR')<{ field: string }>();
|
|
35
|
+
const HTTP_OPERATIONS = ['GET', 'POST', 'PUT', 'DELETE'] as const;
|
|
36
|
+
const EMPTY_CTX: Record<string, never> = {};
|
|
37
|
+
|
|
38
|
+
type CapturedBuffer = AnySpanBuffer | undefined;
|
|
39
|
+
|
|
40
|
+
function requireCapturedBuffer(buffer: CapturedBuffer, label: string): AnySpanBuffer {
|
|
41
|
+
if (!buffer) {
|
|
42
|
+
throw new Error(`Expected captured buffer: ${label}`);
|
|
43
|
+
}
|
|
44
|
+
return buffer;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Test schema with various column types
|
|
48
|
+
const testSchema = defineLogSchema({
|
|
49
|
+
userId: S.category(),
|
|
50
|
+
requestId: S.category(),
|
|
51
|
+
operation: S.enum(['GET', 'POST', 'PUT', 'DELETE']),
|
|
52
|
+
duration: S.number(),
|
|
53
|
+
errorMsg: S.text(),
|
|
54
|
+
index: S.number(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Create op context factory
|
|
58
|
+
const ctx = defineOpContext({
|
|
59
|
+
logSchema: testSchema,
|
|
60
|
+
ctx: EMPTY_CTX,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const { defineOp } = ctx;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Helper to create a properly typed tracer for tests
|
|
67
|
+
*/
|
|
68
|
+
function createTestTracer() {
|
|
69
|
+
return new TestTracer(ctx, { ...createTestTracerOptions() });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getColumnValue(
|
|
73
|
+
table: ReturnType<typeof convertSpanTreeToArrowTable>,
|
|
74
|
+
columnName: string,
|
|
75
|
+
rowIndex: number,
|
|
76
|
+
): unknown {
|
|
77
|
+
const column = table.getChild(columnName);
|
|
78
|
+
if (!column) {
|
|
79
|
+
throw new Error(`column not found: ${columnName}`);
|
|
80
|
+
}
|
|
81
|
+
return column.get(rowIndex);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Count rows in Arrow table by entry_type
|
|
86
|
+
*/
|
|
87
|
+
function countRowsByEntryType(table: ReturnType<typeof convertSpanTreeToArrowTable>): Record<string, number> {
|
|
88
|
+
const counts: Record<string, number> = {};
|
|
89
|
+
for (let i = 0; i < table.numRows; i++) {
|
|
90
|
+
const entryType = getColumnValue(table, 'entry_type', i);
|
|
91
|
+
if (typeof entryType !== 'string' || entryType.length === 0) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
counts[entryType] = (counts[entryType] || 0) + 1;
|
|
95
|
+
}
|
|
96
|
+
return counts;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Extract all rows from Arrow table as JSON
|
|
101
|
+
*/
|
|
102
|
+
function extractRows(table: ReturnType<typeof convertSpanTreeToArrowTable>): Array<Record<string, unknown>> {
|
|
103
|
+
const columns = [
|
|
104
|
+
'entry_type',
|
|
105
|
+
'message',
|
|
106
|
+
'userId',
|
|
107
|
+
'requestId',
|
|
108
|
+
'operation',
|
|
109
|
+
'duration',
|
|
110
|
+
'index',
|
|
111
|
+
'errorMsg',
|
|
112
|
+
'parent_span_id',
|
|
113
|
+
'span_id',
|
|
114
|
+
'trace_id',
|
|
115
|
+
] as const;
|
|
116
|
+
return Array.from({ length: table.numRows }, (_, rowIndex) => {
|
|
117
|
+
const row: Record<string, unknown> = {};
|
|
118
|
+
for (const columnName of columns) {
|
|
119
|
+
const column = table.getChild(columnName);
|
|
120
|
+
if (column) {
|
|
121
|
+
row[columnName] = column.get(rowIndex) as unknown;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return row;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
describe('Buffer Overflow - Op-centric API Integration', () => {
|
|
129
|
+
describe('Entry Preservation via Arrow Output', () => {
|
|
130
|
+
it('should preserve all logged entries in Arrow output', async () => {
|
|
131
|
+
await fc.assert(
|
|
132
|
+
fc.asyncProperty(
|
|
133
|
+
fc.integer({ min: 1, max: 50 }), // Number of log entries
|
|
134
|
+
async (numEntries) => {
|
|
135
|
+
let capturedBuffer: CapturedBuffer;
|
|
136
|
+
|
|
137
|
+
const testOp = defineOp('entry-preservation', async (ctx) => {
|
|
138
|
+
capturedBuffer = ctx.buffer;
|
|
139
|
+
|
|
140
|
+
// Log entries using the fluent API
|
|
141
|
+
for (let i = 0; i < numEntries; i++) {
|
|
142
|
+
ctx.log
|
|
143
|
+
.info(`message-${i}`)
|
|
144
|
+
.userId(`user-${i % 5}`)
|
|
145
|
+
.requestId(`req-${i % 3}`)
|
|
146
|
+
.operation(HTTP_OPERATIONS[i % 4])
|
|
147
|
+
.index(i);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return ctx.ok({ logged: numEntries });
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const { trace } = createTestTracer();
|
|
154
|
+
const result = await trace('test', testOp);
|
|
155
|
+
|
|
156
|
+
expect(result.success).toBe(true);
|
|
157
|
+
expect(capturedBuffer).toBeDefined();
|
|
158
|
+
|
|
159
|
+
// Convert to Arrow and verify
|
|
160
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'entry-preservation'));
|
|
161
|
+
const counts = countRowsByEntryType(table);
|
|
162
|
+
|
|
163
|
+
// Should have: 1 span-start + numEntries info + 1 span-ok
|
|
164
|
+
expect(counts['span-start']).toBe(1);
|
|
165
|
+
expect(counts.info).toBe(numEntries);
|
|
166
|
+
expect(counts['span-ok']).toBe(1);
|
|
167
|
+
expect(table.numRows).toBe(2 + numEntries); // span-start + span-ok + entries
|
|
168
|
+
},
|
|
169
|
+
),
|
|
170
|
+
{ numRuns: 20 },
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe('Buffer Chaining with Large Entry Counts', () => {
|
|
176
|
+
it('should handle overflow transparently for large log volumes', async () => {
|
|
177
|
+
// Log many entries that will definitely cause buffer overflow
|
|
178
|
+
const numEntries = 200; // Way more than default buffer capacity (8)
|
|
179
|
+
let capturedBuffer: CapturedBuffer;
|
|
180
|
+
|
|
181
|
+
const testOp = defineOp('large-volume', async (ctx) => {
|
|
182
|
+
capturedBuffer = ctx.buffer;
|
|
183
|
+
|
|
184
|
+
for (let i = 0; i < numEntries; i++) {
|
|
185
|
+
ctx.log
|
|
186
|
+
.info(`log-${i}`)
|
|
187
|
+
.index(i)
|
|
188
|
+
.userId(`user-${i % 10}`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return ctx.ok({ count: numEntries });
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const { trace } = createTestTracer();
|
|
195
|
+
const result = await trace('large-test', testOp);
|
|
196
|
+
|
|
197
|
+
expect(result.success).toBe(true);
|
|
198
|
+
expect(capturedBuffer).toBeDefined();
|
|
199
|
+
|
|
200
|
+
// Convert to Arrow - this walks the entire buffer chain
|
|
201
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'large-volume'));
|
|
202
|
+
const counts = countRowsByEntryType(table);
|
|
203
|
+
|
|
204
|
+
// All entries should be present
|
|
205
|
+
expect(counts.info).toBe(numEntries);
|
|
206
|
+
expect(table.numRows).toBe(2 + numEntries);
|
|
207
|
+
|
|
208
|
+
// Verify some sample data
|
|
209
|
+
const rows = extractRows(table);
|
|
210
|
+
const infoRows = rows.filter((r) => r.entry_type === 'info');
|
|
211
|
+
|
|
212
|
+
// First and last entries should be correct
|
|
213
|
+
expect(infoRows[0].message).toBe('log-0');
|
|
214
|
+
expect(infoRows[0].index).toBe(0);
|
|
215
|
+
expect(infoRows[numEntries - 1].message).toBe(`log-${numEntries - 1}`);
|
|
216
|
+
expect(infoRows[numEntries - 1].index).toBe(numEntries - 1);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should preserve order across buffer chain boundaries', async () => {
|
|
220
|
+
const numEntries = 100;
|
|
221
|
+
let capturedBuffer: CapturedBuffer;
|
|
222
|
+
|
|
223
|
+
const testOp = defineOp('order-test', async (ctx) => {
|
|
224
|
+
capturedBuffer = ctx.buffer;
|
|
225
|
+
|
|
226
|
+
for (let i = 0; i < numEntries; i++) {
|
|
227
|
+
ctx.log.info(`entry-${i}`).index(i);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return ctx.ok('done');
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const { trace } = createTestTracer();
|
|
234
|
+
await trace('order', testOp);
|
|
235
|
+
|
|
236
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'order-test'));
|
|
237
|
+
const rows = extractRows(table);
|
|
238
|
+
const infoRows = rows.filter((r) => r.entry_type === 'info');
|
|
239
|
+
|
|
240
|
+
// Verify strict ordering - each entry should have index matching its position
|
|
241
|
+
for (let i = 0; i < numEntries; i++) {
|
|
242
|
+
expect(infoRows[i].index).toBe(i);
|
|
243
|
+
expect(infoRows[i].message).toBe(`entry-${i}`);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe('Data Integrity Through Arrow Conversion', () => {
|
|
249
|
+
it('should preserve attribute values through Arrow conversion', async () => {
|
|
250
|
+
await fc.assert(
|
|
251
|
+
fc.asyncProperty(fc.integer({ min: 10, max: 30 }), async (numEntries) => {
|
|
252
|
+
let capturedBuffer: CapturedBuffer;
|
|
253
|
+
|
|
254
|
+
const testOp = defineOp('data-integrity', async (ctx) => {
|
|
255
|
+
capturedBuffer = ctx.buffer;
|
|
256
|
+
|
|
257
|
+
for (let i = 0; i < numEntries; i++) {
|
|
258
|
+
ctx.log
|
|
259
|
+
.info(`msg-${i}`)
|
|
260
|
+
.userId(`user-${i}`)
|
|
261
|
+
.requestId(`req-${i}`)
|
|
262
|
+
.operation(HTTP_OPERATIONS[i % 4])
|
|
263
|
+
.duration(i * 1.5)
|
|
264
|
+
.index(i);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return ctx.ok('done');
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const { trace } = createTestTracer();
|
|
271
|
+
await trace('integrity', testOp);
|
|
272
|
+
|
|
273
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'data-integrity'));
|
|
274
|
+
const rows = extractRows(table);
|
|
275
|
+
const infoRows = rows.filter((r) => r.entry_type === 'info');
|
|
276
|
+
|
|
277
|
+
expect(infoRows.length).toBe(numEntries);
|
|
278
|
+
|
|
279
|
+
// Verify each entry has correct values
|
|
280
|
+
for (let i = 0; i < numEntries; i++) {
|
|
281
|
+
const row = infoRows[i];
|
|
282
|
+
expect(row.message).toBe(`msg-${i}`);
|
|
283
|
+
expect(row.userId).toBe(`user-${i}`);
|
|
284
|
+
expect(row.requestId).toBe(`req-${i}`);
|
|
285
|
+
expect(row.operation).toBe(['GET', 'POST', 'PUT', 'DELETE'][i % 4]);
|
|
286
|
+
expect(row.duration).toBe(i * 1.5);
|
|
287
|
+
expect(row.index).toBe(i);
|
|
288
|
+
}
|
|
289
|
+
}),
|
|
290
|
+
{ numRuns: 10 },
|
|
291
|
+
);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('should handle all column types correctly across overflow', async () => {
|
|
295
|
+
const numEntries = 50;
|
|
296
|
+
let capturedBuffer: CapturedBuffer;
|
|
297
|
+
|
|
298
|
+
const testOp = defineOp('column-types', async (ctx) => {
|
|
299
|
+
capturedBuffer = ctx.buffer;
|
|
300
|
+
|
|
301
|
+
for (let i = 0; i < numEntries; i++) {
|
|
302
|
+
ctx.log
|
|
303
|
+
.info(`text-message-${i}`) // text in message (system column)
|
|
304
|
+
.userId(`category-${i % 5}`) // category
|
|
305
|
+
.operation(HTTP_OPERATIONS[i % 4]) // enum
|
|
306
|
+
.duration(i * Math.PI) // number (float)
|
|
307
|
+
.index(i) // number (int stored as float)
|
|
308
|
+
.errorMsg(`unique-error-${i}-${Date.now()}`); // text (unique values)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return ctx.ok('done');
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
const { trace } = createTestTracer();
|
|
315
|
+
await trace('types', testOp);
|
|
316
|
+
|
|
317
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'enum-types'));
|
|
318
|
+
const rows = extractRows(table);
|
|
319
|
+
const infoRows = rows.filter((r) => r.entry_type === 'info');
|
|
320
|
+
|
|
321
|
+
expect(infoRows.length).toBe(numEntries);
|
|
322
|
+
|
|
323
|
+
// Spot check values
|
|
324
|
+
expect(infoRows[0].message).toBe('text-message-0');
|
|
325
|
+
expect(infoRows[0].userId).toBe('category-0');
|
|
326
|
+
expect(infoRows[0].operation).toBe('GET');
|
|
327
|
+
expect(infoRows[0].duration).toBeCloseTo(0, 5);
|
|
328
|
+
expect(infoRows[0].index).toBe(0);
|
|
329
|
+
const firstErrorMsg = infoRows[0].errorMsg;
|
|
330
|
+
expect(typeof firstErrorMsg).toBe('string');
|
|
331
|
+
if (typeof firstErrorMsg !== 'string') {
|
|
332
|
+
throw new Error('Expected first errorMsg to be a string');
|
|
333
|
+
}
|
|
334
|
+
expect(firstErrorMsg.startsWith('unique-error-0-')).toBe(true);
|
|
335
|
+
|
|
336
|
+
expect(infoRows[25].message).toBe('text-message-25');
|
|
337
|
+
expect(infoRows[25].duration).toBeCloseTo(25 * Math.PI, 5);
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
describe('Nested Spans with Overflow', () => {
|
|
342
|
+
it('should handle overflow in nested span hierarchies', async () => {
|
|
343
|
+
let rootBuffer: CapturedBuffer;
|
|
344
|
+
let childBuffer: CapturedBuffer;
|
|
345
|
+
|
|
346
|
+
const childOp = defineOp('child-op', async (ctx) => {
|
|
347
|
+
childBuffer = ctx.buffer;
|
|
348
|
+
|
|
349
|
+
// Log many entries in child span
|
|
350
|
+
for (let i = 0; i < 50; i++) {
|
|
351
|
+
ctx.log.info(`child-log-${i}`).index(i);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return ctx.ok('child-done');
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const parentOp = defineOp('parent-op', async (ctx) => {
|
|
358
|
+
rootBuffer = ctx.buffer;
|
|
359
|
+
|
|
360
|
+
// Log some in parent
|
|
361
|
+
for (let i = 0; i < 20; i++) {
|
|
362
|
+
ctx.log.info(`parent-log-${i}`).index(i);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Create child span
|
|
366
|
+
await ctx.span('child', childOp);
|
|
367
|
+
|
|
368
|
+
// More logs in parent after child
|
|
369
|
+
for (let i = 20; i < 30; i++) {
|
|
370
|
+
ctx.log.info(`parent-log-${i}`).index(i);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return ctx.ok('parent-done');
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const { trace } = createTestTracer();
|
|
377
|
+
const result = await trace('parent', parentOp);
|
|
378
|
+
|
|
379
|
+
expect(result.success).toBe(true);
|
|
380
|
+
expect(rootBuffer).toBeDefined();
|
|
381
|
+
expect(childBuffer).toBeDefined();
|
|
382
|
+
|
|
383
|
+
// Convert entire tree
|
|
384
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(rootBuffer, 'nested-root'));
|
|
385
|
+
|
|
386
|
+
// Count entries
|
|
387
|
+
const counts = countRowsByEntryType(table);
|
|
388
|
+
|
|
389
|
+
// Parent: 1 span-start + 30 info + 1 span-ok = 32
|
|
390
|
+
// Child: 1 span-start + 50 info + 1 span-ok = 52
|
|
391
|
+
// Total: 84 rows
|
|
392
|
+
expect(counts['span-start']).toBe(2); // parent + child
|
|
393
|
+
expect(counts['span-ok']).toBe(2); // parent + child
|
|
394
|
+
expect(counts.info).toBe(80); // 30 parent + 50 child
|
|
395
|
+
expect(table.numRows).toBe(84);
|
|
396
|
+
|
|
397
|
+
// Verify hierarchy in Arrow output
|
|
398
|
+
const rows = extractRows(table);
|
|
399
|
+
const spanStarts = rows.filter((r) => r.entry_type === 'span-start');
|
|
400
|
+
|
|
401
|
+
expect(spanStarts.length).toBe(2);
|
|
402
|
+
|
|
403
|
+
const parentSpan = spanStarts.find((r) => r.message === 'parent');
|
|
404
|
+
const childSpan = spanStarts.find((r) => r.message === 'child');
|
|
405
|
+
|
|
406
|
+
expect(parentSpan).toBeDefined();
|
|
407
|
+
expect(childSpan).toBeDefined();
|
|
408
|
+
|
|
409
|
+
// Parent span IS the root span (created by trace('parent', parentOp))
|
|
410
|
+
// Root spans have no parent, so parent_span_id is null
|
|
411
|
+
expect(parentSpan?.parent_span_id).toBeNull();
|
|
412
|
+
|
|
413
|
+
// Child's parent is the parent span
|
|
414
|
+
expect(childSpan?.parent_span_id).toBe(parentSpan?.span_id);
|
|
415
|
+
|
|
416
|
+
// Both have same trace_id
|
|
417
|
+
expect(childSpan?.trace_id).toBe(parentSpan?.trace_id);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('should handle deeply nested spans with overflow at each level', async () => {
|
|
421
|
+
let level1Buffer: CapturedBuffer;
|
|
422
|
+
|
|
423
|
+
const level4Op = defineOp('l4', async (ctx) => {
|
|
424
|
+
for (let i = 0; i < 15; i++) {
|
|
425
|
+
ctx.log.info(`l4-${i}`);
|
|
426
|
+
}
|
|
427
|
+
return ctx.ok('l4');
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
const level3Op = defineOp('l3', async (ctx) => {
|
|
431
|
+
for (let i = 0; i < 15; i++) {
|
|
432
|
+
ctx.log.info(`l3-${i}`);
|
|
433
|
+
}
|
|
434
|
+
await ctx.span('level4', level4Op);
|
|
435
|
+
return ctx.ok('l3');
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
const level2Op = defineOp('l2', async (ctx) => {
|
|
439
|
+
for (let i = 0; i < 15; i++) {
|
|
440
|
+
ctx.log.info(`l2-${i}`);
|
|
441
|
+
}
|
|
442
|
+
await ctx.span('level3', level3Op);
|
|
443
|
+
return ctx.ok('l2');
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
const level1Op = defineOp('l1', async (ctx) => {
|
|
447
|
+
level1Buffer = ctx.buffer;
|
|
448
|
+
for (let i = 0; i < 15; i++) {
|
|
449
|
+
ctx.log.info(`l1-${i}`);
|
|
450
|
+
}
|
|
451
|
+
await ctx.span('level2', level2Op);
|
|
452
|
+
return ctx.ok('l1');
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
const { trace } = createTestTracer();
|
|
456
|
+
await trace('level1', level1Op);
|
|
457
|
+
|
|
458
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(level1Buffer, 'nested-level1'));
|
|
459
|
+
const counts = countRowsByEntryType(table);
|
|
460
|
+
|
|
461
|
+
// 4 levels * (1 span-start + 15 info + 1 span-ok) = 4 * 17 = 68
|
|
462
|
+
expect(counts['span-start']).toBe(4);
|
|
463
|
+
expect(counts['span-ok']).toBe(4);
|
|
464
|
+
expect(counts.info).toBe(60); // 15 * 4 levels
|
|
465
|
+
expect(table.numRows).toBe(68);
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
describe('Edge Cases', () => {
|
|
470
|
+
it('should handle empty span (no user logs)', async () => {
|
|
471
|
+
let capturedBuffer: CapturedBuffer;
|
|
472
|
+
|
|
473
|
+
const testOp = defineOp('empty-span', async (ctx) => {
|
|
474
|
+
capturedBuffer = ctx.buffer;
|
|
475
|
+
// No logging, just return
|
|
476
|
+
return ctx.ok('empty');
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
const { trace } = createTestTracer();
|
|
480
|
+
await trace('empty', testOp);
|
|
481
|
+
|
|
482
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'empty-op'));
|
|
483
|
+
|
|
484
|
+
// Just span-start and span-ok
|
|
485
|
+
expect(table.numRows).toBe(2);
|
|
486
|
+
|
|
487
|
+
const counts = countRowsByEntryType(table);
|
|
488
|
+
expect(counts['span-start']).toBe(1);
|
|
489
|
+
expect(counts['span-ok']).toBe(1);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
it('should handle single log entry', async () => {
|
|
493
|
+
let capturedBuffer: CapturedBuffer;
|
|
494
|
+
|
|
495
|
+
const testOp = defineOp('single-log', async (ctx) => {
|
|
496
|
+
capturedBuffer = ctx.buffer;
|
|
497
|
+
ctx.log.info('single').userId('u1');
|
|
498
|
+
return ctx.ok('done');
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const { trace } = createTestTracer();
|
|
502
|
+
await trace('single', testOp);
|
|
503
|
+
|
|
504
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'single-log'));
|
|
505
|
+
expect(table.numRows).toBe(3); // span-start + info + span-ok
|
|
506
|
+
|
|
507
|
+
const rows = extractRows(table);
|
|
508
|
+
const infoRow = rows.find((r) => r.entry_type === 'info');
|
|
509
|
+
expect(infoRow?.message).toBe('single');
|
|
510
|
+
expect(infoRow?.userId).toBe('u1');
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
it('should handle error result (span-err)', async () => {
|
|
514
|
+
let capturedBuffer: CapturedBuffer;
|
|
515
|
+
|
|
516
|
+
const testOp = defineOp('error-span', async (ctx) => {
|
|
517
|
+
capturedBuffer = ctx.buffer;
|
|
518
|
+
ctx.log.info('before error');
|
|
519
|
+
return ctx.err(VALIDATION_ERROR({ field: 'email' }));
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
const { trace } = createTestTracer();
|
|
523
|
+
await trace('error', testOp);
|
|
524
|
+
|
|
525
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'error-path'));
|
|
526
|
+
const counts = countRowsByEntryType(table);
|
|
527
|
+
|
|
528
|
+
expect(counts['span-start']).toBe(1);
|
|
529
|
+
expect(counts.info).toBe(1);
|
|
530
|
+
expect(counts['span-err']).toBe(1);
|
|
531
|
+
expect(table.numRows).toBe(3);
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it('should handle exception (span-exception)', async () => {
|
|
535
|
+
let capturedBuffer: CapturedBuffer;
|
|
536
|
+
|
|
537
|
+
const testOp = defineOp('exception-span', async (ctx) => {
|
|
538
|
+
capturedBuffer = ctx.buffer;
|
|
539
|
+
ctx.log.info('before throw');
|
|
540
|
+
throw new Error('test exception');
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
const { trace } = createTestTracer();
|
|
544
|
+
|
|
545
|
+
await expect(trace('exception', testOp)).rejects.toThrow('test exception');
|
|
546
|
+
|
|
547
|
+
// Buffer should still have entries
|
|
548
|
+
expect(capturedBuffer).toBeDefined();
|
|
549
|
+
|
|
550
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'explicit-assert'));
|
|
551
|
+
const counts = countRowsByEntryType(table);
|
|
552
|
+
|
|
553
|
+
expect(counts['span-start']).toBe(1);
|
|
554
|
+
expect(counts.info).toBe(1);
|
|
555
|
+
expect(counts['span-exception']).toBe(1);
|
|
556
|
+
expect(table.numRows).toBe(3);
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
describe('Mixed Log Levels', () => {
|
|
561
|
+
it('should preserve all log levels through overflow', async () => {
|
|
562
|
+
let capturedBuffer: CapturedBuffer;
|
|
563
|
+
|
|
564
|
+
const testOp = defineOp('mixed-levels', async (ctx) => {
|
|
565
|
+
capturedBuffer = ctx.buffer;
|
|
566
|
+
|
|
567
|
+
// Mix of log levels
|
|
568
|
+
for (let i = 0; i < 50; i++) {
|
|
569
|
+
switch (i % 4) {
|
|
570
|
+
case 0:
|
|
571
|
+
ctx.log.info(`info-${i}`);
|
|
572
|
+
break;
|
|
573
|
+
case 1:
|
|
574
|
+
ctx.log.debug(`debug-${i}`);
|
|
575
|
+
break;
|
|
576
|
+
case 2:
|
|
577
|
+
ctx.log.warn(`warn-${i}`);
|
|
578
|
+
break;
|
|
579
|
+
case 3:
|
|
580
|
+
ctx.log.error(`error-${i}`);
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
return ctx.ok('done');
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
const { trace } = createTestTracer();
|
|
589
|
+
await trace('mixed', testOp);
|
|
590
|
+
|
|
591
|
+
const table = convertSpanTreeToArrowTable(requireCapturedBuffer(capturedBuffer, 'mixed-entries'));
|
|
592
|
+
const counts = countRowsByEntryType(table);
|
|
593
|
+
|
|
594
|
+
// 50 entries divided among 4 levels: 13+13+12+12 = 50
|
|
595
|
+
// info: i % 4 === 0: indices 0,4,8,12,16,20,24,28,32,36,40,44,48 = 13
|
|
596
|
+
// debug: i % 4 === 1: indices 1,5,9,13,17,21,25,29,33,37,41,45,49 = 13
|
|
597
|
+
// warn: i % 4 === 2: indices 2,6,10,14,18,22,26,30,34,38,42,46 = 12
|
|
598
|
+
// error: i % 4 === 3: indices 3,7,11,15,19,23,27,31,35,39,43,47 = 12
|
|
599
|
+
expect(counts.info).toBe(13);
|
|
600
|
+
expect(counts.debug).toBe(13);
|
|
601
|
+
expect(counts.warn).toBe(12);
|
|
602
|
+
expect(counts.error).toBe(12);
|
|
603
|
+
|
|
604
|
+
expect(counts['span-start']).toBe(1);
|
|
605
|
+
expect(counts['span-ok']).toBe(1);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
});
|