@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
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# lmao
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build lmao` to build the library.
|
|
8
|
+
|
|
9
|
+
## Trace Testing
|
|
10
|
+
|
|
11
|
+
LMAO provides a trace-testing system where each test creates queryable trace spans. Instead of testing return values
|
|
12
|
+
directly, you execute code that emits trace facts and assert on WHAT happened.
|
|
13
|
+
|
|
14
|
+
### Quick Start (bun:test)
|
|
15
|
+
|
|
16
|
+
1. Create a preload file:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
// test-trace-setup.ts (preload)
|
|
20
|
+
import * as bunTest from 'bun:test';
|
|
21
|
+
import { mock } from 'bun:test';
|
|
22
|
+
import { createBunTestMock, initTraceTestRun } from '@smoothbricks/lmao/testing/bun';
|
|
23
|
+
import { myOpContext } from './src/opContext.js';
|
|
24
|
+
|
|
25
|
+
initTraceTestRun(myOpContext, { sqlite: { dbPath: '.trace-results.db' } });
|
|
26
|
+
mock.module('bun:test', () => createBunTestMock(bunTest));
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`mock.module` MUST be called from the preload file itself — bun only intercepts subsequent imports when the mock is
|
|
30
|
+
registered from the entry module context.
|
|
31
|
+
|
|
32
|
+
2. Add to `bunfig.toml`:
|
|
33
|
+
|
|
34
|
+
```toml
|
|
35
|
+
[test]
|
|
36
|
+
preload = ["./test-trace-setup.ts"]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
3. Write tests — import from `bun:test` as normal, `mock.module` intercepts transparently:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { describe, it, expect } from 'bun:test';
|
|
43
|
+
import { useTestSpan } from '@smoothbricks/lmao/testing/bun';
|
|
44
|
+
import { querySpan, findSpan } from '@smoothbricks/lmao/testing';
|
|
45
|
+
|
|
46
|
+
describe('Order Processing', () => {
|
|
47
|
+
it('validates and saves order', async () => {
|
|
48
|
+
const ctx = useTestSpan();
|
|
49
|
+
|
|
50
|
+
await ctx.span('processOrder', async (child) => {
|
|
51
|
+
child.tag.orderId('123');
|
|
52
|
+
await child.span('validate', async (v) => v.ok(true));
|
|
53
|
+
await child.span('save', async (s) => s.ok({ id: 'order-123' }));
|
|
54
|
+
return child.ok({ status: 'saved' });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Query the trace tree
|
|
58
|
+
const q = querySpan(ctx.buffer);
|
|
59
|
+
expect(q.names()).toEqual(['processOrder', 'validate', 'save']);
|
|
60
|
+
expect(q.find('validate')).toBeDefined();
|
|
61
|
+
expect(findSpan(ctx.buffer, 'save')).toBeDefined();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Note: `describe`/`it`/`expect` are imported from `bun:test` as normal — `mock.module` intercepts transparently. Only
|
|
67
|
+
`useTestSpan` comes from `@smoothbricks/lmao/testing/bun`.
|
|
68
|
+
|
|
69
|
+
### Quick Start (vitest)
|
|
70
|
+
|
|
71
|
+
1. Configure vitest:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// vitest.config.ts
|
|
75
|
+
export default defineConfig({
|
|
76
|
+
test: { setupFiles: ['./test-setup.ts'] },
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
2. Create the setup file with `vi.mock` for transparent interception:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// test-setup.ts
|
|
84
|
+
import { vi } from 'vitest';
|
|
85
|
+
import { createNodeSQLiteDatabase } from '@smoothbricks/lmao/sqlite/node';
|
|
86
|
+
import { myOpContext } from './src/opContext.js';
|
|
87
|
+
|
|
88
|
+
vi.mock('vitest', async (importOriginal) => {
|
|
89
|
+
const [mod, { createVitestMock }] = await Promise.all([
|
|
90
|
+
importOriginal(),
|
|
91
|
+
import('@smoothbricks/lmao/testing/vitest'),
|
|
92
|
+
]);
|
|
93
|
+
return createVitestMock(mod as Record<string, unknown>);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
import { initTraceTestRun } from '@smoothbricks/lmao/testing/vitest';
|
|
97
|
+
initTraceTestRun(myOpContext, {
|
|
98
|
+
sqlite: { dbPath: '.trace-results.db', createDatabase: createNodeSQLiteDatabase },
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
3. Write tests — import from `vitest` as normal, `vi.mock` intercepts transparently:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { describe, it, expect } from 'vitest';
|
|
106
|
+
import { useTestSpan } from '@smoothbricks/lmao/testing/vitest';
|
|
107
|
+
import { querySpan, findSpan } from '@smoothbricks/lmao/testing';
|
|
108
|
+
|
|
109
|
+
describe('Order Processing', () => {
|
|
110
|
+
it('validates and saves order', async () => {
|
|
111
|
+
const ctx = useTestSpan();
|
|
112
|
+
|
|
113
|
+
await ctx.span('processOrder', async (child) => {
|
|
114
|
+
child.tag.orderId('123');
|
|
115
|
+
await child.span('validate', async (v) => v.ok(true));
|
|
116
|
+
return child.ok({ status: 'saved' });
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const q = querySpan(ctx.buffer);
|
|
120
|
+
expect(q.names()).toContain('validate');
|
|
121
|
+
expect(findSpan(ctx.buffer, 'processOrder')).toBeDefined();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Both bun:test and vitest use the same transparent interception pattern — tests import from their native test module as
|
|
127
|
+
normal. Only `useTestSpan` (for accessing the it-local trace root) comes from the lmao testing module.
|
|
128
|
+
|
|
129
|
+
#### Cloudflare Worker + Vitest notes
|
|
130
|
+
|
|
131
|
+
- Keep the setup file wiring-only: call `setupVitestTestSuiteTracing(...)` and keep the `vi.mock('vitest', ...)` bridge
|
|
132
|
+
with `createVitestMock(...)`.
|
|
133
|
+
- Configure SQLite sink in the package-local vitest tracer module (not in test files) so worker suites flush to a
|
|
134
|
+
worker-appropriate SQLite target (for example `d1://TRACE_RESULTS`).
|
|
135
|
+
- Debug logging is harness-owned and toggled by `LMAO_VITEST_DEBUG`.
|
|
136
|
+
- Verbose trace replay is toggled by `LMAO_TEST_TRACE_VERBOSE` (prints spans to stdout and still flushes SQLite).
|
|
137
|
+
- In Worker tests, forward the debug env in `vitest.config.ts` via `define`, for example
|
|
138
|
+
`globalThis.__LMAO_VITEST_DEBUG_ENV__`, and do the same for `globalThis.__LMAO_TEST_TRACE_VERBOSE_ENV__` when verbose
|
|
139
|
+
replay is needed.
|
|
140
|
+
- Enable debug for Cloudflare tests with:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Setting Up Trace Testing for a New Package
|
|
146
|
+
|
|
147
|
+
1. Create the preload file (`test-trace-setup.ts`):
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import * as bunTest from 'bun:test';
|
|
151
|
+
import { mock } from 'bun:test';
|
|
152
|
+
import { createBunTestMock, initTraceTestRun } from '@smoothbricks/lmao/testing/bun';
|
|
153
|
+
import { myOpContext } from './src/opContext.js';
|
|
154
|
+
|
|
155
|
+
initTraceTestRun(myOpContext, { sqlite: { dbPath: '.trace-results.db' } });
|
|
156
|
+
mock.module('bun:test', () => createBunTestMock(bunTest));
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
2. Add `bunfig.toml`:
|
|
160
|
+
|
|
161
|
+
```toml
|
|
162
|
+
[test]
|
|
163
|
+
preload = ["./test-trace-setup.ts"]
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
3. Tests import `describe`/`it`/`expect` from `bun:test` as normal — the mock intercepts transparently.
|
|
167
|
+
|
|
168
|
+
4. Add `.trace-results.db` to `.gitignore`.
|
|
169
|
+
|
|
170
|
+
### Querying Trace Results
|
|
171
|
+
|
|
172
|
+
After a test run, the trace database is written to the configured path. The `trace_id` is printed at the end:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
[trace] trace_id: 550e8400-e29b-41d4-a716-446655440000 → .trace-results.db
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The `trace_id` IS the run identifier — one root span per test run, with each `it()` as a child span.
|
|
179
|
+
|
|
180
|
+
**SQLite CLI queries:**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# All spans for the latest trace (root span name = 'test-run')
|
|
184
|
+
sqlite3 .trace-results.db "SELECT s0.message, s0.describe FROM spans s0 WHERE s0.row_index = 0 ORDER BY s0.timestamp_ns"
|
|
185
|
+
|
|
186
|
+
# Find root span_id, then query it-level spans
|
|
187
|
+
sqlite3 .trace-results.db "
|
|
188
|
+
SELECT s0.message AS test_name, s0.describe,
|
|
189
|
+
CASE WHEN s1.entry_type = 2 THEN 'ok'
|
|
190
|
+
WHEN s1.entry_type = 3 THEN 'err'
|
|
191
|
+
WHEN s1.entry_type = 4 THEN 'exception'
|
|
192
|
+
ELSE 'running' END AS status,
|
|
193
|
+
s1.timestamp_ns - s0.timestamp_ns AS duration_ns
|
|
194
|
+
FROM spans s0
|
|
195
|
+
LEFT JOIN spans s1 ON s1.trace_id = s0.trace_id AND s1.span_id = s0.span_id AND s1.row_index = 1
|
|
196
|
+
WHERE s0.trace_id = (SELECT trace_id FROM spans WHERE parent_span_id = 0 AND row_index = 0 ORDER BY timestamp_ns DESC LIMIT 1)
|
|
197
|
+
AND s0.parent_span_id = (SELECT span_id FROM spans WHERE parent_span_id = 0 AND row_index = 0 ORDER BY timestamp_ns DESC LIMIT 1)
|
|
198
|
+
AND s0.row_index = 0
|
|
199
|
+
ORDER BY s0.timestamp_ns"
|
|
200
|
+
|
|
201
|
+
# All tests under a specific describe group
|
|
202
|
+
sqlite3 .trace-results.db "SELECT message FROM spans WHERE describe = 'Order Processing > validation' AND row_index = 0"
|
|
203
|
+
|
|
204
|
+
# Nested describe paths use ' > ' separator
|
|
205
|
+
sqlite3 .trace-results.db "SELECT DISTINCT describe FROM spans WHERE describe IS NOT NULL AND row_index = 0"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Schema:**
|
|
209
|
+
|
|
210
|
+
| Column | Description |
|
|
211
|
+
| ---------------- | ---------------------------------------------------------------- |
|
|
212
|
+
| `trace_id` | Run identifier (= root span's trace_id) |
|
|
213
|
+
| `span_id` | Unique span counter within trace |
|
|
214
|
+
| `parent_span_id` | Parent span (0 = root, root's span_id = it-level) |
|
|
215
|
+
| `row_index` | Row within span (0 = span-start, 1 = span-end, 2+ = log entries) |
|
|
216
|
+
| `entry_type` | 1=span-start, 2=span-ok, 3=span-err, 4=span-exception |
|
|
217
|
+
| `timestamp_ns` | Nanosecond timestamp |
|
|
218
|
+
| `message` | Span name (row 0), log message (rows 2+) |
|
|
219
|
+
| `describe` | `' > '`-separated describe path (user schema column) |
|
|
220
|
+
| `...` | Additional user schema columns added dynamically via ALTER TABLE |
|
|
221
|
+
|
|
222
|
+
Tree structure is encoded via `span_id` / `parent_span_id`. The root span (`parent_span_id = 0`) represents the entire
|
|
223
|
+
test run. Each `it()` is a direct child of the root. User operations create deeper children.
|
|
224
|
+
|
|
225
|
+
**TraceQuery API (programmatic access):**
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { Database } from 'bun:sqlite';
|
|
229
|
+
import { TraceQuery } from '@smoothbricks/lmao/testing';
|
|
230
|
+
|
|
231
|
+
const query = new TraceQuery(new Database('.trace-results.db'));
|
|
232
|
+
query.failures(); // all failed tests
|
|
233
|
+
query.slowest(undefined, 10); // 10 slowest tests
|
|
234
|
+
query.findSpans('%validate%'); // spans matching pattern
|
|
235
|
+
query.testTree('my-test'); // full span tree for a test
|
|
236
|
+
query.close();
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Querying Span Results (in-test)
|
|
240
|
+
|
|
241
|
+
**QueryableSpan** wraps a SpanBuffer with ergonomic helpers:
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { querySpan } from '@smoothbricks/lmao/testing';
|
|
245
|
+
|
|
246
|
+
const q = querySpan(tracer.rootBuffers[0]);
|
|
247
|
+
q.name; // span name
|
|
248
|
+
q.facts(); // all facts from this span tree
|
|
249
|
+
q.find('validate'); // first child span by name
|
|
250
|
+
q.findAll('db-query'); // all matching descendants
|
|
251
|
+
q.children; // direct child QueryableSpans
|
|
252
|
+
q.names(); // all descendant span names
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Standalone functions** (tree-shakable):
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { findSpan, extractFactsFor, spanNames } from '@smoothbricks/lmao/testing';
|
|
259
|
+
|
|
260
|
+
const span = findSpan(rootBuffer, 'validate');
|
|
261
|
+
const facts = extractFactsFor(rootBuffer, 'save');
|
|
262
|
+
const names = spanNames(rootBuffer);
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### SQLite Persistence
|
|
266
|
+
|
|
267
|
+
When configured, the trace database is written after all tests complete. Schema columns evolve automatically based on
|
|
268
|
+
your LogSchema fields.
|
|
269
|
+
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun runtime preload — registers Typia validation codegen plugin.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from @smoothbricks/validation which owns the Typia integration.
|
|
5
|
+
* Packages that cannot depend on lmao should use @smoothbricks/validation/bun/preload directly.
|
|
6
|
+
*
|
|
7
|
+
* Usage in bunfig.toml:
|
|
8
|
+
* preload = ["@smoothbricks/lmao/bun/preload"]
|
|
9
|
+
*/
|
|
10
|
+
import '@smoothbricks/validation/bun/preload';
|
|
11
|
+
//# sourceMappingURL=preload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preload.d.ts","sourceRoot":"","sources":["../../src/bun/preload.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun runtime preload — registers Typia validation codegen plugin.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from @smoothbricks/validation which owns the Typia integration.
|
|
5
|
+
* Packages that cannot depend on lmao should use @smoothbricks/validation/bun/preload directly.
|
|
6
|
+
*
|
|
7
|
+
* Usage in bunfig.toml:
|
|
8
|
+
* preload = ["@smoothbricks/lmao/bun/preload"]
|
|
9
|
+
*/
|
|
10
|
+
import '@smoothbricks/validation/bun/preload';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-preload.d.ts","sourceRoot":"","sources":["../../src/bun/trace-preload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun test tracing preload.
|
|
3
|
+
*
|
|
4
|
+
* Registers LMAO SQLite-backed test tracing after the Typia preload has already
|
|
5
|
+
* been registered in bunfig.
|
|
6
|
+
*/
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { autoSetupBunTestTracing } from '../lib/testing/bun-harness.js';
|
|
9
|
+
// WHY: Find the monorepo packages dir relative to this file's location.
|
|
10
|
+
// This file lives at packages/lmao/src/bun/trace-preload.ts (4 levels up to monorepo root).
|
|
11
|
+
const monorepoRoot = join(import.meta.dir, '..', '..', '..', '..');
|
|
12
|
+
await autoSetupBunTestTracing({ packagesDir: join(monorepoRoot, 'packages') });
|
package/dist/es.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ES/Browser entry point for @smoothbricks/lmao/es
|
|
3
|
+
* Uses performance.now() for high-precision timestamps
|
|
4
|
+
* Works in browsers, Deno, Cloudflare Workers, etc.
|
|
5
|
+
*/
|
|
6
|
+
export * from './index.js';
|
|
7
|
+
export { createTraceRoot } from './lib/traceRoot.es.js';
|
|
8
|
+
//# sourceMappingURL=es.d.ts.map
|
package/dist/es.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../src/es.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/es.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ES/Browser entry point for @smoothbricks/lmao/es
|
|
3
|
+
* Uses performance.now() for high-precision timestamps
|
|
4
|
+
* Works in browsers, Deno, Cloudflare Workers, etc.
|
|
5
|
+
*/
|
|
6
|
+
// Re-export all main functionality
|
|
7
|
+
export * from './index.js';
|
|
8
|
+
// Export browser-specific TraceRoot factory for Tracer construction
|
|
9
|
+
export { createTraceRoot } from './lib/traceRoot.es.js';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export * from './lib/defineOpContext.js';
|
|
2
|
+
export { Op } from './lib/op.js';
|
|
3
|
+
export { Blocked, type BlockedConfig, type BlockedReason } from './lib/errors/Blocked.js';
|
|
4
|
+
export type { Result, TaggedError, TaggedErrorConstructor } from './lib/result.js';
|
|
5
|
+
export { defineCodeError, Err, hasErrorCode, Ok } from './lib/result.js';
|
|
6
|
+
export type { RootSpanFn, TraceContext, TraceContextSystem } from './lib/traceContext.js';
|
|
7
|
+
export { isTraceContext, TRACE_CONTEXT_MARKER, TraceContextProto } from './lib/traceContext.js';
|
|
8
|
+
export type { FluentLogEntry, SpanContext, SpanFn, SpanLogger } from './lib/spanContext.js';
|
|
9
|
+
export { isSpanContext, SPAN_CONTEXT_MARKER } from './lib/spanContext.js';
|
|
10
|
+
export type { LogAPI } from './lib/logApi.js';
|
|
11
|
+
export { noopLogAPI } from './lib/logApi.js';
|
|
12
|
+
export { ENTRY_TYPE_BUFFER_CAPACITY, ENTRY_TYPE_BUFFER_SPANS, ENTRY_TYPE_BUFFER_WRITES, ENTRY_TYPE_DEBUG, ENTRY_TYPE_ERROR, ENTRY_TYPE_FF_ACCESS, ENTRY_TYPE_FF_USAGE, ENTRY_TYPE_INFO, ENTRY_TYPE_NAMES, ENTRY_TYPE_OP_DURATION_ERR, ENTRY_TYPE_OP_DURATION_MAX, ENTRY_TYPE_OP_DURATION_MIN, ENTRY_TYPE_OP_DURATION_OK, ENTRY_TYPE_OP_DURATION_TOTAL, ENTRY_TYPE_OP_ERRORS, ENTRY_TYPE_OP_EXCEPTIONS, ENTRY_TYPE_OP_INVOCATIONS, ENTRY_TYPE_PERIOD_START, ENTRY_TYPE_SPAN_ERR, ENTRY_TYPE_SPAN_EXCEPTION, ENTRY_TYPE_SPAN_OK, ENTRY_TYPE_SPAN_START, ENTRY_TYPE_TRACE, ENTRY_TYPE_WARN, mergeWithSystemSchema, systemSchema, } from './lib/schema/systemSchema.js';
|
|
13
|
+
export type { Input, Output, Schema, SchemaFields, SchemaType, SchemaWithMetadata } from '@smoothbricks/arrow-builder';
|
|
14
|
+
export * from './lib/schema/evaluator.js';
|
|
15
|
+
export * from './lib/schema/extend.js';
|
|
16
|
+
export * from './lib/schema/typeGuards.js';
|
|
17
|
+
export type { ResultWriter, TagWriter } from './lib/codegen/fixedPositionWriterGenerator.js';
|
|
18
|
+
export { createResultWriter, createTagWriter } from './lib/codegen/fixedPositionWriterGenerator.js';
|
|
19
|
+
export type { BaseSpanLogger, SpanLoggerImpl } from './lib/codegen/spanLoggerGenerator.js';
|
|
20
|
+
export { createSpanLogger, createSpanLoggerClass } from './lib/codegen/spanLoggerGenerator.js';
|
|
21
|
+
export * from './lib/convertToArrow.js';
|
|
22
|
+
export * from './lib/spanBuffer.js';
|
|
23
|
+
export * from './lib/types.js';
|
|
24
|
+
export * from './lib/flushScheduler.js';
|
|
25
|
+
export type { BufferStrategy } from './lib/bufferStrategy.js';
|
|
26
|
+
export { JsBufferStrategy } from './lib/JsBufferStrategy.js';
|
|
27
|
+
export type { OpContextBinding } from './lib/opContext/types.js';
|
|
28
|
+
export { type TraceFn, type TraceOverrides, Tracer, type TracerOptions } from './lib/tracer.js';
|
|
29
|
+
export { ArrayQueueTracer } from './lib/tracers/ArrayQueueTracer.js';
|
|
30
|
+
export { CompositeTracer } from './lib/tracers/CompositeTracer.js';
|
|
31
|
+
export { NoOpTracer } from './lib/tracers/NoOpTracer.js';
|
|
32
|
+
export { SQLiteAsyncTracer, SQLiteTracer } from './lib/tracers/SQLiteTracer.js';
|
|
33
|
+
export { StdioTracer } from './lib/tracers/StdioTracer.js';
|
|
34
|
+
export { type StatsSnapshot, TestTracer } from './lib/tracers/TestTracer.js';
|
|
35
|
+
export * from './lib/library.js';
|
|
36
|
+
export * from './lib/archive/index.js';
|
|
37
|
+
export { _resetThreadId, copyThreadIdTo, getThreadId, THREAD_ID_BYTES, writeThreadIdToUint64Array, } from './lib/threadId.js';
|
|
38
|
+
export { createTraceId, extractSpanIdentity, generateTraceId, isValidTraceId, MAX_TRACE_ID_LENGTH, type SpanIdentity, type TraceId, } from './lib/traceId.js';
|
|
39
|
+
export type { ITraceRoot, TraceRootFactory, TracerLifecycleHooks } from './lib/traceRoot.js';
|
|
40
|
+
export * from './lib/utf8Cache.js';
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAMjC,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1F,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAUzE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAMhG,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAM1E,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,OAAO,EAEL,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAEhB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EAEf,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,4BAA4B,EAC5B,oBAAoB,EACpB,wBAAwB,EAExB,yBAAyB,EAEzB,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAElB,qBAAqB,EAErB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EAErB,YAAY,GACb,MAAM,8BAA8B,CAAC;AAMtC,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAOvH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAM3C,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AACpG,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAM/F,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAM/B,cAAc,yBAAyB,CAAC;AAMxC,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAM7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAM7E,cAAc,kBAAkB,CAAC;AAMjC,cAAc,wBAAwB,CAAC;AAMvC,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,eAAe,EACf,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,OAAO,GACb,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAM7F,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Main integration API - GREENFIELD - NO BACKWARDS COMPAT
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Primary API: defineOpContext (Op-Centric API)
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// Op-Centric API - the module system (includes schema utilities and types)
|
|
6
|
+
export * from './lib/defineOpContext.js';
|
|
7
|
+
// Op class - used internally by defineOp()
|
|
8
|
+
export { Op } from './lib/op.js';
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Result Types
|
|
11
|
+
// =============================================================================
|
|
12
|
+
export { Blocked } from './lib/errors/Blocked.js';
|
|
13
|
+
export { defineCodeError, Err, hasErrorCode, Ok } from './lib/result.js';
|
|
14
|
+
export { isTraceContext, TRACE_CONTEXT_MARKER, TraceContextProto } from './lib/traceContext.js';
|
|
15
|
+
export { isSpanContext, SPAN_CONTEXT_MARKER } from './lib/spanContext.js';
|
|
16
|
+
export { noopLogAPI } from './lib/logApi.js';
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// System Schema & Entry Type Constants
|
|
19
|
+
// =============================================================================
|
|
20
|
+
export {
|
|
21
|
+
// Buffer metrics (utilization-based capacity tuning)
|
|
22
|
+
ENTRY_TYPE_BUFFER_CAPACITY, ENTRY_TYPE_BUFFER_SPANS, ENTRY_TYPE_BUFFER_WRITES, ENTRY_TYPE_DEBUG, ENTRY_TYPE_ERROR,
|
|
23
|
+
// Feature flags
|
|
24
|
+
ENTRY_TYPE_FF_ACCESS, ENTRY_TYPE_FF_USAGE, ENTRY_TYPE_INFO,
|
|
25
|
+
// Lookup
|
|
26
|
+
ENTRY_TYPE_NAMES, ENTRY_TYPE_OP_DURATION_ERR, ENTRY_TYPE_OP_DURATION_MAX, ENTRY_TYPE_OP_DURATION_MIN, ENTRY_TYPE_OP_DURATION_OK, ENTRY_TYPE_OP_DURATION_TOTAL, ENTRY_TYPE_OP_ERRORS, ENTRY_TYPE_OP_EXCEPTIONS,
|
|
27
|
+
// Op metrics
|
|
28
|
+
ENTRY_TYPE_OP_INVOCATIONS,
|
|
29
|
+
// Period markers
|
|
30
|
+
ENTRY_TYPE_PERIOD_START, ENTRY_TYPE_SPAN_ERR, ENTRY_TYPE_SPAN_EXCEPTION, ENTRY_TYPE_SPAN_OK,
|
|
31
|
+
// Span lifecycle
|
|
32
|
+
ENTRY_TYPE_SPAN_START,
|
|
33
|
+
// Log levels (ordered by verbosity)
|
|
34
|
+
ENTRY_TYPE_TRACE, ENTRY_TYPE_WARN, mergeWithSystemSchema,
|
|
35
|
+
// Schema helpers
|
|
36
|
+
systemSchema, } from './lib/schema/systemSchema.js';
|
|
37
|
+
// =============================================================================
|
|
38
|
+
// Schema System (additional exports not in defineOpContext)
|
|
39
|
+
// Note: defineOpContext already re-exports S, defineFeatureFlags, defineLogSchema, LogSchema
|
|
40
|
+
// =============================================================================
|
|
41
|
+
export * from './lib/schema/evaluator.js';
|
|
42
|
+
export * from './lib/schema/extend.js';
|
|
43
|
+
export * from './lib/schema/typeGuards.js';
|
|
44
|
+
export { createResultWriter, createTagWriter } from './lib/codegen/fixedPositionWriterGenerator.js';
|
|
45
|
+
export { createSpanLogger, createSpanLoggerClass } from './lib/codegen/spanLoggerGenerator.js';
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// SpanBuffer & Arrow Conversion
|
|
48
|
+
// =============================================================================
|
|
49
|
+
export * from './lib/convertToArrow.js';
|
|
50
|
+
export * from './lib/spanBuffer.js';
|
|
51
|
+
export * from './lib/types.js';
|
|
52
|
+
// =============================================================================
|
|
53
|
+
// Flush Scheduler
|
|
54
|
+
// =============================================================================
|
|
55
|
+
export * from './lib/flushScheduler.js';
|
|
56
|
+
export { JsBufferStrategy } from './lib/JsBufferStrategy.js';
|
|
57
|
+
export { Tracer } from './lib/tracer.js';
|
|
58
|
+
export { ArrayQueueTracer } from './lib/tracers/ArrayQueueTracer.js';
|
|
59
|
+
export { CompositeTracer } from './lib/tracers/CompositeTracer.js';
|
|
60
|
+
// Concrete tracer implementations
|
|
61
|
+
export { NoOpTracer } from './lib/tracers/NoOpTracer.js';
|
|
62
|
+
export { SQLiteAsyncTracer, SQLiteTracer } from './lib/tracers/SQLiteTracer.js';
|
|
63
|
+
export { StdioTracer } from './lib/tracers/StdioTracer.js';
|
|
64
|
+
export { TestTracer } from './lib/tracers/TestTracer.js';
|
|
65
|
+
// =============================================================================
|
|
66
|
+
// Library Integration
|
|
67
|
+
// =============================================================================
|
|
68
|
+
export * from './lib/library.js';
|
|
69
|
+
// =============================================================================
|
|
70
|
+
// Archive Data-Plane Primitives
|
|
71
|
+
// =============================================================================
|
|
72
|
+
export * from './lib/archive/index.js';
|
|
73
|
+
// =============================================================================
|
|
74
|
+
// Thread ID Generation
|
|
75
|
+
// =============================================================================
|
|
76
|
+
export { _resetThreadId, copyThreadIdTo, getThreadId, THREAD_ID_BYTES, writeThreadIdToUint64Array, } from './lib/threadId.js';
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// Trace ID
|
|
79
|
+
// =============================================================================
|
|
80
|
+
export { createTraceId, extractSpanIdentity, generateTraceId, isValidTraceId, MAX_TRACE_ID_LENGTH, } from './lib/traceId.js';
|
|
81
|
+
// =============================================================================
|
|
82
|
+
// UTF-8 Cache (for Arrow conversion)
|
|
83
|
+
// =============================================================================
|
|
84
|
+
export * from './lib/utf8Cache.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JsBufferStrategy - Default buffer strategy using JavaScript TypedArrays.
|
|
3
|
+
*
|
|
4
|
+
* Uses GC-managed memory with zero-copy Arrow conversion via flechette.
|
|
5
|
+
*
|
|
6
|
+
* Memory characteristics:
|
|
7
|
+
* - Buffers are regular JS objects with TypedArray properties
|
|
8
|
+
* - GC handles deallocation (no explicit release needed)
|
|
9
|
+
* - Arrow conversion shares ArrayBuffer references (zero-copy)
|
|
10
|
+
*
|
|
11
|
+
* @module JsBufferStrategy
|
|
12
|
+
*/
|
|
13
|
+
import type { Table } from '@uwdata/flechette';
|
|
14
|
+
import type { BufferStrategy } from './bufferStrategy.js';
|
|
15
|
+
import type { OpMetadata } from './opContext/opTypes.js';
|
|
16
|
+
import type { LogSchema } from './schema/LogSchema.js';
|
|
17
|
+
import type { ITraceRoot } from './traceRoot.js';
|
|
18
|
+
import type { AnySpanBuffer, SpanBuffer } from './types.js';
|
|
19
|
+
/**
|
|
20
|
+
* JsBufferStrategy - Default buffer strategy using GC-managed TypedArrays.
|
|
21
|
+
*
|
|
22
|
+
* This is the standard strategy for most use cases:
|
|
23
|
+
* - Simple memory model (GC handles cleanup)
|
|
24
|
+
* - Zero-copy Arrow conversion (shares ArrayBuffer references)
|
|
25
|
+
* - No explicit release needed (but releaseBuffer is a no-op)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const strategy = new JsBufferStrategy<MySchema>();
|
|
30
|
+
* const tracer = new StdioTracer(binding, strategy, options);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class JsBufferStrategy<T extends LogSchema = LogSchema> implements BufferStrategy<T> {
|
|
34
|
+
/**
|
|
35
|
+
* Cache of SpanBuffer classes per schema.
|
|
36
|
+
* Populated lazily on first buffer creation.
|
|
37
|
+
*/
|
|
38
|
+
private spanBufferClassCache;
|
|
39
|
+
/**
|
|
40
|
+
* Get or create SpanBuffer class for a schema.
|
|
41
|
+
*/
|
|
42
|
+
private getSpanBufferClassForSchema;
|
|
43
|
+
createSpanBuffer(schema: T, traceRoot: ITraceRoot, opMetadata: OpMetadata, capacity?: number): SpanBuffer<T>;
|
|
44
|
+
createChildSpanBuffer(parentBuffer: SpanBuffer<T>, callsiteMetadata: OpMetadata, opMetadata: OpMetadata, capacity?: number, schema?: T): SpanBuffer<T>;
|
|
45
|
+
createOverflowBuffer(buffer: SpanBuffer<T>): SpanBuffer<T>;
|
|
46
|
+
toArrowTable(buffer: AnySpanBuffer): Table;
|
|
47
|
+
releaseBuffer(_buffer: AnySpanBuffer): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=JsBufferStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsBufferStrategy.d.ts","sourceRoot":"","sources":["../../src/lib/JsBufferStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS5D;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,YAAW,cAAc,CAAC,CAAC,CAAC;IACzF;;;OAGG;IACH,OAAO,CAAC,oBAAoB,CAAmD;IAE/E;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAYnC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;IAI5G,qBAAqB,CACnB,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,EAC3B,gBAAgB,EAAE,UAAU,EAC5B,UAAU,EAAE,UAAU,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,CAAC,GACT,UAAU,CAAC,CAAC,CAAC;IAOhB,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAI1D,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,KAAK;IAK1C,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;CAI5C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { convertSpanTreeToArrowTable } from './convertToArrow.js';
|
|
2
|
+
import { createChildSpanBuffer as createChildSpanBufferImpl, createOverflowBuffer as createOverflowBufferImpl, createSpanBuffer as createSpanBufferImpl, getSpanBufferClass, } from './spanBuffer.js';
|
|
3
|
+
function isSpanBufferConstructorForSchema(ctor, schema) {
|
|
4
|
+
return ctor !== undefined && ctor.schema === schema;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* JsBufferStrategy - Default buffer strategy using GC-managed TypedArrays.
|
|
8
|
+
*
|
|
9
|
+
* This is the standard strategy for most use cases:
|
|
10
|
+
* - Simple memory model (GC handles cleanup)
|
|
11
|
+
* - Zero-copy Arrow conversion (shares ArrayBuffer references)
|
|
12
|
+
* - No explicit release needed (but releaseBuffer is a no-op)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const strategy = new JsBufferStrategy<MySchema>();
|
|
17
|
+
* const tracer = new StdioTracer(binding, strategy, options);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class JsBufferStrategy {
|
|
21
|
+
/**
|
|
22
|
+
* Cache of SpanBuffer classes per schema.
|
|
23
|
+
* Populated lazily on first buffer creation.
|
|
24
|
+
*/
|
|
25
|
+
spanBufferClassCache = new WeakMap();
|
|
26
|
+
/**
|
|
27
|
+
* Get or create SpanBuffer class for a schema.
|
|
28
|
+
*/
|
|
29
|
+
getSpanBufferClassForSchema(schema) {
|
|
30
|
+
let cached = this.spanBufferClassCache.get(schema);
|
|
31
|
+
if (!cached) {
|
|
32
|
+
cached = getSpanBufferClass(schema);
|
|
33
|
+
this.spanBufferClassCache.set(schema, cached);
|
|
34
|
+
}
|
|
35
|
+
if (!isSpanBufferConstructorForSchema(cached, schema)) {
|
|
36
|
+
throw new TypeError('Cached SpanBuffer class does not match schema');
|
|
37
|
+
}
|
|
38
|
+
return cached;
|
|
39
|
+
}
|
|
40
|
+
createSpanBuffer(schema, traceRoot, opMetadata, capacity) {
|
|
41
|
+
return createSpanBufferImpl(schema, traceRoot, opMetadata, capacity);
|
|
42
|
+
}
|
|
43
|
+
createChildSpanBuffer(parentBuffer, callsiteMetadata, opMetadata, capacity, schema) {
|
|
44
|
+
// Use provided schema (for cross-library calls) or parent's schema
|
|
45
|
+
const childSchema = schema ?? parentBuffer._logSchema;
|
|
46
|
+
const SpanBufferClass = this.getSpanBufferClassForSchema(childSchema);
|
|
47
|
+
return createChildSpanBufferImpl(parentBuffer, SpanBufferClass, callsiteMetadata, opMetadata, capacity);
|
|
48
|
+
}
|
|
49
|
+
createOverflowBuffer(buffer) {
|
|
50
|
+
return createOverflowBufferImpl(buffer);
|
|
51
|
+
}
|
|
52
|
+
toArrowTable(buffer) {
|
|
53
|
+
// Uses existing tree conversion with shared dictionaries
|
|
54
|
+
return convertSpanTreeToArrowTable(buffer);
|
|
55
|
+
}
|
|
56
|
+
releaseBuffer(_buffer) {
|
|
57
|
+
// No-op for JS strategy - GC handles memory
|
|
58
|
+
// The buffer will be collected when no references remain
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TraceChunkEnvelope } from './chunkEnvelope.js';
|
|
2
|
+
export interface CompactionWindow {
|
|
3
|
+
readonly started_at_ms: number;
|
|
4
|
+
readonly ended_at_ms: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CompactedChunkSet {
|
|
7
|
+
readonly compaction_id: string;
|
|
8
|
+
readonly source_set_hash: string;
|
|
9
|
+
readonly source_chunk_ids: readonly string[];
|
|
10
|
+
readonly source_chunk_count: number;
|
|
11
|
+
readonly total_rows: number;
|
|
12
|
+
readonly window: CompactionWindow;
|
|
13
|
+
}
|
|
14
|
+
export declare function compactTraceChunks(chunks: readonly TraceChunkEnvelope[], window: CompactionWindow): CompactedChunkSet;
|
|
15
|
+
//# sourceMappingURL=chunkCompaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunkCompaction.d.ts","sourceRoot":"","sources":["../../../src/lib/archive/chunkCompaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;CACnC;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,EAAE,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,CAcrH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function compactTraceChunks(chunks, window) {
|
|
2
|
+
const sourceChunkIds = [...new Set(chunks.map((chunk) => chunk.chunk_id))].sort();
|
|
3
|
+
const totalRows = chunks.reduce((sum, chunk) => sum + chunk.row_count, 0);
|
|
4
|
+
const source_set_hash = hashDeterministic(sourceChunkIds.join('|'));
|
|
5
|
+
const compaction_id = `compact_${hashDeterministic(`${source_set_hash}:${window.started_at_ms}:${window.ended_at_ms}`)}`;
|
|
6
|
+
return {
|
|
7
|
+
compaction_id,
|
|
8
|
+
source_set_hash,
|
|
9
|
+
source_chunk_ids: sourceChunkIds,
|
|
10
|
+
source_chunk_count: sourceChunkIds.length,
|
|
11
|
+
total_rows: totalRows,
|
|
12
|
+
window,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function hashDeterministic(input) {
|
|
16
|
+
let hash = 0xcbf29ce484222325n;
|
|
17
|
+
const prime = 0x100000001b3n;
|
|
18
|
+
const mod = 0xffffffffffffffffn;
|
|
19
|
+
for (let i = 0; i < input.length; i++) {
|
|
20
|
+
hash ^= BigInt(input.charCodeAt(i));
|
|
21
|
+
hash = (hash * prime) & mod;
|
|
22
|
+
}
|
|
23
|
+
return hash.toString(16).padStart(16, '0');
|
|
24
|
+
}
|