@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,1965 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`generateSpanLoggerClass snapshots snapshot: empty schema 1`] = `
|
|
4
|
+
"
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
// Inline getTimestampNanos for performance (zero function call overhead)
|
|
8
|
+
// performance.timeOrigin + performance.now() gives epoch milliseconds with sub-ms precision
|
|
9
|
+
// Convert to microseconds first (safe as Number), then to nanoseconds as BigInt
|
|
10
|
+
function getTimestampNanos() {
|
|
11
|
+
const epochMicros = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
12
|
+
return BigInt(epochMicros) * 1000n;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class GeneratedSpanLogger {
|
|
18
|
+
constructor(buffer, getBufferWithSpace, scopeInstance) {
|
|
19
|
+
this._buffer = buffer;
|
|
20
|
+
this._getBufferWithSpace = getBufferWithSpace;
|
|
21
|
+
this._scope = scopeInstance;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Tag getter - returns chainable API that writes to row 0 (span-start)
|
|
25
|
+
// Note: No overflow check needed - row 0 always exists
|
|
26
|
+
// Note: No writeIndex increment - always writing to same row (overwrite semantics)
|
|
27
|
+
get tag() {
|
|
28
|
+
// Entry type for row 0 is already span-start (set at buffer creation)
|
|
29
|
+
// Just return this for chaining - individual methods write to row 0
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// with() method for bulk attribute setting - writes to row 0
|
|
34
|
+
// UNROLLED: Each column gets explicit code, no Object.entries iteration
|
|
35
|
+
|
|
36
|
+
with(attributes) {
|
|
37
|
+
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Attribute writer methods (generated from schema)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// Scoped attributes - writes to Scope instance and pre-fills buffer
|
|
45
|
+
// NOTE: scope() exposed via ctx.scope, but SpanLogger provides _setScope for implementation
|
|
46
|
+
// UNROLLED: Each column gets explicit TypedArray.fill() + bulk null bitmap
|
|
47
|
+
|
|
48
|
+
_setScope(attributes) {
|
|
49
|
+
// Update the Scope instance (stores raw values, not interned)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// Pre-fill remaining buffer capacity with scoped attributes
|
|
53
|
+
const startIdx = this._buffer.writeIndex;
|
|
54
|
+
const endIdx = this._buffer.capacity;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Pre-fill buffer with scoped attributes from current writeIndex to capacity.
|
|
61
|
+
* Called after buffer overflow to propagate scoped attributes to the new buffer.
|
|
62
|
+
*
|
|
63
|
+
* UNROLLED: Each column gets explicit code with bulk null bitmap operations
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
_prefillScopedAttributes() {
|
|
67
|
+
const startIdx = this._buffer.writeIndex;
|
|
68
|
+
const endIdx = this._buffer.capacity;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Message logging methods
|
|
74
|
+
// UNROLLED: Scope attribute writes are explicit per-column, no Object.entries
|
|
75
|
+
|
|
76
|
+
_writeMessage(entryType, message) {
|
|
77
|
+
const result = this._getBufferWithSpace(this._buffer);
|
|
78
|
+
|
|
79
|
+
// If overflow occurred, pre-fill new buffer with scoped attributes
|
|
80
|
+
if (result.didOverflow) {
|
|
81
|
+
this._buffer = result.buffer;
|
|
82
|
+
this._prefillScopedAttributes();
|
|
83
|
+
} else {
|
|
84
|
+
this._buffer = result.buffer;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const idx = this._buffer.writeIndex;
|
|
88
|
+
|
|
89
|
+
// Write entry type
|
|
90
|
+
this._buffer.operations[idx] = entryType;
|
|
91
|
+
|
|
92
|
+
// Write timestamp (nanoseconds since epoch)
|
|
93
|
+
this._buffer.timestamps[idx] = getTimestampNanos();
|
|
94
|
+
|
|
95
|
+
// Write message to logMessage column (raw string, no interning)
|
|
96
|
+
const messageColumn = this._buffer.logMessage_values;
|
|
97
|
+
if (messageColumn) {
|
|
98
|
+
messageColumn[idx] = message;
|
|
99
|
+
helpers.setNullBit(this._buffer.logMessage_nulls, idx);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Apply scoped attributes - UNROLLED per-column
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
// Increment write index
|
|
106
|
+
this._buffer.writeIndex++;
|
|
107
|
+
|
|
108
|
+
// Return fluent object for attribute chaining
|
|
109
|
+
// Capture buffer reference directly (not via self._buffer) so it's stable
|
|
110
|
+
// even if another log call happens before fluent methods are called
|
|
111
|
+
const buf = this._buffer;
|
|
112
|
+
return {
|
|
113
|
+
line(lineNumber) {
|
|
114
|
+
const lineCol = buf.lineNumber_values;
|
|
115
|
+
if (lineCol) {
|
|
116
|
+
lineCol[idx] = lineNumber;
|
|
117
|
+
helpers.setNullBit(buf.lineNumber_nulls, idx);
|
|
118
|
+
}
|
|
119
|
+
return this;
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
message(level, message) {
|
|
126
|
+
const entryTypeMap = {
|
|
127
|
+
'info': 9,
|
|
128
|
+
'debug': 10,
|
|
129
|
+
'warn': 11,
|
|
130
|
+
'error': 12
|
|
131
|
+
};
|
|
132
|
+
return this._writeMessage(entryTypeMap[level] || 9, message);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
info(message) {
|
|
136
|
+
return this._writeMessage(9, message);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
debug(message) {
|
|
140
|
+
return this._writeMessage(10, message);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
warn(message) {
|
|
144
|
+
return this._writeMessage(11, message);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
error(message) {
|
|
148
|
+
return this._writeMessage(12, message);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Get the Scope instance directly
|
|
152
|
+
_getScope() {
|
|
153
|
+
return this._scope;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return GeneratedSpanLogger;
|
|
158
|
+
"
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
exports[`generateSpanLoggerClass snapshots snapshot: all field types 1`] = `
|
|
162
|
+
"
|
|
163
|
+
'use strict';
|
|
164
|
+
|
|
165
|
+
// Inline getTimestampNanos for performance (zero function call overhead)
|
|
166
|
+
// performance.timeOrigin + performance.now() gives epoch milliseconds with sub-ms precision
|
|
167
|
+
// Convert to microseconds first (safe as Number), then to nanoseconds as BigInt
|
|
168
|
+
function getTimestampNanos() {
|
|
169
|
+
const epochMicros = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
170
|
+
return BigInt(epochMicros) * 1000n;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
function getEnumIndex_operation(value) {
|
|
175
|
+
switch(value) {
|
|
176
|
+
case "CREATE": return 0;
|
|
177
|
+
case "READ": return 1;
|
|
178
|
+
case "UPDATE": return 2;
|
|
179
|
+
case "DELETE": return 3;
|
|
180
|
+
default: return 0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
class GeneratedSpanLogger {
|
|
185
|
+
constructor(buffer, getBufferWithSpace, scopeInstance) {
|
|
186
|
+
this._buffer = buffer;
|
|
187
|
+
this._getBufferWithSpace = getBufferWithSpace;
|
|
188
|
+
this._scope = scopeInstance;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Tag getter - returns chainable API that writes to row 0 (span-start)
|
|
192
|
+
// Note: No overflow check needed - row 0 always exists
|
|
193
|
+
// Note: No writeIndex increment - always writing to same row (overwrite semantics)
|
|
194
|
+
get tag() {
|
|
195
|
+
// Entry type for row 0 is already span-start (set at buffer creation)
|
|
196
|
+
// Just return this for chaining - individual methods write to row 0
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// with() method for bulk attribute setting - writes to row 0
|
|
201
|
+
// UNROLLED: Each column gets explicit code, no Object.entries iteration
|
|
202
|
+
|
|
203
|
+
with(attributes) {
|
|
204
|
+
|
|
205
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
206
|
+
this._buffer.userId_values[0] = attributes.userId;
|
|
207
|
+
this._buffer.userId_nulls[0] |= 1;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if ('operation' in attributes && attributes.operation !== null && attributes.operation !== undefined) {
|
|
211
|
+
this._buffer.operation_values[0] = getEnumIndex_operation(attributes.operation);
|
|
212
|
+
this._buffer.operation_nulls[0] |= 1;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if ('errorMsg' in attributes && attributes.errorMsg !== null && attributes.errorMsg !== undefined) {
|
|
216
|
+
this._buffer.errorMsg_values[0] = attributes.errorMsg;
|
|
217
|
+
this._buffer.errorMsg_nulls[0] |= 1;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if ('count' in attributes && attributes.count !== null && attributes.count !== undefined) {
|
|
221
|
+
this._buffer.count_values[0] = attributes.count;
|
|
222
|
+
this._buffer.count_nulls[0] |= 1;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if ('enabled' in attributes && attributes.enabled !== null && attributes.enabled !== undefined) {
|
|
226
|
+
// Bit-packed boolean write at index 0
|
|
227
|
+
if (attributes.enabled) {
|
|
228
|
+
this._buffer.enabled_values[0] |= 1;
|
|
229
|
+
} else {
|
|
230
|
+
this._buffer.enabled_values[0] &= ~1;
|
|
231
|
+
}
|
|
232
|
+
this._buffer.enabled_nulls[0] |= 1;
|
|
233
|
+
}
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Attribute writer methods (generated from schema)
|
|
238
|
+
|
|
239
|
+
userId(value) {
|
|
240
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
241
|
+
const idx = 0;
|
|
242
|
+
this._buffer.userId_values[idx] = value;
|
|
243
|
+
|
|
244
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
245
|
+
const nullBitmap = this._buffer.userId_nulls;
|
|
246
|
+
if (nullBitmap) {
|
|
247
|
+
nullBitmap[0] |= 1;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
operation(value) {
|
|
254
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
255
|
+
const idx = 0;
|
|
256
|
+
const enumIndex = getEnumIndex_operation(value);
|
|
257
|
+
this._buffer.operation_values[idx] = enumIndex;
|
|
258
|
+
|
|
259
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
260
|
+
const nullBitmap = this._buffer.operation_nulls;
|
|
261
|
+
if (nullBitmap) {
|
|
262
|
+
nullBitmap[0] |= 1;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
errorMsg(value) {
|
|
269
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
270
|
+
const idx = 0;
|
|
271
|
+
const nullBitmap = this._buffer.errorMsg_nulls;
|
|
272
|
+
|
|
273
|
+
// Handle null/undefined: clear null bitmap bit and return early
|
|
274
|
+
if (value === null || value === undefined) {
|
|
275
|
+
if (nullBitmap) {
|
|
276
|
+
nullBitmap[0] &= ~1; // Clear bit 0
|
|
277
|
+
}
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Store the text value (raw string, no interning)
|
|
282
|
+
this._buffer.errorMsg_values[idx] = value;
|
|
283
|
+
|
|
284
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
285
|
+
if (nullBitmap) {
|
|
286
|
+
nullBitmap[0] |= 1;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
count(value) {
|
|
293
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
294
|
+
const idx = 0;
|
|
295
|
+
this._buffer.count_values[idx] = value;
|
|
296
|
+
|
|
297
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
298
|
+
const nullBitmap = this._buffer.count_nulls;
|
|
299
|
+
if (nullBitmap) {
|
|
300
|
+
nullBitmap[0] |= 1;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return this;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
enabled(value) {
|
|
307
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
308
|
+
// Bit-packed: bit 0 of byte 0 is index 0
|
|
309
|
+
if (value) {
|
|
310
|
+
this._buffer.enabled_values[0] |= 1;
|
|
311
|
+
} else {
|
|
312
|
+
this._buffer.enabled_values[0] &= ~1;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
316
|
+
const nullBitmap = this._buffer.enabled_nulls;
|
|
317
|
+
if (nullBitmap) {
|
|
318
|
+
nullBitmap[0] |= 1;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return this;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Scoped attributes - writes to Scope instance and pre-fills buffer
|
|
325
|
+
// NOTE: scope() exposed via ctx.scope, but SpanLogger provides _setScope for implementation
|
|
326
|
+
// UNROLLED: Each column gets explicit TypedArray.fill() + bulk null bitmap
|
|
327
|
+
|
|
328
|
+
_setScope(attributes) {
|
|
329
|
+
// Update the Scope instance (stores raw values, not interned)
|
|
330
|
+
|
|
331
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
332
|
+
this._scope.userId = attributes.userId;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if ('operation' in attributes && attributes.operation !== null && attributes.operation !== undefined) {
|
|
336
|
+
this._scope.operation = attributes.operation;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if ('errorMsg' in attributes && attributes.errorMsg !== null && attributes.errorMsg !== undefined) {
|
|
340
|
+
this._scope.errorMsg = attributes.errorMsg;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if ('count' in attributes && attributes.count !== null && attributes.count !== undefined) {
|
|
344
|
+
this._scope.count = attributes.count;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if ('enabled' in attributes && attributes.enabled !== null && attributes.enabled !== undefined) {
|
|
348
|
+
this._scope.enabled = attributes.enabled;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Pre-fill remaining buffer capacity with scoped attributes
|
|
352
|
+
const startIdx = this._buffer.writeIndex;
|
|
353
|
+
const endIdx = this._buffer.capacity;
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
357
|
+
// Fill string array with manual loop
|
|
358
|
+
const values = this._buffer.userId_values;
|
|
359
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
360
|
+
values[i] = attributes.userId;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Bulk fill null bitmap using helper
|
|
364
|
+
helpers.fillNullBitmapRange(this._buffer.userId_nulls, startIdx, endIdx);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if ('operation' in attributes && attributes.operation !== null && attributes.operation !== undefined) {
|
|
368
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
369
|
+
this._buffer.operation_values.fill(getEnumIndex_operation(attributes.operation), startIdx, endIdx);
|
|
370
|
+
|
|
371
|
+
// Bulk fill null bitmap using helper
|
|
372
|
+
helpers.fillNullBitmapRange(this._buffer.operation_nulls, startIdx, endIdx);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if ('errorMsg' in attributes && attributes.errorMsg !== null && attributes.errorMsg !== undefined) {
|
|
376
|
+
// Fill string array with manual loop
|
|
377
|
+
const values = this._buffer.errorMsg_values;
|
|
378
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
379
|
+
values[i] = attributes.errorMsg;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Bulk fill null bitmap using helper
|
|
383
|
+
helpers.fillNullBitmapRange(this._buffer.errorMsg_nulls, startIdx, endIdx);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if ('count' in attributes && attributes.count !== null && attributes.count !== undefined) {
|
|
387
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
388
|
+
this._buffer.count_values.fill(attributes.count, startIdx, endIdx);
|
|
389
|
+
|
|
390
|
+
// Bulk fill null bitmap using helper
|
|
391
|
+
helpers.fillNullBitmapRange(this._buffer.count_nulls, startIdx, endIdx);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if ('enabled' in attributes && attributes.enabled !== null && attributes.enabled !== undefined) {
|
|
395
|
+
helpers.fillBooleanBitmapRange(this._buffer.enabled_values, startIdx, endIdx, attributes.enabled);
|
|
396
|
+
helpers.fillNullBitmapRange(this._buffer.enabled_nulls, startIdx, endIdx);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Pre-fill buffer with scoped attributes from current writeIndex to capacity.
|
|
402
|
+
* Called after buffer overflow to propagate scoped attributes to the new buffer.
|
|
403
|
+
*
|
|
404
|
+
* UNROLLED: Each column gets explicit code with bulk null bitmap operations
|
|
405
|
+
*/
|
|
406
|
+
|
|
407
|
+
_prefillScopedAttributes() {
|
|
408
|
+
const startIdx = this._buffer.writeIndex;
|
|
409
|
+
const endIdx = this._buffer.capacity;
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
{
|
|
413
|
+
const scopeValue = this._scope.userId;
|
|
414
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
415
|
+
// Fill string array with manual loop
|
|
416
|
+
const values = this._buffer.userId_values;
|
|
417
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
418
|
+
values[i] = scopeValue;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Bulk fill null bitmap using helper
|
|
422
|
+
helpers.fillNullBitmapRange(this._buffer.userId_nulls, startIdx, endIdx);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
{
|
|
427
|
+
const scopeValue = this._scope.operation;
|
|
428
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
429
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
430
|
+
this._buffer.operation_values.fill(getEnumIndex_operation(scopeValue), startIdx, endIdx);
|
|
431
|
+
|
|
432
|
+
// Bulk fill null bitmap using helper
|
|
433
|
+
helpers.fillNullBitmapRange(this._buffer.operation_nulls, startIdx, endIdx);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
{
|
|
438
|
+
const scopeValue = this._scope.errorMsg;
|
|
439
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
440
|
+
// Fill string array with manual loop
|
|
441
|
+
const values = this._buffer.errorMsg_values;
|
|
442
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
443
|
+
values[i] = scopeValue;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Bulk fill null bitmap using helper
|
|
447
|
+
helpers.fillNullBitmapRange(this._buffer.errorMsg_nulls, startIdx, endIdx);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
{
|
|
452
|
+
const scopeValue = this._scope.count;
|
|
453
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
454
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
455
|
+
this._buffer.count_values.fill(scopeValue, startIdx, endIdx);
|
|
456
|
+
|
|
457
|
+
// Bulk fill null bitmap using helper
|
|
458
|
+
helpers.fillNullBitmapRange(this._buffer.count_nulls, startIdx, endIdx);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
{
|
|
463
|
+
const scopeValue = this._scope.enabled;
|
|
464
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
465
|
+
helpers.fillBooleanBitmapRange(this._buffer.enabled_values, startIdx, endIdx, scopeValue);
|
|
466
|
+
helpers.fillNullBitmapRange(this._buffer.enabled_nulls, startIdx, endIdx);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Message logging methods
|
|
472
|
+
// UNROLLED: Scope attribute writes are explicit per-column, no Object.entries
|
|
473
|
+
|
|
474
|
+
_writeMessage(entryType, message) {
|
|
475
|
+
const result = this._getBufferWithSpace(this._buffer);
|
|
476
|
+
|
|
477
|
+
// If overflow occurred, pre-fill new buffer with scoped attributes
|
|
478
|
+
if (result.didOverflow) {
|
|
479
|
+
this._buffer = result.buffer;
|
|
480
|
+
this._prefillScopedAttributes();
|
|
481
|
+
} else {
|
|
482
|
+
this._buffer = result.buffer;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const idx = this._buffer.writeIndex;
|
|
486
|
+
|
|
487
|
+
// Write entry type
|
|
488
|
+
this._buffer.operations[idx] = entryType;
|
|
489
|
+
|
|
490
|
+
// Write timestamp (nanoseconds since epoch)
|
|
491
|
+
this._buffer.timestamps[idx] = getTimestampNanos();
|
|
492
|
+
|
|
493
|
+
// Write message to logMessage column (raw string, no interning)
|
|
494
|
+
const messageColumn = this._buffer.logMessage_values;
|
|
495
|
+
if (messageColumn) {
|
|
496
|
+
messageColumn[idx] = message;
|
|
497
|
+
helpers.setNullBit(this._buffer.logMessage_nulls, idx);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Apply scoped attributes - UNROLLED per-column
|
|
501
|
+
|
|
502
|
+
{
|
|
503
|
+
const scopeValue = this._scope.userId;
|
|
504
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
505
|
+
this._buffer.userId_values[idx] = scopeValue;
|
|
506
|
+
helpers.setNullBit(this._buffer.userId_nulls, idx);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
{
|
|
511
|
+
const scopeValue = this._scope.operation;
|
|
512
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
513
|
+
this._buffer.operation_values[idx] = getEnumIndex_operation(scopeValue);
|
|
514
|
+
helpers.setNullBit(this._buffer.operation_nulls, idx);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
{
|
|
519
|
+
const scopeValue = this._scope.errorMsg;
|
|
520
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
521
|
+
this._buffer.errorMsg_values[idx] = scopeValue;
|
|
522
|
+
helpers.setNullBit(this._buffer.errorMsg_nulls, idx);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
{
|
|
527
|
+
const scopeValue = this._scope.count;
|
|
528
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
529
|
+
this._buffer.count_values[idx] = scopeValue;
|
|
530
|
+
helpers.setNullBit(this._buffer.count_nulls, idx);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
{
|
|
535
|
+
const scopeValue = this._scope.enabled;
|
|
536
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
537
|
+
const byteIndex = idx >>> 3;
|
|
538
|
+
const bitOffset = idx & 7;
|
|
539
|
+
// Bit-packed boolean write
|
|
540
|
+
if (scopeValue) {
|
|
541
|
+
this._buffer.enabled_values[byteIndex] |= (1 << bitOffset);
|
|
542
|
+
} else {
|
|
543
|
+
this._buffer.enabled_values[byteIndex] &= ~(1 << bitOffset);
|
|
544
|
+
}
|
|
545
|
+
helpers.setNullBit(this._buffer.enabled_nulls, idx);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Increment write index
|
|
550
|
+
this._buffer.writeIndex++;
|
|
551
|
+
|
|
552
|
+
// Return fluent object for attribute chaining
|
|
553
|
+
// Capture buffer reference directly (not via self._buffer) so it's stable
|
|
554
|
+
// even if another log call happens before fluent methods are called
|
|
555
|
+
const buf = this._buffer;
|
|
556
|
+
return {
|
|
557
|
+
line(lineNumber) {
|
|
558
|
+
const lineCol = buf.lineNumber_values;
|
|
559
|
+
if (lineCol) {
|
|
560
|
+
lineCol[idx] = lineNumber;
|
|
561
|
+
helpers.setNullBit(buf.lineNumber_nulls, idx);
|
|
562
|
+
}
|
|
563
|
+
return this;
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
userId(value) {
|
|
567
|
+
buf.userId_values[idx] = value;
|
|
568
|
+
helpers.setNullBit(buf.userId_nulls, idx);
|
|
569
|
+
return this;
|
|
570
|
+
},
|
|
571
|
+
|
|
572
|
+
operation(value) {
|
|
573
|
+
buf.operation_values[idx] = getEnumIndex_operation(value);
|
|
574
|
+
helpers.setNullBit(buf.operation_nulls, idx);
|
|
575
|
+
return this;
|
|
576
|
+
},
|
|
577
|
+
|
|
578
|
+
errorMsg(value) {
|
|
579
|
+
buf.errorMsg_values[idx] = value;
|
|
580
|
+
helpers.setNullBit(buf.errorMsg_nulls, idx);
|
|
581
|
+
return this;
|
|
582
|
+
},
|
|
583
|
+
|
|
584
|
+
count(value) {
|
|
585
|
+
buf.count_values[idx] = value;
|
|
586
|
+
helpers.setNullBit(buf.count_nulls, idx);
|
|
587
|
+
return this;
|
|
588
|
+
},
|
|
589
|
+
|
|
590
|
+
enabled(value) {
|
|
591
|
+
const byteIndex = idx >>> 3;
|
|
592
|
+
const bitOffset = idx & 7;
|
|
593
|
+
if (value) {
|
|
594
|
+
buf.enabled_values[byteIndex] |= (1 << bitOffset);
|
|
595
|
+
} else {
|
|
596
|
+
buf.enabled_values[byteIndex] &= ~(1 << bitOffset);
|
|
597
|
+
}
|
|
598
|
+
helpers.setNullBit(buf.enabled_nulls, idx);
|
|
599
|
+
return this;
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
message(level, message) {
|
|
605
|
+
const entryTypeMap = {
|
|
606
|
+
'info': 9,
|
|
607
|
+
'debug': 10,
|
|
608
|
+
'warn': 11,
|
|
609
|
+
'error': 12
|
|
610
|
+
};
|
|
611
|
+
return this._writeMessage(entryTypeMap[level] || 9, message);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
info(message) {
|
|
615
|
+
return this._writeMessage(9, message);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
debug(message) {
|
|
619
|
+
return this._writeMessage(10, message);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
warn(message) {
|
|
623
|
+
return this._writeMessage(11, message);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
error(message) {
|
|
627
|
+
return this._writeMessage(12, message);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Get the Scope instance directly
|
|
631
|
+
_getScope() {
|
|
632
|
+
return this._scope;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return GeneratedSpanLogger;
|
|
637
|
+
"
|
|
638
|
+
`;
|
|
639
|
+
|
|
640
|
+
exports[`generateSpanLoggerClass snapshots snapshot: enum with many values 1`] = `
|
|
641
|
+
"
|
|
642
|
+
'use strict';
|
|
643
|
+
|
|
644
|
+
// Inline getTimestampNanos for performance (zero function call overhead)
|
|
645
|
+
// performance.timeOrigin + performance.now() gives epoch milliseconds with sub-ms precision
|
|
646
|
+
// Convert to microseconds first (safe as Number), then to nanoseconds as BigInt
|
|
647
|
+
function getTimestampNanos() {
|
|
648
|
+
const epochMicros = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
649
|
+
return BigInt(epochMicros) * 1000n;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
function getEnumIndex_httpMethod(value) {
|
|
654
|
+
switch(value) {
|
|
655
|
+
case "GET": return 0;
|
|
656
|
+
case "POST": return 1;
|
|
657
|
+
case "PUT": return 2;
|
|
658
|
+
case "PATCH": return 3;
|
|
659
|
+
case "DELETE": return 4;
|
|
660
|
+
case "HEAD": return 5;
|
|
661
|
+
case "OPTIONS": return 6;
|
|
662
|
+
default: return 0;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function getEnumIndex_status(value) {
|
|
667
|
+
switch(value) {
|
|
668
|
+
case "pending": return 0;
|
|
669
|
+
case "active": return 1;
|
|
670
|
+
case "completed": return 2;
|
|
671
|
+
case "failed": return 3;
|
|
672
|
+
case "cancelled": return 4;
|
|
673
|
+
default: return 0;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
class GeneratedSpanLogger {
|
|
678
|
+
constructor(buffer, getBufferWithSpace, scopeInstance) {
|
|
679
|
+
this._buffer = buffer;
|
|
680
|
+
this._getBufferWithSpace = getBufferWithSpace;
|
|
681
|
+
this._scope = scopeInstance;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// Tag getter - returns chainable API that writes to row 0 (span-start)
|
|
685
|
+
// Note: No overflow check needed - row 0 always exists
|
|
686
|
+
// Note: No writeIndex increment - always writing to same row (overwrite semantics)
|
|
687
|
+
get tag() {
|
|
688
|
+
// Entry type for row 0 is already span-start (set at buffer creation)
|
|
689
|
+
// Just return this for chaining - individual methods write to row 0
|
|
690
|
+
return this;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// with() method for bulk attribute setting - writes to row 0
|
|
694
|
+
// UNROLLED: Each column gets explicit code, no Object.entries iteration
|
|
695
|
+
|
|
696
|
+
with(attributes) {
|
|
697
|
+
|
|
698
|
+
if ('httpMethod' in attributes && attributes.httpMethod !== null && attributes.httpMethod !== undefined) {
|
|
699
|
+
this._buffer.httpMethod_values[0] = getEnumIndex_httpMethod(attributes.httpMethod);
|
|
700
|
+
this._buffer.httpMethod_nulls[0] |= 1;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if ('status' in attributes && attributes.status !== null && attributes.status !== undefined) {
|
|
704
|
+
this._buffer.status_values[0] = getEnumIndex_status(attributes.status);
|
|
705
|
+
this._buffer.status_nulls[0] |= 1;
|
|
706
|
+
}
|
|
707
|
+
return this;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// Attribute writer methods (generated from schema)
|
|
711
|
+
|
|
712
|
+
httpMethod(value) {
|
|
713
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
714
|
+
const idx = 0;
|
|
715
|
+
const enumIndex = getEnumIndex_httpMethod(value);
|
|
716
|
+
this._buffer.httpMethod_values[idx] = enumIndex;
|
|
717
|
+
|
|
718
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
719
|
+
const nullBitmap = this._buffer.httpMethod_nulls;
|
|
720
|
+
if (nullBitmap) {
|
|
721
|
+
nullBitmap[0] |= 1;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return this;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
status(value) {
|
|
728
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
729
|
+
const idx = 0;
|
|
730
|
+
const enumIndex = getEnumIndex_status(value);
|
|
731
|
+
this._buffer.status_values[idx] = enumIndex;
|
|
732
|
+
|
|
733
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
734
|
+
const nullBitmap = this._buffer.status_nulls;
|
|
735
|
+
if (nullBitmap) {
|
|
736
|
+
nullBitmap[0] |= 1;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return this;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// Scoped attributes - writes to Scope instance and pre-fills buffer
|
|
743
|
+
// NOTE: scope() exposed via ctx.scope, but SpanLogger provides _setScope for implementation
|
|
744
|
+
// UNROLLED: Each column gets explicit TypedArray.fill() + bulk null bitmap
|
|
745
|
+
|
|
746
|
+
_setScope(attributes) {
|
|
747
|
+
// Update the Scope instance (stores raw values, not interned)
|
|
748
|
+
|
|
749
|
+
if ('httpMethod' in attributes && attributes.httpMethod !== null && attributes.httpMethod !== undefined) {
|
|
750
|
+
this._scope.httpMethod = attributes.httpMethod;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if ('status' in attributes && attributes.status !== null && attributes.status !== undefined) {
|
|
754
|
+
this._scope.status = attributes.status;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// Pre-fill remaining buffer capacity with scoped attributes
|
|
758
|
+
const startIdx = this._buffer.writeIndex;
|
|
759
|
+
const endIdx = this._buffer.capacity;
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
if ('httpMethod' in attributes && attributes.httpMethod !== null && attributes.httpMethod !== undefined) {
|
|
763
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
764
|
+
this._buffer.httpMethod_values.fill(getEnumIndex_httpMethod(attributes.httpMethod), startIdx, endIdx);
|
|
765
|
+
|
|
766
|
+
// Bulk fill null bitmap using helper
|
|
767
|
+
helpers.fillNullBitmapRange(this._buffer.httpMethod_nulls, startIdx, endIdx);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if ('status' in attributes && attributes.status !== null && attributes.status !== undefined) {
|
|
771
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
772
|
+
this._buffer.status_values.fill(getEnumIndex_status(attributes.status), startIdx, endIdx);
|
|
773
|
+
|
|
774
|
+
// Bulk fill null bitmap using helper
|
|
775
|
+
helpers.fillNullBitmapRange(this._buffer.status_nulls, startIdx, endIdx);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Pre-fill buffer with scoped attributes from current writeIndex to capacity.
|
|
781
|
+
* Called after buffer overflow to propagate scoped attributes to the new buffer.
|
|
782
|
+
*
|
|
783
|
+
* UNROLLED: Each column gets explicit code with bulk null bitmap operations
|
|
784
|
+
*/
|
|
785
|
+
|
|
786
|
+
_prefillScopedAttributes() {
|
|
787
|
+
const startIdx = this._buffer.writeIndex;
|
|
788
|
+
const endIdx = this._buffer.capacity;
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
{
|
|
792
|
+
const scopeValue = this._scope.httpMethod;
|
|
793
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
794
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
795
|
+
this._buffer.httpMethod_values.fill(getEnumIndex_httpMethod(scopeValue), startIdx, endIdx);
|
|
796
|
+
|
|
797
|
+
// Bulk fill null bitmap using helper
|
|
798
|
+
helpers.fillNullBitmapRange(this._buffer.httpMethod_nulls, startIdx, endIdx);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
{
|
|
803
|
+
const scopeValue = this._scope.status;
|
|
804
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
805
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
806
|
+
this._buffer.status_values.fill(getEnumIndex_status(scopeValue), startIdx, endIdx);
|
|
807
|
+
|
|
808
|
+
// Bulk fill null bitmap using helper
|
|
809
|
+
helpers.fillNullBitmapRange(this._buffer.status_nulls, startIdx, endIdx);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// Message logging methods
|
|
815
|
+
// UNROLLED: Scope attribute writes are explicit per-column, no Object.entries
|
|
816
|
+
|
|
817
|
+
_writeMessage(entryType, message) {
|
|
818
|
+
const result = this._getBufferWithSpace(this._buffer);
|
|
819
|
+
|
|
820
|
+
// If overflow occurred, pre-fill new buffer with scoped attributes
|
|
821
|
+
if (result.didOverflow) {
|
|
822
|
+
this._buffer = result.buffer;
|
|
823
|
+
this._prefillScopedAttributes();
|
|
824
|
+
} else {
|
|
825
|
+
this._buffer = result.buffer;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
const idx = this._buffer.writeIndex;
|
|
829
|
+
|
|
830
|
+
// Write entry type
|
|
831
|
+
this._buffer.operations[idx] = entryType;
|
|
832
|
+
|
|
833
|
+
// Write timestamp (nanoseconds since epoch)
|
|
834
|
+
this._buffer.timestamps[idx] = getTimestampNanos();
|
|
835
|
+
|
|
836
|
+
// Write message to logMessage column (raw string, no interning)
|
|
837
|
+
const messageColumn = this._buffer.logMessage_values;
|
|
838
|
+
if (messageColumn) {
|
|
839
|
+
messageColumn[idx] = message;
|
|
840
|
+
helpers.setNullBit(this._buffer.logMessage_nulls, idx);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// Apply scoped attributes - UNROLLED per-column
|
|
844
|
+
|
|
845
|
+
{
|
|
846
|
+
const scopeValue = this._scope.httpMethod;
|
|
847
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
848
|
+
this._buffer.httpMethod_values[idx] = getEnumIndex_httpMethod(scopeValue);
|
|
849
|
+
helpers.setNullBit(this._buffer.httpMethod_nulls, idx);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
{
|
|
854
|
+
const scopeValue = this._scope.status;
|
|
855
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
856
|
+
this._buffer.status_values[idx] = getEnumIndex_status(scopeValue);
|
|
857
|
+
helpers.setNullBit(this._buffer.status_nulls, idx);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// Increment write index
|
|
862
|
+
this._buffer.writeIndex++;
|
|
863
|
+
|
|
864
|
+
// Return fluent object for attribute chaining
|
|
865
|
+
// Capture buffer reference directly (not via self._buffer) so it's stable
|
|
866
|
+
// even if another log call happens before fluent methods are called
|
|
867
|
+
const buf = this._buffer;
|
|
868
|
+
return {
|
|
869
|
+
line(lineNumber) {
|
|
870
|
+
const lineCol = buf.lineNumber_values;
|
|
871
|
+
if (lineCol) {
|
|
872
|
+
lineCol[idx] = lineNumber;
|
|
873
|
+
helpers.setNullBit(buf.lineNumber_nulls, idx);
|
|
874
|
+
}
|
|
875
|
+
return this;
|
|
876
|
+
},
|
|
877
|
+
|
|
878
|
+
httpMethod(value) {
|
|
879
|
+
buf.httpMethod_values[idx] = getEnumIndex_httpMethod(value);
|
|
880
|
+
helpers.setNullBit(buf.httpMethod_nulls, idx);
|
|
881
|
+
return this;
|
|
882
|
+
},
|
|
883
|
+
|
|
884
|
+
status(value) {
|
|
885
|
+
buf.status_values[idx] = getEnumIndex_status(value);
|
|
886
|
+
helpers.setNullBit(buf.status_nulls, idx);
|
|
887
|
+
return this;
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
message(level, message) {
|
|
893
|
+
const entryTypeMap = {
|
|
894
|
+
'info': 9,
|
|
895
|
+
'debug': 10,
|
|
896
|
+
'warn': 11,
|
|
897
|
+
'error': 12
|
|
898
|
+
};
|
|
899
|
+
return this._writeMessage(entryTypeMap[level] || 9, message);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
info(message) {
|
|
903
|
+
return this._writeMessage(9, message);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
debug(message) {
|
|
907
|
+
return this._writeMessage(10, message);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
warn(message) {
|
|
911
|
+
return this._writeMessage(11, message);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
error(message) {
|
|
915
|
+
return this._writeMessage(12, message);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// Get the Scope instance directly
|
|
919
|
+
_getScope() {
|
|
920
|
+
return this._scope;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
return GeneratedSpanLogger;
|
|
925
|
+
"
|
|
926
|
+
`;
|
|
927
|
+
|
|
928
|
+
exports[`generateSpanLoggerClass snapshots snapshot: category and text fields 1`] = `
|
|
929
|
+
"
|
|
930
|
+
'use strict';
|
|
931
|
+
|
|
932
|
+
// Inline getTimestampNanos for performance (zero function call overhead)
|
|
933
|
+
// performance.timeOrigin + performance.now() gives epoch milliseconds with sub-ms precision
|
|
934
|
+
// Convert to microseconds first (safe as Number), then to nanoseconds as BigInt
|
|
935
|
+
function getTimestampNanos() {
|
|
936
|
+
const epochMicros = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
937
|
+
return BigInt(epochMicros) * 1000n;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
class GeneratedSpanLogger {
|
|
943
|
+
constructor(buffer, getBufferWithSpace, scopeInstance) {
|
|
944
|
+
this._buffer = buffer;
|
|
945
|
+
this._getBufferWithSpace = getBufferWithSpace;
|
|
946
|
+
this._scope = scopeInstance;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Tag getter - returns chainable API that writes to row 0 (span-start)
|
|
950
|
+
// Note: No overflow check needed - row 0 always exists
|
|
951
|
+
// Note: No writeIndex increment - always writing to same row (overwrite semantics)
|
|
952
|
+
get tag() {
|
|
953
|
+
// Entry type for row 0 is already span-start (set at buffer creation)
|
|
954
|
+
// Just return this for chaining - individual methods write to row 0
|
|
955
|
+
return this;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// with() method for bulk attribute setting - writes to row 0
|
|
959
|
+
// UNROLLED: Each column gets explicit code, no Object.entries iteration
|
|
960
|
+
|
|
961
|
+
with(attributes) {
|
|
962
|
+
|
|
963
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
964
|
+
this._buffer.userId_values[0] = attributes.userId;
|
|
965
|
+
this._buffer.userId_nulls[0] |= 1;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
if ('sessionId' in attributes && attributes.sessionId !== null && attributes.sessionId !== undefined) {
|
|
969
|
+
this._buffer.sessionId_values[0] = attributes.sessionId;
|
|
970
|
+
this._buffer.sessionId_nulls[0] |= 1;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
if ('requestBody' in attributes && attributes.requestBody !== null && attributes.requestBody !== undefined) {
|
|
974
|
+
this._buffer.requestBody_values[0] = attributes.requestBody;
|
|
975
|
+
this._buffer.requestBody_nulls[0] |= 1;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
if ('errorMessage' in attributes && attributes.errorMessage !== null && attributes.errorMessage !== undefined) {
|
|
979
|
+
this._buffer.errorMessage_values[0] = attributes.errorMessage;
|
|
980
|
+
this._buffer.errorMessage_nulls[0] |= 1;
|
|
981
|
+
}
|
|
982
|
+
return this;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// Attribute writer methods (generated from schema)
|
|
986
|
+
|
|
987
|
+
userId(value) {
|
|
988
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
989
|
+
const idx = 0;
|
|
990
|
+
this._buffer.userId_values[idx] = value;
|
|
991
|
+
|
|
992
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
993
|
+
const nullBitmap = this._buffer.userId_nulls;
|
|
994
|
+
if (nullBitmap) {
|
|
995
|
+
nullBitmap[0] |= 1;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
sessionId(value) {
|
|
1002
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1003
|
+
const idx = 0;
|
|
1004
|
+
this._buffer.sessionId_values[idx] = value;
|
|
1005
|
+
|
|
1006
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1007
|
+
const nullBitmap = this._buffer.sessionId_nulls;
|
|
1008
|
+
if (nullBitmap) {
|
|
1009
|
+
nullBitmap[0] |= 1;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
return this;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
requestBody(value) {
|
|
1016
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1017
|
+
const idx = 0;
|
|
1018
|
+
const nullBitmap = this._buffer.requestBody_nulls;
|
|
1019
|
+
|
|
1020
|
+
// Handle null/undefined: clear null bitmap bit and return early
|
|
1021
|
+
if (value === null || value === undefined) {
|
|
1022
|
+
if (nullBitmap) {
|
|
1023
|
+
nullBitmap[0] &= ~1; // Clear bit 0
|
|
1024
|
+
}
|
|
1025
|
+
return this;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// Store the text value (raw string, no interning)
|
|
1029
|
+
this._buffer.requestBody_values[idx] = value;
|
|
1030
|
+
|
|
1031
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1032
|
+
if (nullBitmap) {
|
|
1033
|
+
nullBitmap[0] |= 1;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
return this;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
errorMessage(value) {
|
|
1040
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1041
|
+
const idx = 0;
|
|
1042
|
+
const nullBitmap = this._buffer.errorMessage_nulls;
|
|
1043
|
+
|
|
1044
|
+
// Handle null/undefined: clear null bitmap bit and return early
|
|
1045
|
+
if (value === null || value === undefined) {
|
|
1046
|
+
if (nullBitmap) {
|
|
1047
|
+
nullBitmap[0] &= ~1; // Clear bit 0
|
|
1048
|
+
}
|
|
1049
|
+
return this;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// Store the text value (raw string, no interning)
|
|
1053
|
+
this._buffer.errorMessage_values[idx] = value;
|
|
1054
|
+
|
|
1055
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1056
|
+
if (nullBitmap) {
|
|
1057
|
+
nullBitmap[0] |= 1;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
return this;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// Scoped attributes - writes to Scope instance and pre-fills buffer
|
|
1064
|
+
// NOTE: scope() exposed via ctx.scope, but SpanLogger provides _setScope for implementation
|
|
1065
|
+
// UNROLLED: Each column gets explicit TypedArray.fill() + bulk null bitmap
|
|
1066
|
+
|
|
1067
|
+
_setScope(attributes) {
|
|
1068
|
+
// Update the Scope instance (stores raw values, not interned)
|
|
1069
|
+
|
|
1070
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
1071
|
+
this._scope.userId = attributes.userId;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
if ('sessionId' in attributes && attributes.sessionId !== null && attributes.sessionId !== undefined) {
|
|
1075
|
+
this._scope.sessionId = attributes.sessionId;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
if ('requestBody' in attributes && attributes.requestBody !== null && attributes.requestBody !== undefined) {
|
|
1079
|
+
this._scope.requestBody = attributes.requestBody;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
if ('errorMessage' in attributes && attributes.errorMessage !== null && attributes.errorMessage !== undefined) {
|
|
1083
|
+
this._scope.errorMessage = attributes.errorMessage;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// Pre-fill remaining buffer capacity with scoped attributes
|
|
1087
|
+
const startIdx = this._buffer.writeIndex;
|
|
1088
|
+
const endIdx = this._buffer.capacity;
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
1092
|
+
// Fill string array with manual loop
|
|
1093
|
+
const values = this._buffer.userId_values;
|
|
1094
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1095
|
+
values[i] = attributes.userId;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// Bulk fill null bitmap using helper
|
|
1099
|
+
helpers.fillNullBitmapRange(this._buffer.userId_nulls, startIdx, endIdx);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
if ('sessionId' in attributes && attributes.sessionId !== null && attributes.sessionId !== undefined) {
|
|
1103
|
+
// Fill string array with manual loop
|
|
1104
|
+
const values = this._buffer.sessionId_values;
|
|
1105
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1106
|
+
values[i] = attributes.sessionId;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// Bulk fill null bitmap using helper
|
|
1110
|
+
helpers.fillNullBitmapRange(this._buffer.sessionId_nulls, startIdx, endIdx);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
if ('requestBody' in attributes && attributes.requestBody !== null && attributes.requestBody !== undefined) {
|
|
1114
|
+
// Fill string array with manual loop
|
|
1115
|
+
const values = this._buffer.requestBody_values;
|
|
1116
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1117
|
+
values[i] = attributes.requestBody;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// Bulk fill null bitmap using helper
|
|
1121
|
+
helpers.fillNullBitmapRange(this._buffer.requestBody_nulls, startIdx, endIdx);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
if ('errorMessage' in attributes && attributes.errorMessage !== null && attributes.errorMessage !== undefined) {
|
|
1125
|
+
// Fill string array with manual loop
|
|
1126
|
+
const values = this._buffer.errorMessage_values;
|
|
1127
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1128
|
+
values[i] = attributes.errorMessage;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// Bulk fill null bitmap using helper
|
|
1132
|
+
helpers.fillNullBitmapRange(this._buffer.errorMessage_nulls, startIdx, endIdx);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Pre-fill buffer with scoped attributes from current writeIndex to capacity.
|
|
1138
|
+
* Called after buffer overflow to propagate scoped attributes to the new buffer.
|
|
1139
|
+
*
|
|
1140
|
+
* UNROLLED: Each column gets explicit code with bulk null bitmap operations
|
|
1141
|
+
*/
|
|
1142
|
+
|
|
1143
|
+
_prefillScopedAttributes() {
|
|
1144
|
+
const startIdx = this._buffer.writeIndex;
|
|
1145
|
+
const endIdx = this._buffer.capacity;
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
{
|
|
1149
|
+
const scopeValue = this._scope.userId;
|
|
1150
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1151
|
+
// Fill string array with manual loop
|
|
1152
|
+
const values = this._buffer.userId_values;
|
|
1153
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1154
|
+
values[i] = scopeValue;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
// Bulk fill null bitmap using helper
|
|
1158
|
+
helpers.fillNullBitmapRange(this._buffer.userId_nulls, startIdx, endIdx);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
{
|
|
1163
|
+
const scopeValue = this._scope.sessionId;
|
|
1164
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1165
|
+
// Fill string array with manual loop
|
|
1166
|
+
const values = this._buffer.sessionId_values;
|
|
1167
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1168
|
+
values[i] = scopeValue;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// Bulk fill null bitmap using helper
|
|
1172
|
+
helpers.fillNullBitmapRange(this._buffer.sessionId_nulls, startIdx, endIdx);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
{
|
|
1177
|
+
const scopeValue = this._scope.requestBody;
|
|
1178
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1179
|
+
// Fill string array with manual loop
|
|
1180
|
+
const values = this._buffer.requestBody_values;
|
|
1181
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1182
|
+
values[i] = scopeValue;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
// Bulk fill null bitmap using helper
|
|
1186
|
+
helpers.fillNullBitmapRange(this._buffer.requestBody_nulls, startIdx, endIdx);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
{
|
|
1191
|
+
const scopeValue = this._scope.errorMessage;
|
|
1192
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1193
|
+
// Fill string array with manual loop
|
|
1194
|
+
const values = this._buffer.errorMessage_values;
|
|
1195
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1196
|
+
values[i] = scopeValue;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// Bulk fill null bitmap using helper
|
|
1200
|
+
helpers.fillNullBitmapRange(this._buffer.errorMessage_nulls, startIdx, endIdx);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// Message logging methods
|
|
1206
|
+
// UNROLLED: Scope attribute writes are explicit per-column, no Object.entries
|
|
1207
|
+
|
|
1208
|
+
_writeMessage(entryType, message) {
|
|
1209
|
+
const result = this._getBufferWithSpace(this._buffer);
|
|
1210
|
+
|
|
1211
|
+
// If overflow occurred, pre-fill new buffer with scoped attributes
|
|
1212
|
+
if (result.didOverflow) {
|
|
1213
|
+
this._buffer = result.buffer;
|
|
1214
|
+
this._prefillScopedAttributes();
|
|
1215
|
+
} else {
|
|
1216
|
+
this._buffer = result.buffer;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
const idx = this._buffer.writeIndex;
|
|
1220
|
+
|
|
1221
|
+
// Write entry type
|
|
1222
|
+
this._buffer.operations[idx] = entryType;
|
|
1223
|
+
|
|
1224
|
+
// Write timestamp (nanoseconds since epoch)
|
|
1225
|
+
this._buffer.timestamps[idx] = getTimestampNanos();
|
|
1226
|
+
|
|
1227
|
+
// Write message to logMessage column (raw string, no interning)
|
|
1228
|
+
const messageColumn = this._buffer.logMessage_values;
|
|
1229
|
+
if (messageColumn) {
|
|
1230
|
+
messageColumn[idx] = message;
|
|
1231
|
+
helpers.setNullBit(this._buffer.logMessage_nulls, idx);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// Apply scoped attributes - UNROLLED per-column
|
|
1235
|
+
|
|
1236
|
+
{
|
|
1237
|
+
const scopeValue = this._scope.userId;
|
|
1238
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1239
|
+
this._buffer.userId_values[idx] = scopeValue;
|
|
1240
|
+
helpers.setNullBit(this._buffer.userId_nulls, idx);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
{
|
|
1245
|
+
const scopeValue = this._scope.sessionId;
|
|
1246
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1247
|
+
this._buffer.sessionId_values[idx] = scopeValue;
|
|
1248
|
+
helpers.setNullBit(this._buffer.sessionId_nulls, idx);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
{
|
|
1253
|
+
const scopeValue = this._scope.requestBody;
|
|
1254
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1255
|
+
this._buffer.requestBody_values[idx] = scopeValue;
|
|
1256
|
+
helpers.setNullBit(this._buffer.requestBody_nulls, idx);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
{
|
|
1261
|
+
const scopeValue = this._scope.errorMessage;
|
|
1262
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1263
|
+
this._buffer.errorMessage_values[idx] = scopeValue;
|
|
1264
|
+
helpers.setNullBit(this._buffer.errorMessage_nulls, idx);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// Increment write index
|
|
1269
|
+
this._buffer.writeIndex++;
|
|
1270
|
+
|
|
1271
|
+
// Return fluent object for attribute chaining
|
|
1272
|
+
// Capture buffer reference directly (not via self._buffer) so it's stable
|
|
1273
|
+
// even if another log call happens before fluent methods are called
|
|
1274
|
+
const buf = this._buffer;
|
|
1275
|
+
return {
|
|
1276
|
+
line(lineNumber) {
|
|
1277
|
+
const lineCol = buf.lineNumber_values;
|
|
1278
|
+
if (lineCol) {
|
|
1279
|
+
lineCol[idx] = lineNumber;
|
|
1280
|
+
helpers.setNullBit(buf.lineNumber_nulls, idx);
|
|
1281
|
+
}
|
|
1282
|
+
return this;
|
|
1283
|
+
},
|
|
1284
|
+
|
|
1285
|
+
userId(value) {
|
|
1286
|
+
buf.userId_values[idx] = value;
|
|
1287
|
+
helpers.setNullBit(buf.userId_nulls, idx);
|
|
1288
|
+
return this;
|
|
1289
|
+
},
|
|
1290
|
+
|
|
1291
|
+
sessionId(value) {
|
|
1292
|
+
buf.sessionId_values[idx] = value;
|
|
1293
|
+
helpers.setNullBit(buf.sessionId_nulls, idx);
|
|
1294
|
+
return this;
|
|
1295
|
+
},
|
|
1296
|
+
|
|
1297
|
+
requestBody(value) {
|
|
1298
|
+
buf.requestBody_values[idx] = value;
|
|
1299
|
+
helpers.setNullBit(buf.requestBody_nulls, idx);
|
|
1300
|
+
return this;
|
|
1301
|
+
},
|
|
1302
|
+
|
|
1303
|
+
errorMessage(value) {
|
|
1304
|
+
buf.errorMessage_values[idx] = value;
|
|
1305
|
+
helpers.setNullBit(buf.errorMessage_nulls, idx);
|
|
1306
|
+
return this;
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
message(level, message) {
|
|
1312
|
+
const entryTypeMap = {
|
|
1313
|
+
'info': 9,
|
|
1314
|
+
'debug': 10,
|
|
1315
|
+
'warn': 11,
|
|
1316
|
+
'error': 12
|
|
1317
|
+
};
|
|
1318
|
+
return this._writeMessage(entryTypeMap[level] || 9, message);
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
info(message) {
|
|
1322
|
+
return this._writeMessage(9, message);
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
debug(message) {
|
|
1326
|
+
return this._writeMessage(10, message);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
warn(message) {
|
|
1330
|
+
return this._writeMessage(11, message);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
error(message) {
|
|
1334
|
+
return this._writeMessage(12, message);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
// Get the Scope instance directly
|
|
1338
|
+
_getScope() {
|
|
1339
|
+
return this._scope;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
return GeneratedSpanLogger;
|
|
1344
|
+
"
|
|
1345
|
+
`;
|
|
1346
|
+
|
|
1347
|
+
exports[`generateSpanLoggerClass snapshots snapshot: numeric and boolean fields 1`] = `
|
|
1348
|
+
"
|
|
1349
|
+
'use strict';
|
|
1350
|
+
|
|
1351
|
+
// Inline getTimestampNanos for performance (zero function call overhead)
|
|
1352
|
+
// performance.timeOrigin + performance.now() gives epoch milliseconds with sub-ms precision
|
|
1353
|
+
// Convert to microseconds first (safe as Number), then to nanoseconds as BigInt
|
|
1354
|
+
function getTimestampNanos() {
|
|
1355
|
+
const epochMicros = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
1356
|
+
return BigInt(epochMicros) * 1000n;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
class GeneratedSpanLogger {
|
|
1362
|
+
constructor(buffer, getBufferWithSpace, scopeInstance) {
|
|
1363
|
+
this._buffer = buffer;
|
|
1364
|
+
this._getBufferWithSpace = getBufferWithSpace;
|
|
1365
|
+
this._scope = scopeInstance;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
// Tag getter - returns chainable API that writes to row 0 (span-start)
|
|
1369
|
+
// Note: No overflow check needed - row 0 always exists
|
|
1370
|
+
// Note: No writeIndex increment - always writing to same row (overwrite semantics)
|
|
1371
|
+
get tag() {
|
|
1372
|
+
// Entry type for row 0 is already span-start (set at buffer creation)
|
|
1373
|
+
// Just return this for chaining - individual methods write to row 0
|
|
1374
|
+
return this;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
// with() method for bulk attribute setting - writes to row 0
|
|
1378
|
+
// UNROLLED: Each column gets explicit code, no Object.entries iteration
|
|
1379
|
+
|
|
1380
|
+
with(attributes) {
|
|
1381
|
+
|
|
1382
|
+
if ('count' in attributes && attributes.count !== null && attributes.count !== undefined) {
|
|
1383
|
+
this._buffer.count_values[0] = attributes.count;
|
|
1384
|
+
this._buffer.count_nulls[0] |= 1;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
if ('duration' in attributes && attributes.duration !== null && attributes.duration !== undefined) {
|
|
1388
|
+
this._buffer.duration_values[0] = attributes.duration;
|
|
1389
|
+
this._buffer.duration_nulls[0] |= 1;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
if ('isValid' in attributes && attributes.isValid !== null && attributes.isValid !== undefined) {
|
|
1393
|
+
// Bit-packed boolean write at index 0
|
|
1394
|
+
if (attributes.isValid) {
|
|
1395
|
+
this._buffer.isValid_values[0] |= 1;
|
|
1396
|
+
} else {
|
|
1397
|
+
this._buffer.isValid_values[0] &= ~1;
|
|
1398
|
+
}
|
|
1399
|
+
this._buffer.isValid_nulls[0] |= 1;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
if ('isEnabled' in attributes && attributes.isEnabled !== null && attributes.isEnabled !== undefined) {
|
|
1403
|
+
// Bit-packed boolean write at index 0
|
|
1404
|
+
if (attributes.isEnabled) {
|
|
1405
|
+
this._buffer.isEnabled_values[0] |= 1;
|
|
1406
|
+
} else {
|
|
1407
|
+
this._buffer.isEnabled_values[0] &= ~1;
|
|
1408
|
+
}
|
|
1409
|
+
this._buffer.isEnabled_nulls[0] |= 1;
|
|
1410
|
+
}
|
|
1411
|
+
return this;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// Attribute writer methods (generated from schema)
|
|
1415
|
+
|
|
1416
|
+
count(value) {
|
|
1417
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1418
|
+
const idx = 0;
|
|
1419
|
+
this._buffer.count_values[idx] = value;
|
|
1420
|
+
|
|
1421
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1422
|
+
const nullBitmap = this._buffer.count_nulls;
|
|
1423
|
+
if (nullBitmap) {
|
|
1424
|
+
nullBitmap[0] |= 1;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
return this;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
duration(value) {
|
|
1431
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1432
|
+
const idx = 0;
|
|
1433
|
+
this._buffer.duration_values[idx] = value;
|
|
1434
|
+
|
|
1435
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1436
|
+
const nullBitmap = this._buffer.duration_nulls;
|
|
1437
|
+
if (nullBitmap) {
|
|
1438
|
+
nullBitmap[0] |= 1;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
return this;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
isValid(value) {
|
|
1445
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1446
|
+
// Bit-packed: bit 0 of byte 0 is index 0
|
|
1447
|
+
if (value) {
|
|
1448
|
+
this._buffer.isValid_values[0] |= 1;
|
|
1449
|
+
} else {
|
|
1450
|
+
this._buffer.isValid_values[0] &= ~1;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1454
|
+
const nullBitmap = this._buffer.isValid_nulls;
|
|
1455
|
+
if (nullBitmap) {
|
|
1456
|
+
nullBitmap[0] |= 1;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
return this;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
isEnabled(value) {
|
|
1463
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1464
|
+
// Bit-packed: bit 0 of byte 0 is index 0
|
|
1465
|
+
if (value) {
|
|
1466
|
+
this._buffer.isEnabled_values[0] |= 1;
|
|
1467
|
+
} else {
|
|
1468
|
+
this._buffer.isEnabled_values[0] &= ~1;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1472
|
+
const nullBitmap = this._buffer.isEnabled_nulls;
|
|
1473
|
+
if (nullBitmap) {
|
|
1474
|
+
nullBitmap[0] |= 1;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
return this;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
// Scoped attributes - writes to Scope instance and pre-fills buffer
|
|
1481
|
+
// NOTE: scope() exposed via ctx.scope, but SpanLogger provides _setScope for implementation
|
|
1482
|
+
// UNROLLED: Each column gets explicit TypedArray.fill() + bulk null bitmap
|
|
1483
|
+
|
|
1484
|
+
_setScope(attributes) {
|
|
1485
|
+
// Update the Scope instance (stores raw values, not interned)
|
|
1486
|
+
|
|
1487
|
+
if ('count' in attributes && attributes.count !== null && attributes.count !== undefined) {
|
|
1488
|
+
this._scope.count = attributes.count;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
if ('duration' in attributes && attributes.duration !== null && attributes.duration !== undefined) {
|
|
1492
|
+
this._scope.duration = attributes.duration;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
if ('isValid' in attributes && attributes.isValid !== null && attributes.isValid !== undefined) {
|
|
1496
|
+
this._scope.isValid = attributes.isValid;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
if ('isEnabled' in attributes && attributes.isEnabled !== null && attributes.isEnabled !== undefined) {
|
|
1500
|
+
this._scope.isEnabled = attributes.isEnabled;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
// Pre-fill remaining buffer capacity with scoped attributes
|
|
1504
|
+
const startIdx = this._buffer.writeIndex;
|
|
1505
|
+
const endIdx = this._buffer.capacity;
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
if ('count' in attributes && attributes.count !== null && attributes.count !== undefined) {
|
|
1509
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
1510
|
+
this._buffer.count_values.fill(attributes.count, startIdx, endIdx);
|
|
1511
|
+
|
|
1512
|
+
// Bulk fill null bitmap using helper
|
|
1513
|
+
helpers.fillNullBitmapRange(this._buffer.count_nulls, startIdx, endIdx);
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
if ('duration' in attributes && attributes.duration !== null && attributes.duration !== undefined) {
|
|
1517
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
1518
|
+
this._buffer.duration_values.fill(attributes.duration, startIdx, endIdx);
|
|
1519
|
+
|
|
1520
|
+
// Bulk fill null bitmap using helper
|
|
1521
|
+
helpers.fillNullBitmapRange(this._buffer.duration_nulls, startIdx, endIdx);
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
if ('isValid' in attributes && attributes.isValid !== null && attributes.isValid !== undefined) {
|
|
1525
|
+
helpers.fillBooleanBitmapRange(this._buffer.isValid_values, startIdx, endIdx, attributes.isValid);
|
|
1526
|
+
helpers.fillNullBitmapRange(this._buffer.isValid_nulls, startIdx, endIdx);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
if ('isEnabled' in attributes && attributes.isEnabled !== null && attributes.isEnabled !== undefined) {
|
|
1530
|
+
helpers.fillBooleanBitmapRange(this._buffer.isEnabled_values, startIdx, endIdx, attributes.isEnabled);
|
|
1531
|
+
helpers.fillNullBitmapRange(this._buffer.isEnabled_nulls, startIdx, endIdx);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Pre-fill buffer with scoped attributes from current writeIndex to capacity.
|
|
1537
|
+
* Called after buffer overflow to propagate scoped attributes to the new buffer.
|
|
1538
|
+
*
|
|
1539
|
+
* UNROLLED: Each column gets explicit code with bulk null bitmap operations
|
|
1540
|
+
*/
|
|
1541
|
+
|
|
1542
|
+
_prefillScopedAttributes() {
|
|
1543
|
+
const startIdx = this._buffer.writeIndex;
|
|
1544
|
+
const endIdx = this._buffer.capacity;
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
{
|
|
1548
|
+
const scopeValue = this._scope.count;
|
|
1549
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1550
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
1551
|
+
this._buffer.count_values.fill(scopeValue, startIdx, endIdx);
|
|
1552
|
+
|
|
1553
|
+
// Bulk fill null bitmap using helper
|
|
1554
|
+
helpers.fillNullBitmapRange(this._buffer.count_nulls, startIdx, endIdx);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
{
|
|
1559
|
+
const scopeValue = this._scope.duration;
|
|
1560
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1561
|
+
// Fill values with SIMD-friendly TypedArray.fill()
|
|
1562
|
+
this._buffer.duration_values.fill(scopeValue, startIdx, endIdx);
|
|
1563
|
+
|
|
1564
|
+
// Bulk fill null bitmap using helper
|
|
1565
|
+
helpers.fillNullBitmapRange(this._buffer.duration_nulls, startIdx, endIdx);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
{
|
|
1570
|
+
const scopeValue = this._scope.isValid;
|
|
1571
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1572
|
+
helpers.fillBooleanBitmapRange(this._buffer.isValid_values, startIdx, endIdx, scopeValue);
|
|
1573
|
+
helpers.fillNullBitmapRange(this._buffer.isValid_nulls, startIdx, endIdx);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
{
|
|
1578
|
+
const scopeValue = this._scope.isEnabled;
|
|
1579
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1580
|
+
helpers.fillBooleanBitmapRange(this._buffer.isEnabled_values, startIdx, endIdx, scopeValue);
|
|
1581
|
+
helpers.fillNullBitmapRange(this._buffer.isEnabled_nulls, startIdx, endIdx);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// Message logging methods
|
|
1587
|
+
// UNROLLED: Scope attribute writes are explicit per-column, no Object.entries
|
|
1588
|
+
|
|
1589
|
+
_writeMessage(entryType, message) {
|
|
1590
|
+
const result = this._getBufferWithSpace(this._buffer);
|
|
1591
|
+
|
|
1592
|
+
// If overflow occurred, pre-fill new buffer with scoped attributes
|
|
1593
|
+
if (result.didOverflow) {
|
|
1594
|
+
this._buffer = result.buffer;
|
|
1595
|
+
this._prefillScopedAttributes();
|
|
1596
|
+
} else {
|
|
1597
|
+
this._buffer = result.buffer;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
const idx = this._buffer.writeIndex;
|
|
1601
|
+
|
|
1602
|
+
// Write entry type
|
|
1603
|
+
this._buffer.operations[idx] = entryType;
|
|
1604
|
+
|
|
1605
|
+
// Write timestamp (nanoseconds since epoch)
|
|
1606
|
+
this._buffer.timestamps[idx] = getTimestampNanos();
|
|
1607
|
+
|
|
1608
|
+
// Write message to logMessage column (raw string, no interning)
|
|
1609
|
+
const messageColumn = this._buffer.logMessage_values;
|
|
1610
|
+
if (messageColumn) {
|
|
1611
|
+
messageColumn[idx] = message;
|
|
1612
|
+
helpers.setNullBit(this._buffer.logMessage_nulls, idx);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
// Apply scoped attributes - UNROLLED per-column
|
|
1616
|
+
|
|
1617
|
+
{
|
|
1618
|
+
const scopeValue = this._scope.count;
|
|
1619
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1620
|
+
this._buffer.count_values[idx] = scopeValue;
|
|
1621
|
+
helpers.setNullBit(this._buffer.count_nulls, idx);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
{
|
|
1626
|
+
const scopeValue = this._scope.duration;
|
|
1627
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1628
|
+
this._buffer.duration_values[idx] = scopeValue;
|
|
1629
|
+
helpers.setNullBit(this._buffer.duration_nulls, idx);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
{
|
|
1634
|
+
const scopeValue = this._scope.isValid;
|
|
1635
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1636
|
+
const byteIndex = idx >>> 3;
|
|
1637
|
+
const bitOffset = idx & 7;
|
|
1638
|
+
// Bit-packed boolean write
|
|
1639
|
+
if (scopeValue) {
|
|
1640
|
+
this._buffer.isValid_values[byteIndex] |= (1 << bitOffset);
|
|
1641
|
+
} else {
|
|
1642
|
+
this._buffer.isValid_values[byteIndex] &= ~(1 << bitOffset);
|
|
1643
|
+
}
|
|
1644
|
+
helpers.setNullBit(this._buffer.isValid_nulls, idx);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
{
|
|
1649
|
+
const scopeValue = this._scope.isEnabled;
|
|
1650
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1651
|
+
const byteIndex = idx >>> 3;
|
|
1652
|
+
const bitOffset = idx & 7;
|
|
1653
|
+
// Bit-packed boolean write
|
|
1654
|
+
if (scopeValue) {
|
|
1655
|
+
this._buffer.isEnabled_values[byteIndex] |= (1 << bitOffset);
|
|
1656
|
+
} else {
|
|
1657
|
+
this._buffer.isEnabled_values[byteIndex] &= ~(1 << bitOffset);
|
|
1658
|
+
}
|
|
1659
|
+
helpers.setNullBit(this._buffer.isEnabled_nulls, idx);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// Increment write index
|
|
1664
|
+
this._buffer.writeIndex++;
|
|
1665
|
+
|
|
1666
|
+
// Return fluent object for attribute chaining
|
|
1667
|
+
// Capture buffer reference directly (not via self._buffer) so it's stable
|
|
1668
|
+
// even if another log call happens before fluent methods are called
|
|
1669
|
+
const buf = this._buffer;
|
|
1670
|
+
return {
|
|
1671
|
+
line(lineNumber) {
|
|
1672
|
+
const lineCol = buf.lineNumber_values;
|
|
1673
|
+
if (lineCol) {
|
|
1674
|
+
lineCol[idx] = lineNumber;
|
|
1675
|
+
helpers.setNullBit(buf.lineNumber_nulls, idx);
|
|
1676
|
+
}
|
|
1677
|
+
return this;
|
|
1678
|
+
},
|
|
1679
|
+
|
|
1680
|
+
count(value) {
|
|
1681
|
+
buf.count_values[idx] = value;
|
|
1682
|
+
helpers.setNullBit(buf.count_nulls, idx);
|
|
1683
|
+
return this;
|
|
1684
|
+
},
|
|
1685
|
+
|
|
1686
|
+
duration(value) {
|
|
1687
|
+
buf.duration_values[idx] = value;
|
|
1688
|
+
helpers.setNullBit(buf.duration_nulls, idx);
|
|
1689
|
+
return this;
|
|
1690
|
+
},
|
|
1691
|
+
|
|
1692
|
+
isValid(value) {
|
|
1693
|
+
const byteIndex = idx >>> 3;
|
|
1694
|
+
const bitOffset = idx & 7;
|
|
1695
|
+
if (value) {
|
|
1696
|
+
buf.isValid_values[byteIndex] |= (1 << bitOffset);
|
|
1697
|
+
} else {
|
|
1698
|
+
buf.isValid_values[byteIndex] &= ~(1 << bitOffset);
|
|
1699
|
+
}
|
|
1700
|
+
helpers.setNullBit(buf.isValid_nulls, idx);
|
|
1701
|
+
return this;
|
|
1702
|
+
},
|
|
1703
|
+
|
|
1704
|
+
isEnabled(value) {
|
|
1705
|
+
const byteIndex = idx >>> 3;
|
|
1706
|
+
const bitOffset = idx & 7;
|
|
1707
|
+
if (value) {
|
|
1708
|
+
buf.isEnabled_values[byteIndex] |= (1 << bitOffset);
|
|
1709
|
+
} else {
|
|
1710
|
+
buf.isEnabled_values[byteIndex] &= ~(1 << bitOffset);
|
|
1711
|
+
}
|
|
1712
|
+
helpers.setNullBit(buf.isEnabled_nulls, idx);
|
|
1713
|
+
return this;
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
message(level, message) {
|
|
1719
|
+
const entryTypeMap = {
|
|
1720
|
+
'info': 9,
|
|
1721
|
+
'debug': 10,
|
|
1722
|
+
'warn': 11,
|
|
1723
|
+
'error': 12
|
|
1724
|
+
};
|
|
1725
|
+
return this._writeMessage(entryTypeMap[level] || 9, message);
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
info(message) {
|
|
1729
|
+
return this._writeMessage(9, message);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
debug(message) {
|
|
1733
|
+
return this._writeMessage(10, message);
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
warn(message) {
|
|
1737
|
+
return this._writeMessage(11, message);
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
error(message) {
|
|
1741
|
+
return this._writeMessage(12, message);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
// Get the Scope instance directly
|
|
1745
|
+
_getScope() {
|
|
1746
|
+
return this._scope;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
return GeneratedSpanLogger;
|
|
1751
|
+
"
|
|
1752
|
+
`;
|
|
1753
|
+
|
|
1754
|
+
exports[`generateSpanLoggerClass snapshots snapshot: custom class name 1`] = `
|
|
1755
|
+
"
|
|
1756
|
+
'use strict';
|
|
1757
|
+
|
|
1758
|
+
// Inline getTimestampNanos for performance (zero function call overhead)
|
|
1759
|
+
// performance.timeOrigin + performance.now() gives epoch milliseconds with sub-ms precision
|
|
1760
|
+
// Convert to microseconds first (safe as Number), then to nanoseconds as BigInt
|
|
1761
|
+
function getTimestampNanos() {
|
|
1762
|
+
const epochMicros = Math.round((performance.timeOrigin + performance.now()) * 1000);
|
|
1763
|
+
return BigInt(epochMicros) * 1000n;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
class CustomSpanLogger {
|
|
1769
|
+
constructor(buffer, getBufferWithSpace, scopeInstance) {
|
|
1770
|
+
this._buffer = buffer;
|
|
1771
|
+
this._getBufferWithSpace = getBufferWithSpace;
|
|
1772
|
+
this._scope = scopeInstance;
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
// Tag getter - returns chainable API that writes to row 0 (span-start)
|
|
1776
|
+
// Note: No overflow check needed - row 0 always exists
|
|
1777
|
+
// Note: No writeIndex increment - always writing to same row (overwrite semantics)
|
|
1778
|
+
get tag() {
|
|
1779
|
+
// Entry type for row 0 is already span-start (set at buffer creation)
|
|
1780
|
+
// Just return this for chaining - individual methods write to row 0
|
|
1781
|
+
return this;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
// with() method for bulk attribute setting - writes to row 0
|
|
1785
|
+
// UNROLLED: Each column gets explicit code, no Object.entries iteration
|
|
1786
|
+
|
|
1787
|
+
with(attributes) {
|
|
1788
|
+
|
|
1789
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
1790
|
+
this._buffer.userId_values[0] = attributes.userId;
|
|
1791
|
+
this._buffer.userId_nulls[0] |= 1;
|
|
1792
|
+
}
|
|
1793
|
+
return this;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
// Attribute writer methods (generated from schema)
|
|
1797
|
+
|
|
1798
|
+
userId(value) {
|
|
1799
|
+
// ALWAYS write to row 0 (span-start) - overwrite semantics
|
|
1800
|
+
const idx = 0;
|
|
1801
|
+
this._buffer.userId_values[idx] = value;
|
|
1802
|
+
|
|
1803
|
+
// Mark as non-null (bit 0 for idx 0)
|
|
1804
|
+
const nullBitmap = this._buffer.userId_nulls;
|
|
1805
|
+
if (nullBitmap) {
|
|
1806
|
+
nullBitmap[0] |= 1;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
return this;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// Scoped attributes - writes to Scope instance and pre-fills buffer
|
|
1813
|
+
// NOTE: scope() exposed via ctx.scope, but SpanLogger provides _setScope for implementation
|
|
1814
|
+
// UNROLLED: Each column gets explicit TypedArray.fill() + bulk null bitmap
|
|
1815
|
+
|
|
1816
|
+
_setScope(attributes) {
|
|
1817
|
+
// Update the Scope instance (stores raw values, not interned)
|
|
1818
|
+
|
|
1819
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
1820
|
+
this._scope.userId = attributes.userId;
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
// Pre-fill remaining buffer capacity with scoped attributes
|
|
1824
|
+
const startIdx = this._buffer.writeIndex;
|
|
1825
|
+
const endIdx = this._buffer.capacity;
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
if ('userId' in attributes && attributes.userId !== null && attributes.userId !== undefined) {
|
|
1829
|
+
// Fill string array with manual loop
|
|
1830
|
+
const values = this._buffer.userId_values;
|
|
1831
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1832
|
+
values[i] = attributes.userId;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
// Bulk fill null bitmap using helper
|
|
1836
|
+
helpers.fillNullBitmapRange(this._buffer.userId_nulls, startIdx, endIdx);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* Pre-fill buffer with scoped attributes from current writeIndex to capacity.
|
|
1842
|
+
* Called after buffer overflow to propagate scoped attributes to the new buffer.
|
|
1843
|
+
*
|
|
1844
|
+
* UNROLLED: Each column gets explicit code with bulk null bitmap operations
|
|
1845
|
+
*/
|
|
1846
|
+
|
|
1847
|
+
_prefillScopedAttributes() {
|
|
1848
|
+
const startIdx = this._buffer.writeIndex;
|
|
1849
|
+
const endIdx = this._buffer.capacity;
|
|
1850
|
+
|
|
1851
|
+
|
|
1852
|
+
{
|
|
1853
|
+
const scopeValue = this._scope.userId;
|
|
1854
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1855
|
+
// Fill string array with manual loop
|
|
1856
|
+
const values = this._buffer.userId_values;
|
|
1857
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
1858
|
+
values[i] = scopeValue;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
// Bulk fill null bitmap using helper
|
|
1862
|
+
helpers.fillNullBitmapRange(this._buffer.userId_nulls, startIdx, endIdx);
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
// Message logging methods
|
|
1868
|
+
// UNROLLED: Scope attribute writes are explicit per-column, no Object.entries
|
|
1869
|
+
|
|
1870
|
+
_writeMessage(entryType, message) {
|
|
1871
|
+
const result = this._getBufferWithSpace(this._buffer);
|
|
1872
|
+
|
|
1873
|
+
// If overflow occurred, pre-fill new buffer with scoped attributes
|
|
1874
|
+
if (result.didOverflow) {
|
|
1875
|
+
this._buffer = result.buffer;
|
|
1876
|
+
this._prefillScopedAttributes();
|
|
1877
|
+
} else {
|
|
1878
|
+
this._buffer = result.buffer;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
const idx = this._buffer.writeIndex;
|
|
1882
|
+
|
|
1883
|
+
// Write entry type
|
|
1884
|
+
this._buffer.operations[idx] = entryType;
|
|
1885
|
+
|
|
1886
|
+
// Write timestamp (nanoseconds since epoch)
|
|
1887
|
+
this._buffer.timestamps[idx] = getTimestampNanos();
|
|
1888
|
+
|
|
1889
|
+
// Write message to logMessage column (raw string, no interning)
|
|
1890
|
+
const messageColumn = this._buffer.logMessage_values;
|
|
1891
|
+
if (messageColumn) {
|
|
1892
|
+
messageColumn[idx] = message;
|
|
1893
|
+
helpers.setNullBit(this._buffer.logMessage_nulls, idx);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
// Apply scoped attributes - UNROLLED per-column
|
|
1897
|
+
|
|
1898
|
+
{
|
|
1899
|
+
const scopeValue = this._scope.userId;
|
|
1900
|
+
if (scopeValue !== null && scopeValue !== undefined) {
|
|
1901
|
+
this._buffer.userId_values[idx] = scopeValue;
|
|
1902
|
+
helpers.setNullBit(this._buffer.userId_nulls, idx);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
// Increment write index
|
|
1907
|
+
this._buffer.writeIndex++;
|
|
1908
|
+
|
|
1909
|
+
// Return fluent object for attribute chaining
|
|
1910
|
+
// Capture buffer reference directly (not via self._buffer) so it's stable
|
|
1911
|
+
// even if another log call happens before fluent methods are called
|
|
1912
|
+
const buf = this._buffer;
|
|
1913
|
+
return {
|
|
1914
|
+
line(lineNumber) {
|
|
1915
|
+
const lineCol = buf.lineNumber_values;
|
|
1916
|
+
if (lineCol) {
|
|
1917
|
+
lineCol[idx] = lineNumber;
|
|
1918
|
+
helpers.setNullBit(buf.lineNumber_nulls, idx);
|
|
1919
|
+
}
|
|
1920
|
+
return this;
|
|
1921
|
+
},
|
|
1922
|
+
|
|
1923
|
+
userId(value) {
|
|
1924
|
+
buf.userId_values[idx] = value;
|
|
1925
|
+
helpers.setNullBit(buf.userId_nulls, idx);
|
|
1926
|
+
return this;
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
message(level, message) {
|
|
1932
|
+
const entryTypeMap = {
|
|
1933
|
+
'info': 9,
|
|
1934
|
+
'debug': 10,
|
|
1935
|
+
'warn': 11,
|
|
1936
|
+
'error': 12
|
|
1937
|
+
};
|
|
1938
|
+
return this._writeMessage(entryTypeMap[level] || 9, message);
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
info(message) {
|
|
1942
|
+
return this._writeMessage(9, message);
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
debug(message) {
|
|
1946
|
+
return this._writeMessage(10, message);
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
warn(message) {
|
|
1950
|
+
return this._writeMessage(11, message);
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
error(message) {
|
|
1954
|
+
return this._writeMessage(12, message);
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
// Get the Scope instance directly
|
|
1958
|
+
_getScope() {
|
|
1959
|
+
return this._scope;
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
return CustomSpanLogger;
|
|
1964
|
+
"
|
|
1965
|
+
`;
|