@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,635 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for RemappedBufferView - the view that maps prefixed column names
|
|
3
|
+
* to unprefixed column names for tree traversal during Arrow conversion.
|
|
4
|
+
*
|
|
5
|
+
* Per specs/lmao/01e_library_integration_pattern.md:
|
|
6
|
+
* - Libraries write to unprefixed columns (status, method)
|
|
7
|
+
* - Arrow conversion accesses via prefixed names (http_status, http_method)
|
|
8
|
+
* - RemappedBufferView bridges this gap for tree traversal
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, expect, it } from 'bun:test';
|
|
12
|
+
import '../../node.js'; // Configure timestamp implementation for Node.js
|
|
13
|
+
import { defineOpContext } from '../defineOpContext.js';
|
|
14
|
+
import { createPrefixMapping, generateRemappedBufferViewClass, prefixSchema } from '../library.js';
|
|
15
|
+
import { S } from '../schema/builder.js';
|
|
16
|
+
import { defineLogSchema } from '../schema/defineLogSchema.js';
|
|
17
|
+
import type { LogSchema } from '../schema/LogSchema.js';
|
|
18
|
+
import { TestTracer } from '../tracers/TestTracer.js';
|
|
19
|
+
import type { AnySpanBuffer } from '../types.js';
|
|
20
|
+
import { createBuffer, createTestTracerOptions, requireFloat64Array } from './test-helpers.js';
|
|
21
|
+
|
|
22
|
+
describe('generateRemappedBufferViewClass', () => {
|
|
23
|
+
describe('class generation', () => {
|
|
24
|
+
it('should generate a valid JavaScript class', () => {
|
|
25
|
+
// Mapping is prefixed → unprefixed (e.g., 'http_status' → 'status')
|
|
26
|
+
// This allows Arrow conversion to access via prefixed names while buffer has unprefixed columns
|
|
27
|
+
const mapping = { http_status: 'status', http_method: 'method' };
|
|
28
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
29
|
+
|
|
30
|
+
expect(typeof ViewClass).toBe('function');
|
|
31
|
+
expect(ViewClass.prototype).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should create instances with the wrapped buffer', () => {
|
|
35
|
+
const mapping = { http_status: 'status' };
|
|
36
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
37
|
+
|
|
38
|
+
const mockBuffer = createBuffer(defineLogSchema({}));
|
|
39
|
+
mockBuffer._writeIndex = 5;
|
|
40
|
+
|
|
41
|
+
const view = new ViewClass(mockBuffer);
|
|
42
|
+
expect(view).toBeDefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should cache generated classes by mapping key', () => {
|
|
46
|
+
const mapping = { http_status: 'status' };
|
|
47
|
+
|
|
48
|
+
const ViewClass1 = generateRemappedBufferViewClass(mapping);
|
|
49
|
+
const ViewClass2 = generateRemappedBufferViewClass(mapping);
|
|
50
|
+
|
|
51
|
+
// Should return cached class for same mapping
|
|
52
|
+
expect(ViewClass1).toBe(ViewClass2);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should generate different classes for different mappings', () => {
|
|
56
|
+
const mapping1 = { http_status: 'status' };
|
|
57
|
+
const mapping2 = { db_query: 'query' };
|
|
58
|
+
|
|
59
|
+
const ViewClass1 = generateRemappedBufferViewClass(mapping1);
|
|
60
|
+
const ViewClass2 = generateRemappedBufferViewClass(mapping2);
|
|
61
|
+
|
|
62
|
+
expect(ViewClass1).not.toBe(ViewClass2);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('pass-through properties', () => {
|
|
67
|
+
const createMockBuffer = (): AnySpanBuffer => {
|
|
68
|
+
const schema = defineLogSchema({ userId: S.category() });
|
|
69
|
+
const buffer = createBuffer(schema);
|
|
70
|
+
buffer._children = [createBuffer(schema), createBuffer(schema)];
|
|
71
|
+
buffer._overflow = createBuffer(schema);
|
|
72
|
+
buffer._writeIndex = 7;
|
|
73
|
+
|
|
74
|
+
return buffer;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
it('should pass through tree traversal properties unchanged', () => {
|
|
78
|
+
// Mapping direction: prefixed → unprefixed
|
|
79
|
+
const mapping = { http_status: 'status' };
|
|
80
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
81
|
+
const buffer = createMockBuffer();
|
|
82
|
+
const view = new ViewClass(buffer);
|
|
83
|
+
|
|
84
|
+
expect(view._children).toBe(buffer._children);
|
|
85
|
+
expect(view._overflow).toBe(buffer._overflow);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should pass through writeIndex', () => {
|
|
89
|
+
const mapping = { http_status: 'status' };
|
|
90
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
91
|
+
const buffer = createMockBuffer();
|
|
92
|
+
const view = new ViewClass(buffer);
|
|
93
|
+
|
|
94
|
+
expect(view._writeIndex).toBe(7);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should pass through system columns', () => {
|
|
98
|
+
const mapping = { http_status: 'status' };
|
|
99
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
100
|
+
const buffer = createMockBuffer();
|
|
101
|
+
const view = new ViewClass(buffer);
|
|
102
|
+
|
|
103
|
+
expect(view.timestamp).toBe(buffer.timestamp);
|
|
104
|
+
expect(view.entry_type).toBe(buffer.entry_type);
|
|
105
|
+
expect(view.message_values).toBe(buffer.message_values);
|
|
106
|
+
expect(view.message_nulls).toBe(buffer.message_nulls);
|
|
107
|
+
expect(view.line_values).toBe(buffer.line_values);
|
|
108
|
+
expect(view.line_nulls).toBe(buffer.line_nulls);
|
|
109
|
+
expect(view.error_code_values).toBe(buffer.error_code_values);
|
|
110
|
+
expect(view.error_code_nulls).toBe(buffer.error_code_nulls);
|
|
111
|
+
expect(view.exception_stack_values).toBe(buffer.exception_stack_values);
|
|
112
|
+
expect(view.exception_stack_nulls).toBe(buffer.exception_stack_nulls);
|
|
113
|
+
expect(view.ff_value_values).toBe(buffer.ff_value_values);
|
|
114
|
+
expect(view.ff_value_nulls).toBe(buffer.ff_value_nulls);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should pass through identity properties', () => {
|
|
118
|
+
const mapping = { http_status: 'status' };
|
|
119
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
120
|
+
const buffer = createMockBuffer();
|
|
121
|
+
const view = new ViewClass(buffer);
|
|
122
|
+
|
|
123
|
+
expect(view.trace_id).toBe(buffer.trace_id);
|
|
124
|
+
expect(view.thread_id).toBe(buffer.thread_id);
|
|
125
|
+
expect(view.span_id).toBe(buffer.span_id);
|
|
126
|
+
expect(view.parent_span_id).toBe(buffer.parent_span_id);
|
|
127
|
+
expect(view._identity).toBe(buffer._identity);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should pass through identity properties via _buffer', () => {
|
|
131
|
+
// The underlying buffer is accessible via _buffer
|
|
132
|
+
const mapping = { http_status: 'status' };
|
|
133
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
134
|
+
const buffer = createMockBuffer();
|
|
135
|
+
const view = new ViewClass(buffer);
|
|
136
|
+
|
|
137
|
+
// The underlying buffer is accessible via _buffer
|
|
138
|
+
expect(Reflect.get(view as object, '_buffer')).toBe(buffer);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('column remapping', () => {
|
|
143
|
+
it('should remap prefixed column names to unprefixed in getColumnIfAllocated', () => {
|
|
144
|
+
// Mapping: prefixed → unprefixed. View receives 'http_status', returns 'status' column.
|
|
145
|
+
const mapping = { http_status: 'status', http_method: 'method' };
|
|
146
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
147
|
+
|
|
148
|
+
const buffer = createBuffer(
|
|
149
|
+
defineLogSchema({
|
|
150
|
+
status: S.number(),
|
|
151
|
+
method: S.category(),
|
|
152
|
+
}),
|
|
153
|
+
);
|
|
154
|
+
buffer.status(0, 200);
|
|
155
|
+
buffer.status(1, 404);
|
|
156
|
+
buffer.status(2, 500);
|
|
157
|
+
buffer.method(0, 'GET');
|
|
158
|
+
buffer.method(1, 'POST');
|
|
159
|
+
buffer.method(2, 'DELETE');
|
|
160
|
+
buffer._writeIndex = 3;
|
|
161
|
+
|
|
162
|
+
const statusValues = buffer.getColumnIfAllocated('status');
|
|
163
|
+
const methodValues = buffer.getColumnIfAllocated('method');
|
|
164
|
+
|
|
165
|
+
const view = new ViewClass(buffer);
|
|
166
|
+
|
|
167
|
+
// Access via PREFIXED name, should return UNPREFIXED column
|
|
168
|
+
expect(view.getColumnIfAllocated('http_status')).toBe(statusValues);
|
|
169
|
+
expect(view.getColumnIfAllocated('http_method')).toBe(methodValues);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should remap prefixed column names to unprefixed in getNullsIfAllocated', () => {
|
|
173
|
+
const mapping = { http_status: 'status' };
|
|
174
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
175
|
+
|
|
176
|
+
const buffer = createBuffer(
|
|
177
|
+
defineLogSchema({
|
|
178
|
+
status: S.number(),
|
|
179
|
+
}),
|
|
180
|
+
);
|
|
181
|
+
buffer.status(0, 200);
|
|
182
|
+
buffer.status(1, 404);
|
|
183
|
+
buffer.status(2, 500);
|
|
184
|
+
buffer._writeIndex = 3;
|
|
185
|
+
|
|
186
|
+
const statusNulls = buffer.getNullsIfAllocated('status');
|
|
187
|
+
|
|
188
|
+
const view = new ViewClass(buffer);
|
|
189
|
+
|
|
190
|
+
// Access via PREFIXED name, should return UNPREFIXED null bitmap
|
|
191
|
+
expect(view.getNullsIfAllocated('http_status')).toBe(statusNulls);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should pass through unmapped column names', () => {
|
|
195
|
+
const mapping = { http_status: 'status' };
|
|
196
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
197
|
+
|
|
198
|
+
const buffer = createBuffer(
|
|
199
|
+
defineLogSchema({
|
|
200
|
+
userId: S.category(),
|
|
201
|
+
}),
|
|
202
|
+
);
|
|
203
|
+
buffer.userId(0, 'user1');
|
|
204
|
+
buffer.userId(1, 'user2');
|
|
205
|
+
buffer._writeIndex = 2;
|
|
206
|
+
|
|
207
|
+
const userIdValues = buffer.getColumnIfAllocated('userId');
|
|
208
|
+
|
|
209
|
+
const view = new ViewClass(buffer);
|
|
210
|
+
|
|
211
|
+
// Non-mapped columns pass through unchanged
|
|
212
|
+
expect(view.getColumnIfAllocated('userId')).toBe(userIdValues);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should return undefined for non-existent columns', () => {
|
|
216
|
+
const mapping = { http_status: 'status' };
|
|
217
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
218
|
+
|
|
219
|
+
const buffer = createBuffer(defineLogSchema({}));
|
|
220
|
+
|
|
221
|
+
const view = new ViewClass(buffer);
|
|
222
|
+
|
|
223
|
+
// Columns that don't exist return undefined (correct for Arrow conversion)
|
|
224
|
+
expect(view.getColumnIfAllocated('http_status')).toBeUndefined();
|
|
225
|
+
expect(view.getColumnIfAllocated('nonexistent')).toBeUndefined();
|
|
226
|
+
expect(view.getNullsIfAllocated('http_status')).toBeUndefined();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('integration with createPrefixMapping', () => {
|
|
231
|
+
it('should work with inverted schema-derived prefix mapping', () => {
|
|
232
|
+
const schema = defineLogSchema({
|
|
233
|
+
status: S.number(),
|
|
234
|
+
method: S.enum(['GET', 'POST', 'PUT', 'DELETE']),
|
|
235
|
+
url: S.text(),
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// createPrefixMapping returns unprefixed → prefixed
|
|
239
|
+
const prefixMapping = createPrefixMapping(schema, 'http');
|
|
240
|
+
|
|
241
|
+
expect(prefixMapping).toEqual({
|
|
242
|
+
status: 'http_status',
|
|
243
|
+
method: 'http_method',
|
|
244
|
+
url: 'http_url',
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// For RemappedBufferView, we need the inverse: prefixed → unprefixed
|
|
248
|
+
const invertedMapping: Record<string, string> = {};
|
|
249
|
+
for (const [unprefixed, prefixed] of Object.entries(prefixMapping)) {
|
|
250
|
+
invertedMapping[prefixed] = unprefixed;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const ViewClass = generateRemappedBufferViewClass(invertedMapping);
|
|
254
|
+
|
|
255
|
+
const buffer = createBuffer(
|
|
256
|
+
defineLogSchema({
|
|
257
|
+
status: S.number(),
|
|
258
|
+
method: S.category(),
|
|
259
|
+
}),
|
|
260
|
+
);
|
|
261
|
+
buffer.status(0, 200);
|
|
262
|
+
buffer.method(0, 'GET');
|
|
263
|
+
buffer._writeIndex = 1;
|
|
264
|
+
|
|
265
|
+
const statusValues = buffer.getColumnIfAllocated('status');
|
|
266
|
+
const methodValues = buffer.getColumnIfAllocated('method');
|
|
267
|
+
|
|
268
|
+
const view = new ViewClass(buffer);
|
|
269
|
+
|
|
270
|
+
// Prefixed access returns unprefixed columns
|
|
271
|
+
expect(view.getColumnIfAllocated('http_status')).toBe(statusValues);
|
|
272
|
+
expect(view.getColumnIfAllocated('http_method')).toBe(methodValues);
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe('nested tasks with library modules - 4+ levels deep', () => {
|
|
278
|
+
// Setup common schemas
|
|
279
|
+
const appSchema = defineLogSchema({
|
|
280
|
+
requestId: S.category(),
|
|
281
|
+
userId: S.category(),
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const httpSchema = defineLogSchema({
|
|
285
|
+
status: S.number(),
|
|
286
|
+
method: S.enum(['GET', 'POST', 'PUT', 'DELETE']),
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
const dbSchema = defineLogSchema({
|
|
290
|
+
query: S.text(),
|
|
291
|
+
table: S.category(),
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// cacheSchema used for prefix mapping tests
|
|
295
|
+
const cacheSchema = defineLogSchema({
|
|
296
|
+
key: S.category(),
|
|
297
|
+
hit: S.boolean(),
|
|
298
|
+
});
|
|
299
|
+
// Suppress unused variable warning - schema is used for demonstrating API patterns
|
|
300
|
+
void cacheSchema;
|
|
301
|
+
|
|
302
|
+
describe('without library module constructors', () => {
|
|
303
|
+
it('should handle 4-level nested tasks with correct buffer hierarchy', async () => {
|
|
304
|
+
// All using app schema directly (no library prefixing)
|
|
305
|
+
// Each op at each level gets its own factory to ensure separate logBindings
|
|
306
|
+
const opContext = defineOpContext({
|
|
307
|
+
logSchema: appSchema,
|
|
308
|
+
});
|
|
309
|
+
const { defineOp: defineOp1 } = opContext;
|
|
310
|
+
|
|
311
|
+
const buffers: { level: number; span_id: number; parent_span_id: number }[] = [];
|
|
312
|
+
|
|
313
|
+
const level4Op = defineOp1('level4-task', async (ctx) => {
|
|
314
|
+
buffers.push({
|
|
315
|
+
level: 4,
|
|
316
|
+
span_id: ctx.buffer.span_id,
|
|
317
|
+
parent_span_id: ctx.buffer.parent_span_id,
|
|
318
|
+
});
|
|
319
|
+
ctx.tag.requestId('req-level4');
|
|
320
|
+
return ctx.ok({ level: 4 });
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
const level3Op = defineOp1('level3-task', async (ctx) => {
|
|
324
|
+
buffers.push({
|
|
325
|
+
level: 3,
|
|
326
|
+
span_id: ctx.buffer.span_id,
|
|
327
|
+
parent_span_id: ctx.buffer.parent_span_id,
|
|
328
|
+
});
|
|
329
|
+
ctx.tag.requestId('req-level3');
|
|
330
|
+
|
|
331
|
+
const result = await ctx.span('nested-level4', level4Op);
|
|
332
|
+
return ctx.ok({ level: 3, child: result });
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const level2Op = defineOp1('level2-task', async (ctx) => {
|
|
336
|
+
buffers.push({
|
|
337
|
+
level: 2,
|
|
338
|
+
span_id: ctx.buffer.span_id,
|
|
339
|
+
parent_span_id: ctx.buffer.parent_span_id,
|
|
340
|
+
});
|
|
341
|
+
ctx.tag.userId('user-level2');
|
|
342
|
+
|
|
343
|
+
const result = await ctx.span('nested-level3', level3Op);
|
|
344
|
+
return ctx.ok({ level: 2, child: result });
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const level1Op = defineOp1('level1-task', async (ctx) => {
|
|
348
|
+
buffers.push({
|
|
349
|
+
level: 1,
|
|
350
|
+
span_id: ctx.buffer.span_id,
|
|
351
|
+
parent_span_id: ctx.buffer.parent_span_id,
|
|
352
|
+
});
|
|
353
|
+
ctx.tag.requestId('req-root').userId('user-root');
|
|
354
|
+
|
|
355
|
+
const result = await ctx.span('nested-level2', level2Op);
|
|
356
|
+
return ctx.ok({ level: 1, child: result });
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
const { trace } = new TestTracer(opContext, { ...createTestTracerOptions() });
|
|
360
|
+
|
|
361
|
+
const result = await trace('root', level1Op);
|
|
362
|
+
expect(result.success).toBe(true);
|
|
363
|
+
|
|
364
|
+
// Verify buffer hierarchy - all 4 levels executed
|
|
365
|
+
expect(buffers).toHaveLength(4);
|
|
366
|
+
expect(buffers[0].level).toBe(1);
|
|
367
|
+
expect(buffers[1].level).toBe(2);
|
|
368
|
+
expect(buffers[2].level).toBe(3);
|
|
369
|
+
expect(buffers[3].level).toBe(4);
|
|
370
|
+
|
|
371
|
+
// Root has no parent (parentSpanId = 0)
|
|
372
|
+
expect(buffers[0].parent_span_id).toBe(0);
|
|
373
|
+
|
|
374
|
+
// Verify all spanIds are non-zero
|
|
375
|
+
const spanIds = buffers.map((b) => b.span_id);
|
|
376
|
+
for (const spanId of spanIds) {
|
|
377
|
+
expect(spanId).toBeGreaterThan(0);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Note: In the new Op-centric API, span_id might be the same when ops share the same factory
|
|
381
|
+
// because span_id is incremented per-logBinding. This is correct behavior for the new API.
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('should propagate traceId through all nested levels', async () => {
|
|
385
|
+
const opContext = defineOpContext({
|
|
386
|
+
logSchema: appSchema,
|
|
387
|
+
});
|
|
388
|
+
const { defineOp } = opContext;
|
|
389
|
+
|
|
390
|
+
const traceIds: string[] = [];
|
|
391
|
+
|
|
392
|
+
const level4Op = defineOp('level4', async (ctx) => {
|
|
393
|
+
traceIds.push(ctx.buffer.trace_id);
|
|
394
|
+
return ctx.ok({});
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
const level3Op = defineOp('level3', async (ctx) => {
|
|
398
|
+
traceIds.push(ctx.buffer.trace_id);
|
|
399
|
+
return ctx.span('to-level4', level4Op);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
const level2Op = defineOp('level2', async (ctx) => {
|
|
403
|
+
traceIds.push(ctx.buffer.trace_id);
|
|
404
|
+
return ctx.span('to-level3', level3Op);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const level1Op = defineOp('level1', async (ctx) => {
|
|
408
|
+
traceIds.push(ctx.buffer.trace_id);
|
|
409
|
+
return ctx.span('to-level2', level2Op);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const { trace } = new TestTracer(opContext, { ...createTestTracerOptions() });
|
|
413
|
+
|
|
414
|
+
await trace('root', level1Op);
|
|
415
|
+
|
|
416
|
+
// All levels should have the same traceId
|
|
417
|
+
expect(traceIds).toHaveLength(4);
|
|
418
|
+
const rootTraceId = traceIds[0];
|
|
419
|
+
expect(rootTraceId).toMatch(/^[a-f0-9]{32}$/);
|
|
420
|
+
for (const tid of traceIds) {
|
|
421
|
+
expect(tid).toBe(rootTraceId);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
describe('with library module constructors (prefixed schemas)', () => {
|
|
427
|
+
it('should maintain correct prefix mappings at each level', () => {
|
|
428
|
+
// Use createPrefixMapping directly to verify prefix mapping logic
|
|
429
|
+
// DefinedLogSchema is a LogSchema instance at runtime - cast for type compatibility
|
|
430
|
+
const httpPrefixMapping = createPrefixMapping(httpSchema as LogSchema, 'http');
|
|
431
|
+
const dbPrefixMapping = createPrefixMapping(dbSchema as LogSchema, 'db');
|
|
432
|
+
|
|
433
|
+
// Verify prefix mappings
|
|
434
|
+
expect(httpPrefixMapping).toEqual({
|
|
435
|
+
status: 'http_status',
|
|
436
|
+
method: 'http_method',
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
expect(dbPrefixMapping).toEqual({
|
|
440
|
+
query: 'db_query',
|
|
441
|
+
table: 'db_table',
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// Verify original schemas still have their fields
|
|
445
|
+
expect(httpSchema._columnNames.includes('status')).toBe(true);
|
|
446
|
+
expect(httpSchema._columnNames.includes('method')).toBe(true);
|
|
447
|
+
|
|
448
|
+
expect(dbSchema._columnNames.includes('query')).toBe(true);
|
|
449
|
+
expect(dbSchema._columnNames.includes('table')).toBe(true);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
it('should create library module with proper op wrapper', async () => {
|
|
453
|
+
// Create a factory with prefixed schema to simulate library usage
|
|
454
|
+
// DefinedLogSchema is a LogSchema instance at runtime - cast for type compatibility
|
|
455
|
+
const prefixedHttpSchema = prefixSchema(httpSchema as LogSchema, 'http');
|
|
456
|
+
|
|
457
|
+
// prefixSchema returns { fields, prefix, mapping }
|
|
458
|
+
// We need to create a LogSchema from the prefixed fields
|
|
459
|
+
const prefixedLogSchema = defineLogSchema(prefixedHttpSchema.fields);
|
|
460
|
+
|
|
461
|
+
const opContext = defineOpContext({
|
|
462
|
+
logSchema: prefixedLogSchema,
|
|
463
|
+
});
|
|
464
|
+
const { defineOp } = opContext;
|
|
465
|
+
|
|
466
|
+
let opExecuted = false;
|
|
467
|
+
|
|
468
|
+
// Create an op through the factory
|
|
469
|
+
const httpOp = defineOp('http-request', async (ctx) => {
|
|
470
|
+
opExecuted = true;
|
|
471
|
+
// With prefixed schema, we write to prefixed columns directly
|
|
472
|
+
ctx.tag.http_status(200).http_method('GET');
|
|
473
|
+
return ctx.ok({ status: 200 });
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// Verify the op was created (Op is an object with _invoke method)
|
|
477
|
+
expect(typeof httpOp).toBe('object');
|
|
478
|
+
expect(httpOp).toBeDefined();
|
|
479
|
+
|
|
480
|
+
// Create a trace context and run the op via Tracer
|
|
481
|
+
const { trace } = new TestTracer(opContext, { ...createTestTracerOptions() });
|
|
482
|
+
const result = await trace('http-request', httpOp);
|
|
483
|
+
|
|
484
|
+
expect(opExecuted).toBe(true);
|
|
485
|
+
expect(result.success).toBe(true);
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
describe('buffer tree structure with RemappedBufferView', () => {
|
|
490
|
+
it('should allow tree traversal through RemappedBufferView instances', () => {
|
|
491
|
+
// Simulate what Arrow conversion would see
|
|
492
|
+
// Mapping: prefixed → unprefixed (view.getColumnIfAllocated('http_status') → buffer.getColumnIfAllocated('status'))
|
|
493
|
+
const mapping = { http_status: 'status' };
|
|
494
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
495
|
+
|
|
496
|
+
// Create child buffer mock
|
|
497
|
+
const childBuffer = createBuffer(
|
|
498
|
+
defineLogSchema({
|
|
499
|
+
status: S.number(),
|
|
500
|
+
}),
|
|
501
|
+
);
|
|
502
|
+
childBuffer.status(0, 404);
|
|
503
|
+
childBuffer._writeIndex = 1;
|
|
504
|
+
|
|
505
|
+
// Wrap child in RemappedBufferView
|
|
506
|
+
const childView = new ViewClass(childBuffer);
|
|
507
|
+
|
|
508
|
+
// Create parent buffer with child as RemappedBufferView
|
|
509
|
+
const parentBuffer = createBuffer(defineLogSchema({}));
|
|
510
|
+
(parentBuffer as AnySpanBuffer)._children = [childView];
|
|
511
|
+
parentBuffer._writeIndex = 1;
|
|
512
|
+
|
|
513
|
+
// Simulate tree traversal (as Arrow conversion would do)
|
|
514
|
+
expect(parentBuffer._children).toHaveLength(1);
|
|
515
|
+
|
|
516
|
+
const child = parentBuffer._children[0];
|
|
517
|
+
|
|
518
|
+
// Access via prefixed name through the view
|
|
519
|
+
const childStatus = requireFloat64Array(child.getColumnIfAllocated('http_status'), 'child http_status');
|
|
520
|
+
expect(childStatus[0]).toBe(404);
|
|
521
|
+
|
|
522
|
+
// System columns pass through unchanged
|
|
523
|
+
expect(child.span_id).toBe(childBuffer.span_id);
|
|
524
|
+
expect(child.parent_span_id).toBe(childBuffer.parent_span_id);
|
|
525
|
+
expect(child.trace_id).toBe(childBuffer.trace_id);
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
it('should handle nested RemappedBufferView in children array', () => {
|
|
529
|
+
// Different prefixes for different libraries
|
|
530
|
+
// Mapping: prefixed → unprefixed
|
|
531
|
+
const httpMapping = { http_status: 'status' };
|
|
532
|
+
const dbMapping = { db_query: 'query' };
|
|
533
|
+
|
|
534
|
+
const HttpViewClass = generateRemappedBufferViewClass(httpMapping);
|
|
535
|
+
const DbViewClass = generateRemappedBufferViewClass(dbMapping);
|
|
536
|
+
|
|
537
|
+
// Grandchild: DB library buffer
|
|
538
|
+
const grandchildBuffer = createBuffer(
|
|
539
|
+
defineLogSchema({
|
|
540
|
+
query: S.text(),
|
|
541
|
+
}),
|
|
542
|
+
);
|
|
543
|
+
grandchildBuffer.query(0, 'SELECT * FROM users');
|
|
544
|
+
grandchildBuffer._writeIndex = 1;
|
|
545
|
+
|
|
546
|
+
const grandchildView = new DbViewClass(grandchildBuffer);
|
|
547
|
+
|
|
548
|
+
// Child: HTTP library buffer with DB grandchild
|
|
549
|
+
const childBuffer = createBuffer(
|
|
550
|
+
defineLogSchema({
|
|
551
|
+
status: S.number(),
|
|
552
|
+
}),
|
|
553
|
+
);
|
|
554
|
+
(childBuffer as AnySpanBuffer)._children = [grandchildView];
|
|
555
|
+
childBuffer.status(0, 200);
|
|
556
|
+
childBuffer._writeIndex = 1;
|
|
557
|
+
|
|
558
|
+
const childView = new HttpViewClass(childBuffer);
|
|
559
|
+
|
|
560
|
+
// Root: App buffer with HTTP child
|
|
561
|
+
const rootBuffer = createBuffer(defineLogSchema({}));
|
|
562
|
+
(rootBuffer as AnySpanBuffer)._children = [childView];
|
|
563
|
+
rootBuffer._writeIndex = 1;
|
|
564
|
+
|
|
565
|
+
// Traverse the tree
|
|
566
|
+
const httpChild = rootBuffer._children[0];
|
|
567
|
+
const dbGrandchild = httpChild._children[0];
|
|
568
|
+
|
|
569
|
+
// Each level returns correct prefixed columns
|
|
570
|
+
const httpStatus = requireFloat64Array(httpChild.getColumnIfAllocated('http_status'), 'http child status');
|
|
571
|
+
expect(httpStatus[0]).toBe(200);
|
|
572
|
+
expect(dbGrandchild.getColumnIfAllocated('db_query')).toEqual(['SELECT * FROM users']);
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
describe('edge cases', () => {
|
|
577
|
+
it('should handle empty prefix mapping', () => {
|
|
578
|
+
const ViewClass = generateRemappedBufferViewClass({});
|
|
579
|
+
|
|
580
|
+
const buffer = createBuffer(
|
|
581
|
+
defineLogSchema({
|
|
582
|
+
status: S.number(),
|
|
583
|
+
}),
|
|
584
|
+
);
|
|
585
|
+
buffer.status(0, 200);
|
|
586
|
+
buffer._writeIndex = 1;
|
|
587
|
+
|
|
588
|
+
const view = new ViewClass(buffer);
|
|
589
|
+
|
|
590
|
+
// No remapping, pass through directly
|
|
591
|
+
const statusCol = requireFloat64Array(view.getColumnIfAllocated('status'), 'status');
|
|
592
|
+
expect(statusCol[0]).toBe(200);
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
it('should handle special characters in column names', () => {
|
|
596
|
+
// Mapping: prefixed → unprefixed
|
|
597
|
+
const mapping = { prefix_field_with_underscores: 'field_with_underscores' };
|
|
598
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
599
|
+
|
|
600
|
+
const buffer = createBuffer(
|
|
601
|
+
defineLogSchema({
|
|
602
|
+
field_with_underscores: S.category(),
|
|
603
|
+
}),
|
|
604
|
+
);
|
|
605
|
+
buffer.field_with_underscores(0, 'test');
|
|
606
|
+
buffer._writeIndex = 1;
|
|
607
|
+
|
|
608
|
+
const view = new ViewClass(buffer);
|
|
609
|
+
|
|
610
|
+
expect(view.getColumnIfAllocated('prefix_field_with_underscores')).toEqual(['test']);
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
it('should handle large number of columns in mapping', () => {
|
|
614
|
+
// Mapping: prefixed → unprefixed
|
|
615
|
+
const mapping: Record<string, string> = {};
|
|
616
|
+
for (let i = 0; i < 100; i++) {
|
|
617
|
+
mapping[`prefix_field${i}`] = `field${i}`;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
const ViewClass = generateRemappedBufferViewClass(mapping);
|
|
621
|
+
|
|
622
|
+
const buffer = createBuffer(
|
|
623
|
+
defineLogSchema({
|
|
624
|
+
field50: S.category(),
|
|
625
|
+
}),
|
|
626
|
+
);
|
|
627
|
+
buffer.field50(0, 'value50');
|
|
628
|
+
buffer._writeIndex = 1;
|
|
629
|
+
|
|
630
|
+
const view = new ViewClass(buffer);
|
|
631
|
+
|
|
632
|
+
expect(view.getColumnIfAllocated('prefix_field50')).toEqual(['value50']);
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
});
|