@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,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WasmBufferStrategy - Buffer strategy using WASM memory with freelist allocation.
|
|
3
|
+
*
|
|
4
|
+
* Uses WebAssembly memory for numeric columns with O(1) freelist allocation/deallocation.
|
|
5
|
+
* String columns remain in JavaScript.
|
|
6
|
+
*
|
|
7
|
+
* Memory characteristics:
|
|
8
|
+
* - Numeric data lives in contiguous WASM memory (better cache locality)
|
|
9
|
+
* - Freelist enables O(1) memory reuse across traces
|
|
10
|
+
* - Explicit release required (not GC-managed)
|
|
11
|
+
* - Arrow conversion reads from WASM memory views
|
|
12
|
+
*
|
|
13
|
+
* @module WasmBufferStrategy
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { Table } from '@uwdata/flechette';
|
|
17
|
+
import type { BufferStrategy } from '../bufferStrategy.js';
|
|
18
|
+
import { convertSpanTreeToArrowTable } from '../convertToArrow.js';
|
|
19
|
+
import type { OpMetadata } from '../opContext/opTypes.js';
|
|
20
|
+
import type { LogSchema } from '../schema/LogSchema.js';
|
|
21
|
+
import { EMPTY_SCOPE } from '../spanBuffer.js';
|
|
22
|
+
import type { ITraceRoot } from '../traceRoot.js';
|
|
23
|
+
import type { AnySpanBuffer, SpanBuffer } from '../types.js';
|
|
24
|
+
import { createWasmAllocator, type WasmAllocator, type WasmAllocatorOptions } from './wasmAllocator.js';
|
|
25
|
+
import {
|
|
26
|
+
createWasmChildSpanBuffer,
|
|
27
|
+
createWasmOverflowBuffer,
|
|
28
|
+
createWasmSpanBuffer,
|
|
29
|
+
isWasmSpanBufferInstance,
|
|
30
|
+
type WasmSpanBufferInstance,
|
|
31
|
+
} from './wasmSpanBuffer.js';
|
|
32
|
+
|
|
33
|
+
function requireWasmSpanBuffer(buffer: AnySpanBuffer): WasmSpanBufferInstance {
|
|
34
|
+
if (!isWasmSpanBufferInstance(buffer)) {
|
|
35
|
+
throw new Error('Expected WASM-backed span buffer');
|
|
36
|
+
}
|
|
37
|
+
return buffer;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Options for WasmBufferStrategy.
|
|
42
|
+
*/
|
|
43
|
+
export interface WasmBufferStrategyOptions extends WasmAllocatorOptions {
|
|
44
|
+
/** Pre-created allocator. If not provided, one will be created. */
|
|
45
|
+
allocator?: WasmAllocator;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type WasmAllocatorStats = {
|
|
49
|
+
allocCount: number;
|
|
50
|
+
freeCount: number;
|
|
51
|
+
bumpPtr: number;
|
|
52
|
+
capacity: number;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* WasmBufferStrategy - Buffer strategy using WASM memory with freelist allocation.
|
|
57
|
+
*
|
|
58
|
+
* This strategy is optimized for high-throughput scenarios:
|
|
59
|
+
* - Numeric columns allocated from WASM freelists (O(1) alloc/free)
|
|
60
|
+
* - Better cache locality from contiguous WASM memory
|
|
61
|
+
* - Explicit memory management via releaseBuffer()
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const strategy = await WasmBufferStrategy.create<MySchema>();
|
|
66
|
+
* const tracer = new StdioTracer(binding, { bufferStrategy: strategy });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export class WasmBufferStrategy<T extends LogSchema = LogSchema> implements BufferStrategy<T> {
|
|
70
|
+
/**
|
|
71
|
+
* The WASM allocator instance.
|
|
72
|
+
* Shared across all buffers created by this strategy.
|
|
73
|
+
*/
|
|
74
|
+
readonly allocator: WasmAllocator;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Private constructor - use static create() method.
|
|
78
|
+
*/
|
|
79
|
+
private constructor(allocator: WasmAllocator) {
|
|
80
|
+
this.allocator = allocator;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Create a WasmBufferStrategy instance.
|
|
85
|
+
*
|
|
86
|
+
* Async because WASM module loading may be asynchronous.
|
|
87
|
+
*
|
|
88
|
+
* @param options - Configuration options
|
|
89
|
+
* @returns Promise<WasmBufferStrategy>
|
|
90
|
+
*/
|
|
91
|
+
static async create<T extends LogSchema = LogSchema>(
|
|
92
|
+
options?: WasmBufferStrategyOptions,
|
|
93
|
+
): Promise<WasmBufferStrategy<T>> {
|
|
94
|
+
const allocator = options?.allocator ?? (await createWasmAllocator(options));
|
|
95
|
+
return new WasmBufferStrategy<T>(allocator);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
createSpanBuffer(schema: T, traceRoot: ITraceRoot, opMetadata: OpMetadata, capacity?: number): SpanBuffer<T> {
|
|
99
|
+
const effectiveCapacity = capacity ?? this.allocator.capacity;
|
|
100
|
+
|
|
101
|
+
// Create WASM buffer
|
|
102
|
+
const wasmBuffer = createWasmSpanBuffer(
|
|
103
|
+
schema,
|
|
104
|
+
{
|
|
105
|
+
allocator: this.allocator,
|
|
106
|
+
capacity: effectiveCapacity,
|
|
107
|
+
trace_id: traceRoot.trace_id,
|
|
108
|
+
// thread_id and span_id come from WASM (global header and allocator respectively)
|
|
109
|
+
thread_id: 0n, // Will be read from WASM header
|
|
110
|
+
span_id: 0, // Will be assigned by WASM allocator
|
|
111
|
+
},
|
|
112
|
+
traceRoot, // _traceRoot
|
|
113
|
+
EMPTY_SCOPE, // _scopeValues
|
|
114
|
+
opMetadata, // _opMetadata
|
|
115
|
+
opMetadata, // _callsiteMetadata (same as opMetadata for root)
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- generated WASM buffers implement the SpanBuffer contract for the same schema.
|
|
119
|
+
return wasmBuffer as unknown as SpanBuffer<T>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
createChildSpanBuffer(
|
|
123
|
+
parentBuffer: SpanBuffer<T>,
|
|
124
|
+
callsiteMetadata: OpMetadata,
|
|
125
|
+
opMetadata: OpMetadata,
|
|
126
|
+
capacity?: number,
|
|
127
|
+
schema?: T,
|
|
128
|
+
): SpanBuffer<T> {
|
|
129
|
+
const wasmParent = requireWasmSpanBuffer(parentBuffer);
|
|
130
|
+
const effectiveCapacity = capacity ?? wasmParent._capacity;
|
|
131
|
+
|
|
132
|
+
// Use provided schema (for cross-library calls) or parent's schema
|
|
133
|
+
const childSchema = schema ?? (parentBuffer._logSchema as T);
|
|
134
|
+
|
|
135
|
+
const child = createWasmChildSpanBuffer(
|
|
136
|
+
wasmParent,
|
|
137
|
+
{
|
|
138
|
+
allocator: this.allocator,
|
|
139
|
+
capacity: effectiveCapacity,
|
|
140
|
+
thread_id: 0n, // Will be read from WASM header
|
|
141
|
+
span_id: 0, // Will be assigned by WASM allocator
|
|
142
|
+
schema: childSchema, // Pass schema for correct buffer class
|
|
143
|
+
},
|
|
144
|
+
parentBuffer._traceRoot, // _traceRoot (inherit from parent)
|
|
145
|
+
parentBuffer._scopeValues, // _scopeValues (inherit from parent)
|
|
146
|
+
opMetadata, // _opMetadata
|
|
147
|
+
callsiteMetadata, // _callsiteMetadata
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- child buffers preserve the requested schema contract.
|
|
151
|
+
return child as unknown as SpanBuffer<T>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
createOverflowBuffer(buffer: SpanBuffer<T>): SpanBuffer<T> {
|
|
155
|
+
const wasmBuffer = requireWasmSpanBuffer(buffer);
|
|
156
|
+
const overflow = createWasmOverflowBuffer(
|
|
157
|
+
wasmBuffer,
|
|
158
|
+
buffer._traceRoot, // _traceRoot (same as original)
|
|
159
|
+
buffer._scopeValues, // _scopeValues (same as original)
|
|
160
|
+
buffer._opMetadata, // _opMetadata (same as original)
|
|
161
|
+
buffer._callsiteMetadata ?? buffer._opMetadata, // _callsiteMetadata (same as original, fallback to opMetadata)
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- overflow buffers are schema-compatible continuations of the same span.
|
|
165
|
+
return overflow as unknown as SpanBuffer<T>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
toArrowTable(buffer: AnySpanBuffer): Table {
|
|
169
|
+
// Uses existing tree conversion with shared dictionaries
|
|
170
|
+
return convertSpanTreeToArrowTable(buffer);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
releaseBuffer(buffer: AnySpanBuffer): void {
|
|
174
|
+
// Walk the span tree and free all WASM memory
|
|
175
|
+
this.freeSpanTree(requireWasmSpanBuffer(buffer));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Recursively free all WASM memory for a span tree.
|
|
180
|
+
*/
|
|
181
|
+
private freeSpanTree(buffer: WasmSpanBufferInstance): void {
|
|
182
|
+
// Free children first (depth-first)
|
|
183
|
+
if (buffer._children) {
|
|
184
|
+
for (const child of buffer._children) {
|
|
185
|
+
this.freeSpanTree(child);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Free overflow chain
|
|
190
|
+
if (buffer._overflow) {
|
|
191
|
+
this.freeSpanTree(buffer._overflow);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Free this buffer's WASM memory
|
|
195
|
+
if (typeof buffer.free === 'function') {
|
|
196
|
+
buffer.free();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Reset the allocator (for testing/benchmarking).
|
|
202
|
+
* WARNING: This invalidates ALL buffers created by this strategy.
|
|
203
|
+
*/
|
|
204
|
+
reset(): void {
|
|
205
|
+
this.allocator.reset();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get allocator statistics for debugging/monitoring.
|
|
210
|
+
*/
|
|
211
|
+
getStats(): WasmAllocatorStats {
|
|
212
|
+
return {
|
|
213
|
+
allocCount: this.allocator.getAllocCount(),
|
|
214
|
+
freeCount: this.allocator.getFreeCount(),
|
|
215
|
+
bumpPtr: this.allocator.getBumpPtr(),
|
|
216
|
+
capacity: this.allocator.capacity,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for WasmBufferStrategy
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { afterEach, beforeAll, describe, expect, it } from 'bun:test';
|
|
6
|
+
import { createOpMetadata } from '../../opContext/defineOp.js';
|
|
7
|
+
import { S } from '../../schema/builder.js';
|
|
8
|
+
import { defineLogSchema } from '../../schema/defineLogSchema.js';
|
|
9
|
+
import type { TracerLifecycleHooks } from '../../traceRoot.js';
|
|
10
|
+
import { WasmBufferStrategy } from '../WasmBufferStrategy.js';
|
|
11
|
+
import { createWasmAllocator } from '../wasmAllocator.js';
|
|
12
|
+
import { createWasmTraceRoot } from '../wasmTraceRoot.js';
|
|
13
|
+
|
|
14
|
+
describe('WasmBufferStrategy', () => {
|
|
15
|
+
// Simple schema for testing
|
|
16
|
+
const testSchema = defineLogSchema({
|
|
17
|
+
userId: S.category(),
|
|
18
|
+
latency: S.number(),
|
|
19
|
+
success: S.boolean(),
|
|
20
|
+
operation: S.enum(['CREATE', 'READ', 'UPDATE', 'DELETE']),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Test metadata for buffer creation
|
|
24
|
+
const testMetadata = createOpMetadata('test-op', 'test-package', 'test.ts', 'abc123', 1);
|
|
25
|
+
|
|
26
|
+
// Mock tracer lifecycle hooks for WasmTraceRoot
|
|
27
|
+
let strategy: WasmBufferStrategy<typeof testSchema>;
|
|
28
|
+
let mockTracer: TracerLifecycleHooks;
|
|
29
|
+
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
strategy = await WasmBufferStrategy.create<typeof testSchema>({
|
|
32
|
+
capacity: 64,
|
|
33
|
+
initialPages: 16, // 1MB
|
|
34
|
+
maxPages: 16,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Mock tracer lifecycle hooks for WasmTraceRoot
|
|
38
|
+
// Must be created after strategy so we can reference it
|
|
39
|
+
mockTracer = {
|
|
40
|
+
onTraceStart: () => {},
|
|
41
|
+
onTraceEnd: () => {},
|
|
42
|
+
onSpanStart: () => {},
|
|
43
|
+
onSpanEnd: () => {},
|
|
44
|
+
onStatsWillResetFor: () => {},
|
|
45
|
+
bufferStrategy: strategy,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
// Reset allocator between tests to ensure clean state
|
|
51
|
+
strategy.reset();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('create()', () => {
|
|
55
|
+
it('creates a strategy with default options', async () => {
|
|
56
|
+
const s = await WasmBufferStrategy.create();
|
|
57
|
+
expect(s).toBeDefined();
|
|
58
|
+
expect(s.allocator).toBeDefined();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('creates a strategy with custom options', async () => {
|
|
62
|
+
const s = await WasmBufferStrategy.create({
|
|
63
|
+
capacity: 128,
|
|
64
|
+
initialPages: 32,
|
|
65
|
+
});
|
|
66
|
+
expect(s).toBeDefined();
|
|
67
|
+
expect(s.allocator.capacity).toBe(128);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('accepts a pre-created allocator', async () => {
|
|
71
|
+
const allocator = await createWasmAllocator({ capacity: 32 });
|
|
72
|
+
const s = await WasmBufferStrategy.create({ allocator });
|
|
73
|
+
expect(s.allocator).toBe(allocator);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('createSpanBuffer()', () => {
|
|
78
|
+
it('creates a root span buffer', async () => {
|
|
79
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
80
|
+
|
|
81
|
+
const buffer = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
82
|
+
// Caller must set span name via message() - simulating writeSpanStart behavior
|
|
83
|
+
buffer.message(0, 'test-span');
|
|
84
|
+
|
|
85
|
+
expect(buffer).toBeDefined();
|
|
86
|
+
expect(buffer._capacity).toBe(64);
|
|
87
|
+
expect(buffer.message_values[0]).toBe('test-span');
|
|
88
|
+
expect(String(buffer.trace_id)).toBe('test-trace-id');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('creates buffer with custom capacity', async () => {
|
|
92
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
93
|
+
|
|
94
|
+
const buffer = strategy.createSpanBuffer(
|
|
95
|
+
testSchema,
|
|
96
|
+
traceRoot,
|
|
97
|
+
testMetadata,
|
|
98
|
+
32, // Custom capacity
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(buffer._capacity).toBe(32);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('allocates WASM memory for buffer', async () => {
|
|
105
|
+
const statsBefore = strategy.getStats();
|
|
106
|
+
|
|
107
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
108
|
+
strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
109
|
+
|
|
110
|
+
const statsAfter = strategy.getStats();
|
|
111
|
+
expect(statsAfter.allocCount).toBeGreaterThan(statsBefore.allocCount);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('createChildSpanBuffer()', () => {
|
|
116
|
+
it('creates a child span linked to parent', async () => {
|
|
117
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
118
|
+
|
|
119
|
+
const parent = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
120
|
+
|
|
121
|
+
const child = strategy.createChildSpanBuffer(parent, testMetadata, testMetadata);
|
|
122
|
+
// Caller must set span name via message() - simulating writeSpanStart behavior
|
|
123
|
+
child.message(0, 'child-span');
|
|
124
|
+
|
|
125
|
+
expect(child).toBeDefined();
|
|
126
|
+
expect(child.message_values[0]).toBe('child-span');
|
|
127
|
+
expect(child.trace_id).toBe(parent.trace_id);
|
|
128
|
+
expect(child.parent_span_id).toBe(parent.span_id);
|
|
129
|
+
// Note: parent._children is NOT populated by the strategy - SpanContext handles that.
|
|
130
|
+
// The strategy only sets up the parent-child relationship via child._parent.
|
|
131
|
+
expect(child._parent).toBe(parent);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('inherits capacity from parent by default', async () => {
|
|
135
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
136
|
+
|
|
137
|
+
const parent = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
138
|
+
|
|
139
|
+
const child = strategy.createChildSpanBuffer(parent, testMetadata, testMetadata);
|
|
140
|
+
|
|
141
|
+
expect(child._capacity).toBe(parent._capacity);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('allows custom capacity for child', async () => {
|
|
145
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
146
|
+
|
|
147
|
+
const parent = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
148
|
+
|
|
149
|
+
const child = strategy.createChildSpanBuffer(
|
|
150
|
+
parent,
|
|
151
|
+
testMetadata,
|
|
152
|
+
testMetadata,
|
|
153
|
+
32, // Custom capacity
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
expect(child._capacity).toBe(32);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('createOverflowBuffer()', () => {
|
|
161
|
+
it('creates overflow buffer linked to parent', async () => {
|
|
162
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
163
|
+
|
|
164
|
+
const buffer = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
165
|
+
|
|
166
|
+
const overflow = strategy.createOverflowBuffer(buffer);
|
|
167
|
+
|
|
168
|
+
expect(overflow).toBeDefined();
|
|
169
|
+
expect(overflow._capacity).toBe(buffer._capacity);
|
|
170
|
+
// Note: Currently overflow allocates its own identity block with new span_id
|
|
171
|
+
// TODO: Overflow should share identity with parent buffer
|
|
172
|
+
expect(overflow.trace_id).toBe(buffer.trace_id);
|
|
173
|
+
expect(buffer._overflow).toBe(overflow);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe('releaseBuffer()', () => {
|
|
178
|
+
it('frees WASM memory for a single buffer', async () => {
|
|
179
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
180
|
+
|
|
181
|
+
const buffer = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
182
|
+
|
|
183
|
+
const statsBefore = strategy.getStats();
|
|
184
|
+
strategy.releaseBuffer(buffer);
|
|
185
|
+
const statsAfter = strategy.getStats();
|
|
186
|
+
|
|
187
|
+
expect(statsAfter.freeCount).toBeGreaterThan(statsBefore.freeCount);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('frees entire span tree recursively', async () => {
|
|
191
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
192
|
+
|
|
193
|
+
const parent = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
194
|
+
|
|
195
|
+
strategy.createChildSpanBuffer(parent, testMetadata, testMetadata);
|
|
196
|
+
|
|
197
|
+
strategy.createChildSpanBuffer(parent, testMetadata, testMetadata);
|
|
198
|
+
|
|
199
|
+
const statsBefore = strategy.getStats();
|
|
200
|
+
strategy.releaseBuffer(parent);
|
|
201
|
+
const statsAfter = strategy.getStats();
|
|
202
|
+
|
|
203
|
+
// Should have freed 3 buffers worth of memory
|
|
204
|
+
expect(statsAfter.freeCount).toBeGreaterThan(statsBefore.freeCount);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('frees overflow chain', async () => {
|
|
208
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
209
|
+
|
|
210
|
+
const buffer = strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
211
|
+
|
|
212
|
+
strategy.createOverflowBuffer(buffer);
|
|
213
|
+
|
|
214
|
+
const statsBefore = strategy.getStats();
|
|
215
|
+
strategy.releaseBuffer(buffer);
|
|
216
|
+
const statsAfter = strategy.getStats();
|
|
217
|
+
|
|
218
|
+
// Should have freed both buffers
|
|
219
|
+
expect(statsAfter.freeCount).toBeGreaterThan(statsBefore.freeCount);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('getStats()', () => {
|
|
224
|
+
it('returns allocator statistics', async () => {
|
|
225
|
+
const stats = strategy.getStats();
|
|
226
|
+
|
|
227
|
+
expect(stats).toHaveProperty('allocCount');
|
|
228
|
+
expect(stats).toHaveProperty('freeCount');
|
|
229
|
+
expect(stats).toHaveProperty('bumpPtr');
|
|
230
|
+
expect(stats).toHaveProperty('capacity');
|
|
231
|
+
expect(typeof stats.allocCount).toBe('number');
|
|
232
|
+
expect(typeof stats.freeCount).toBe('number');
|
|
233
|
+
expect(typeof stats.bumpPtr).toBe('number');
|
|
234
|
+
expect(typeof stats.capacity).toBe('number');
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
describe('reset()', () => {
|
|
239
|
+
it('resets allocator state', async () => {
|
|
240
|
+
const traceRoot = createWasmTraceRoot(strategy.allocator, 'test-trace-id', mockTracer);
|
|
241
|
+
|
|
242
|
+
// Create some buffers
|
|
243
|
+
strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
244
|
+
strategy.createSpanBuffer(testSchema, traceRoot, testMetadata);
|
|
245
|
+
|
|
246
|
+
const statsBeforeReset = strategy.getStats();
|
|
247
|
+
expect(statsBeforeReset.allocCount).toBeGreaterThan(0);
|
|
248
|
+
|
|
249
|
+
strategy.reset();
|
|
250
|
+
|
|
251
|
+
const statsAfterReset = strategy.getStats();
|
|
252
|
+
expect(statsAfterReset.allocCount).toBe(0);
|
|
253
|
+
expect(statsAfterReset.freeCount).toBe(0);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
});
|