@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.
Files changed (447) hide show
  1. package/README.md +269 -0
  2. package/dist/allocator.wasm +0 -0
  3. package/dist/bun/preload.d.ts +11 -0
  4. package/dist/bun/preload.d.ts.map +1 -0
  5. package/dist/bun/preload.js +10 -0
  6. package/dist/bun/trace-preload.d.ts +8 -0
  7. package/dist/bun/trace-preload.d.ts.map +1 -0
  8. package/dist/bun/trace-preload.js +12 -0
  9. package/dist/es.d.ts +8 -0
  10. package/dist/es.d.ts.map +1 -0
  11. package/dist/es.js +9 -0
  12. package/dist/index.d.ts +41 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +84 -0
  15. package/dist/lib/JsBufferStrategy.d.ts +49 -0
  16. package/dist/lib/JsBufferStrategy.d.ts.map +1 -0
  17. package/dist/lib/JsBufferStrategy.js +60 -0
  18. package/dist/lib/archive/chunkCompaction.d.ts +15 -0
  19. package/dist/lib/archive/chunkCompaction.d.ts.map +1 -0
  20. package/dist/lib/archive/chunkCompaction.js +24 -0
  21. package/dist/lib/archive/chunkEnvelope.d.ts +21 -0
  22. package/dist/lib/archive/chunkEnvelope.d.ts.map +1 -0
  23. package/dist/lib/archive/chunkEnvelope.js +55 -0
  24. package/dist/lib/archive/chunkRouting.d.ts +10 -0
  25. package/dist/lib/archive/chunkRouting.d.ts.map +1 -0
  26. package/dist/lib/archive/chunkRouting.js +47 -0
  27. package/dist/lib/archive/chunkStats.d.ts +12 -0
  28. package/dist/lib/archive/chunkStats.d.ts.map +1 -0
  29. package/dist/lib/archive/chunkStats.js +10 -0
  30. package/dist/lib/archive/index.d.ts +5 -0
  31. package/dist/lib/archive/index.d.ts.map +1 -0
  32. package/dist/lib/archive/index.js +4 -0
  33. package/dist/lib/arrow/capacityStats.d.ts +9 -0
  34. package/dist/lib/arrow/capacityStats.d.ts.map +1 -0
  35. package/dist/lib/arrow/capacityStats.js +231 -0
  36. package/dist/lib/arrow/dictionaries.d.ts +27 -0
  37. package/dist/lib/arrow/dictionaries.d.ts.map +1 -0
  38. package/dist/lib/arrow/dictionaries.js +135 -0
  39. package/dist/lib/arrow/flechette.d.ts +40 -0
  40. package/dist/lib/arrow/flechette.d.ts.map +1 -0
  41. package/dist/lib/arrow/flechette.js +67 -0
  42. package/dist/lib/arrow/utils.d.ts +38 -0
  43. package/dist/lib/arrow/utils.d.ts.map +1 -0
  44. package/dist/lib/arrow/utils.js +112 -0
  45. package/dist/lib/buffer/Nanoseconds.d.ts +109 -0
  46. package/dist/lib/buffer/Nanoseconds.d.ts.map +1 -0
  47. package/dist/lib/buffer/Nanoseconds.js +86 -0
  48. package/dist/lib/bufferStrategy.d.ts +95 -0
  49. package/dist/lib/bufferStrategy.d.ts.map +1 -0
  50. package/dist/lib/bufferStrategy.js +1 -0
  51. package/dist/lib/capacityTuning.d.ts +50 -0
  52. package/dist/lib/capacityTuning.d.ts.map +1 -0
  53. package/dist/lib/capacityTuning.js +65 -0
  54. package/dist/lib/codegen/evaluatorGenerator.d.ts +35 -0
  55. package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -0
  56. package/dist/lib/codegen/evaluatorGenerator.js +199 -0
  57. package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +139 -0
  58. package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -0
  59. package/dist/lib/codegen/fixedPositionWriterGenerator.js +289 -0
  60. package/dist/lib/codegen/spanLoggerGenerator.d.ts +115 -0
  61. package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -0
  62. package/dist/lib/codegen/spanLoggerGenerator.js +575 -0
  63. package/dist/lib/convertToArrow.d.ts +40 -0
  64. package/dist/lib/convertToArrow.d.ts.map +1 -0
  65. package/dist/lib/convertToArrow.js +1467 -0
  66. package/dist/lib/defineOpContext.d.ts +96 -0
  67. package/dist/lib/defineOpContext.d.ts.map +1 -0
  68. package/dist/lib/defineOpContext.js +227 -0
  69. package/dist/lib/errors/Blocked.d.ts +113 -0
  70. package/dist/lib/errors/Blocked.d.ts.map +1 -0
  71. package/dist/lib/errors/Blocked.js +68 -0
  72. package/dist/lib/errors/CodeError.d.ts +101 -0
  73. package/dist/lib/errors/CodeError.d.ts.map +1 -0
  74. package/dist/lib/errors/CodeError.js +42 -0
  75. package/dist/lib/errors/RetriesExhausted.d.ts +67 -0
  76. package/dist/lib/errors/RetriesExhausted.d.ts.map +1 -0
  77. package/dist/lib/errors/RetriesExhausted.js +31 -0
  78. package/dist/lib/errors/Transient.d.ts +115 -0
  79. package/dist/lib/errors/Transient.d.ts.map +1 -0
  80. package/dist/lib/errors/Transient.js +54 -0
  81. package/dist/lib/errors/index.d.ts +14 -0
  82. package/dist/lib/errors/index.d.ts.map +1 -0
  83. package/dist/lib/errors/index.js +16 -0
  84. package/dist/lib/errors/retry-policy.d.ts +60 -0
  85. package/dist/lib/errors/retry-policy.d.ts.map +1 -0
  86. package/dist/lib/errors/retry-policy.js +54 -0
  87. package/dist/lib/flushScheduler.d.ts +162 -0
  88. package/dist/lib/flushScheduler.d.ts.map +1 -0
  89. package/dist/lib/flushScheduler.js +388 -0
  90. package/dist/lib/library.d.ts +149 -0
  91. package/dist/lib/library.d.ts.map +1 -0
  92. package/dist/lib/library.js +588 -0
  93. package/dist/lib/logApi.d.ts +61 -0
  94. package/dist/lib/logApi.d.ts.map +1 -0
  95. package/dist/lib/logApi.js +12 -0
  96. package/dist/lib/logBinding.d.ts +63 -0
  97. package/dist/lib/logBinding.d.ts.map +1 -0
  98. package/dist/lib/logBinding.js +1 -0
  99. package/dist/lib/op.d.ts +105 -0
  100. package/dist/lib/op.d.ts.map +1 -0
  101. package/dist/lib/op.js +59 -0
  102. package/dist/lib/opContext/contextTypes.d.ts +88 -0
  103. package/dist/lib/opContext/contextTypes.d.ts.map +1 -0
  104. package/dist/lib/opContext/contextTypes.js +34 -0
  105. package/dist/lib/opContext/createOpGroup.d.ts +57 -0
  106. package/dist/lib/opContext/createOpGroup.d.ts.map +1 -0
  107. package/dist/lib/opContext/createOpGroup.js +341 -0
  108. package/dist/lib/opContext/defineOp.d.ts +83 -0
  109. package/dist/lib/opContext/defineOp.d.ts.map +1 -0
  110. package/dist/lib/opContext/defineOp.js +197 -0
  111. package/dist/lib/opContext/featureFlagTypes.d.ts +58 -0
  112. package/dist/lib/opContext/featureFlagTypes.d.ts.map +1 -0
  113. package/dist/lib/opContext/featureFlagTypes.js +1 -0
  114. package/dist/lib/opContext/index.d.ts +13 -0
  115. package/dist/lib/opContext/index.d.ts.map +1 -0
  116. package/dist/lib/opContext/index.js +15 -0
  117. package/dist/lib/opContext/opGroupTypes.d.ts +250 -0
  118. package/dist/lib/opContext/opGroupTypes.d.ts.map +1 -0
  119. package/dist/lib/opContext/opGroupTypes.js +31 -0
  120. package/dist/lib/opContext/opTypes.d.ts +48 -0
  121. package/dist/lib/opContext/opTypes.d.ts.map +1 -0
  122. package/dist/lib/opContext/opTypes.js +7 -0
  123. package/dist/lib/opContext/spanContextTypes.d.ts +347 -0
  124. package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -0
  125. package/dist/lib/opContext/spanContextTypes.js +1 -0
  126. package/dist/lib/opContext/types.d.ts +297 -0
  127. package/dist/lib/opContext/types.d.ts.map +1 -0
  128. package/dist/lib/opContext/types.js +16 -0
  129. package/dist/lib/result.d.ts +308 -0
  130. package/dist/lib/result.d.ts.map +1 -0
  131. package/dist/lib/result.js +359 -0
  132. package/dist/lib/schema/LogSchema.d.ts +62 -0
  133. package/dist/lib/schema/LogSchema.d.ts.map +1 -0
  134. package/dist/lib/schema/LogSchema.js +134 -0
  135. package/dist/lib/schema/builder.d.ts +12 -0
  136. package/dist/lib/schema/builder.d.ts.map +1 -0
  137. package/dist/lib/schema/builder.js +169 -0
  138. package/dist/lib/schema/defineFeatureFlags.d.ts +60 -0
  139. package/dist/lib/schema/defineFeatureFlags.d.ts.map +1 -0
  140. package/dist/lib/schema/defineFeatureFlags.js +29 -0
  141. package/dist/lib/schema/defineLogSchema.d.ts +87 -0
  142. package/dist/lib/schema/defineLogSchema.d.ts.map +1 -0
  143. package/dist/lib/schema/defineLogSchema.js +171 -0
  144. package/dist/lib/schema/evaluator.d.ts +267 -0
  145. package/dist/lib/schema/evaluator.d.ts.map +1 -0
  146. package/dist/lib/schema/evaluator.js +169 -0
  147. package/dist/lib/schema/extend.d.ts +14 -0
  148. package/dist/lib/schema/extend.d.ts.map +1 -0
  149. package/dist/lib/schema/extend.js +51 -0
  150. package/dist/lib/schema/systemSchema.d.ts +112 -0
  151. package/dist/lib/schema/systemSchema.d.ts.map +1 -0
  152. package/dist/lib/schema/systemSchema.js +260 -0
  153. package/dist/lib/schema/typeGuards.d.ts +52 -0
  154. package/dist/lib/schema/typeGuards.d.ts.map +1 -0
  155. package/dist/lib/schema/typeGuards.js +127 -0
  156. package/dist/lib/schema/types.d.ts +156 -0
  157. package/dist/lib/schema/types.d.ts.map +1 -0
  158. package/dist/lib/schema/types.js +4 -0
  159. package/dist/lib/spanBuffer.d.ts +133 -0
  160. package/dist/lib/spanBuffer.d.ts.map +1 -0
  161. package/dist/lib/spanBuffer.js +442 -0
  162. package/dist/lib/spanBufferHelpers.d.ts +53 -0
  163. package/dist/lib/spanBufferHelpers.d.ts.map +1 -0
  164. package/dist/lib/spanBufferHelpers.js +65 -0
  165. package/dist/lib/spanBufferStats.d.ts +38 -0
  166. package/dist/lib/spanBufferStats.d.ts.map +1 -0
  167. package/dist/lib/spanBufferStats.js +1 -0
  168. package/dist/lib/spanContext.d.ts +141 -0
  169. package/dist/lib/spanContext.d.ts.map +1 -0
  170. package/dist/lib/spanContext.js +763 -0
  171. package/dist/lib/sqlite/index.d.ts +14 -0
  172. package/dist/lib/sqlite/index.d.ts.map +1 -0
  173. package/dist/lib/sqlite/index.js +12 -0
  174. package/dist/lib/sqlite/sqlite-async-writer.d.ts +24 -0
  175. package/dist/lib/sqlite/sqlite-async-writer.d.ts.map +1 -0
  176. package/dist/lib/sqlite/sqlite-async-writer.js +65 -0
  177. package/dist/lib/sqlite/sqlite-common.d.ts +37 -0
  178. package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -0
  179. package/dist/lib/sqlite/sqlite-common.js +207 -0
  180. package/dist/lib/sqlite/sqlite-d1.d.ts +25 -0
  181. package/dist/lib/sqlite/sqlite-d1.d.ts.map +1 -0
  182. package/dist/lib/sqlite/sqlite-d1.js +67 -0
  183. package/dist/lib/sqlite/sqlite-db.d.ts +29 -0
  184. package/dist/lib/sqlite/sqlite-db.d.ts.map +1 -0
  185. package/dist/lib/sqlite/sqlite-db.js +1 -0
  186. package/dist/lib/sqlite/sqlite-node.d.ts +16 -0
  187. package/dist/lib/sqlite/sqlite-node.d.ts.map +1 -0
  188. package/dist/lib/sqlite/sqlite-node.js +68 -0
  189. package/dist/lib/sqlite/sqlite-writer.d.ts +39 -0
  190. package/dist/lib/sqlite/sqlite-writer.d.ts.map +1 -0
  191. package/dist/lib/sqlite/sqlite-writer.js +78 -0
  192. package/dist/lib/testing/bun-harness.d.ts +150 -0
  193. package/dist/lib/testing/bun-harness.d.ts.map +1 -0
  194. package/dist/lib/testing/bun-harness.js +729 -0
  195. package/dist/lib/testing/extractFacts.d.ts +73 -0
  196. package/dist/lib/testing/extractFacts.d.ts.map +1 -0
  197. package/dist/lib/testing/extractFacts.js +237 -0
  198. package/dist/lib/testing/facts.d.ts +235 -0
  199. package/dist/lib/testing/facts.d.ts.map +1 -0
  200. package/dist/lib/testing/facts.js +209 -0
  201. package/dist/lib/testing/index.d.ts +58 -0
  202. package/dist/lib/testing/index.d.ts.map +1 -0
  203. package/dist/lib/testing/index.js +74 -0
  204. package/dist/lib/testing/queryable-span.d.ts +39 -0
  205. package/dist/lib/testing/queryable-span.d.ts.map +1 -0
  206. package/dist/lib/testing/queryable-span.js +58 -0
  207. package/dist/lib/testing/span-query.d.ts +21 -0
  208. package/dist/lib/testing/span-query.d.ts.map +1 -0
  209. package/dist/lib/testing/span-query.js +47 -0
  210. package/dist/lib/testing/stdio-replay.d.ts +4 -0
  211. package/dist/lib/testing/stdio-replay.d.ts.map +1 -0
  212. package/dist/lib/testing/stdio-replay.js +42 -0
  213. package/dist/lib/testing/trace-query.d.ts +59 -0
  214. package/dist/lib/testing/trace-query.d.ts.map +1 -0
  215. package/dist/lib/testing/trace-query.js +462 -0
  216. package/dist/lib/testing/vitest-harness.d.ts +135 -0
  217. package/dist/lib/testing/vitest-harness.d.ts.map +1 -0
  218. package/dist/lib/testing/vitest-harness.js +486 -0
  219. package/dist/lib/threadId.d.ts +58 -0
  220. package/dist/lib/threadId.d.ts.map +1 -0
  221. package/dist/lib/threadId.js +123 -0
  222. package/dist/lib/traceContext.d.ts +116 -0
  223. package/dist/lib/traceContext.d.ts.map +1 -0
  224. package/dist/lib/traceContext.js +37 -0
  225. package/dist/lib/traceId.d.ts +78 -0
  226. package/dist/lib/traceId.d.ts.map +1 -0
  227. package/dist/lib/traceId.js +87 -0
  228. package/dist/lib/traceRoot.d.ts +133 -0
  229. package/dist/lib/traceRoot.d.ts.map +1 -0
  230. package/dist/lib/traceRoot.es.d.ts +75 -0
  231. package/dist/lib/traceRoot.es.d.ts.map +1 -0
  232. package/dist/lib/traceRoot.es.js +129 -0
  233. package/dist/lib/traceRoot.js +19 -0
  234. package/dist/lib/traceRoot.node.d.ts +77 -0
  235. package/dist/lib/traceRoot.node.d.ts.map +1 -0
  236. package/dist/lib/traceRoot.node.js +133 -0
  237. package/dist/lib/traceRoot.universal.d.ts +3 -0
  238. package/dist/lib/traceRoot.universal.d.ts.map +1 -0
  239. package/dist/lib/traceRoot.universal.js +17 -0
  240. package/dist/lib/tracer.d.ts +296 -0
  241. package/dist/lib/tracer.d.ts.map +1 -0
  242. package/dist/lib/tracer.js +346 -0
  243. package/dist/lib/tracers/ArrayQueueTracer.d.ts +56 -0
  244. package/dist/lib/tracers/ArrayQueueTracer.d.ts.map +1 -0
  245. package/dist/lib/tracers/ArrayQueueTracer.js +67 -0
  246. package/dist/lib/tracers/CompositeTracer.d.ts +24 -0
  247. package/dist/lib/tracers/CompositeTracer.d.ts.map +1 -0
  248. package/dist/lib/tracers/CompositeTracer.js +57 -0
  249. package/dist/lib/tracers/NoOpTracer.d.ts +58 -0
  250. package/dist/lib/tracers/NoOpTracer.d.ts.map +1 -0
  251. package/dist/lib/tracers/NoOpTracer.js +41 -0
  252. package/dist/lib/tracers/SQLiteTracer.d.ts +42 -0
  253. package/dist/lib/tracers/SQLiteTracer.d.ts.map +1 -0
  254. package/dist/lib/tracers/SQLiteTracer.js +84 -0
  255. package/dist/lib/tracers/StdioTracer.d.ts +83 -0
  256. package/dist/lib/tracers/StdioTracer.d.ts.map +1 -0
  257. package/dist/lib/tracers/StdioTracer.js +270 -0
  258. package/dist/lib/tracers/TestTracer.d.ts +95 -0
  259. package/dist/lib/tracers/TestTracer.d.ts.map +1 -0
  260. package/dist/lib/tracers/TestTracer.js +87 -0
  261. package/dist/lib/tracers/index.d.ts +12 -0
  262. package/dist/lib/tracers/index.d.ts.map +1 -0
  263. package/dist/lib/tracers/index.js +11 -0
  264. package/dist/lib/types.d.ts +366 -0
  265. package/dist/lib/types.d.ts.map +1 -0
  266. package/dist/lib/types.js +1 -0
  267. package/dist/lib/utf8Cache.d.ts +111 -0
  268. package/dist/lib/utf8Cache.d.ts.map +1 -0
  269. package/dist/lib/utf8Cache.js +177 -0
  270. package/dist/lib/wasm/WasmBufferStrategy.d.ts +88 -0
  271. package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -0
  272. package/dist/lib/wasm/WasmBufferStrategy.js +138 -0
  273. package/dist/lib/wasm/wasmAllocator.d.ts +109 -0
  274. package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -0
  275. package/dist/lib/wasm/wasmAllocator.js +227 -0
  276. package/dist/lib/wasm/wasmSpanBuffer.d.ts +123 -0
  277. package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -0
  278. package/dist/lib/wasm/wasmSpanBuffer.js +772 -0
  279. package/dist/lib/wasm/wasmTraceRoot.d.ts +167 -0
  280. package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -0
  281. package/dist/lib/wasm/wasmTraceRoot.js +264 -0
  282. package/dist/node.d.ts +7 -0
  283. package/dist/node.d.ts.map +1 -0
  284. package/dist/node.js +8 -0
  285. package/dist/testing.d.ts +18 -0
  286. package/dist/testing.d.ts.map +1 -0
  287. package/dist/testing.js +17 -0
  288. package/package.json +193 -0
  289. package/src/bun/preload.ts +11 -0
  290. package/src/bun/trace-preload.ts +14 -0
  291. package/src/es.ts +11 -0
  292. package/src/index.ts +194 -0
  293. package/src/lib/JsBufferStrategy.ts +102 -0
  294. package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +485 -0
  295. package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +390 -0
  296. package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +647 -0
  297. package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +292 -0
  298. package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +354 -0
  299. package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +127 -0
  300. package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +392 -0
  301. package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +389 -0
  302. package/src/lib/__tests__/arrow-conversion-algorithms.test.ts +54 -0
  303. package/src/lib/__tests__/arrow-test-helpers.ts +71 -0
  304. package/src/lib/__tests__/binary-e2e.test.ts +203 -0
  305. package/src/lib/__tests__/buffer-overflow-op-api.test.ts +608 -0
  306. package/src/lib/__tests__/buffer-overflow.test.ts +612 -0
  307. package/src/lib/__tests__/capacity-tuning.test.ts +544 -0
  308. package/src/lib/__tests__/effective-schema.test.ts +439 -0
  309. package/src/lib/__tests__/flechette.test.ts +42 -0
  310. package/src/lib/__tests__/flushScheduler.test.ts +537 -0
  311. package/src/lib/__tests__/integration.test.ts +600 -0
  312. package/src/lib/__tests__/library.test.ts +934 -0
  313. package/src/lib/__tests__/nested-library-tasks.test.ts +849 -0
  314. package/src/lib/__tests__/op-context-binding.test.ts +135 -0
  315. package/src/lib/__tests__/op-metadata.test.ts +198 -0
  316. package/src/lib/__tests__/op-type-safety.test.ts +71 -0
  317. package/src/lib/__tests__/package-exports.test.ts +57 -0
  318. package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +319 -0
  319. package/src/lib/__tests__/remapped-buffer-view.test.ts +635 -0
  320. package/src/lib/__tests__/scope-attributes.test.ts +348 -0
  321. package/src/lib/__tests__/span-lifecycle.test.ts +680 -0
  322. package/src/lib/__tests__/sync-async-trace.test.ts +435 -0
  323. package/src/lib/__tests__/test-helpers.ts +318 -0
  324. package/src/lib/__tests__/timestamp.test.ts +259 -0
  325. package/src/lib/__tests__/trace-archive-primitives.test.ts +98 -0
  326. package/src/lib/__tests__/traceContext-type-enforcement.test.ts +271 -0
  327. package/src/lib/__tests__/tracer.test.ts +211 -0
  328. package/src/lib/__tests__/type-narrowing.test.ts +137 -0
  329. package/src/lib/archive/chunkCompaction.ts +44 -0
  330. package/src/lib/archive/chunkEnvelope.ts +79 -0
  331. package/src/lib/archive/chunkRouting.ts +70 -0
  332. package/src/lib/archive/chunkStats.ts +25 -0
  333. package/src/lib/archive/index.ts +4 -0
  334. package/src/lib/arrow/capacityStats.ts +340 -0
  335. package/src/lib/arrow/dictionaries.ts +159 -0
  336. package/src/lib/arrow/flechette.ts +114 -0
  337. package/src/lib/arrow/utils.ts +126 -0
  338. package/src/lib/buffer/Nanoseconds.ts +131 -0
  339. package/src/lib/bufferStrategy.ts +106 -0
  340. package/src/lib/capacityTuning.ts +102 -0
  341. package/src/lib/codegen/__tests__/__snapshots__/evaluatorGenerator.test.ts.snap +160 -0
  342. package/src/lib/codegen/__tests__/__snapshots__/scopeGenerator.test.ts.snap +196 -0
  343. package/src/lib/codegen/__tests__/__snapshots__/spanLoggerGenerator.test.ts.snap +1965 -0
  344. package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +516 -0
  345. package/src/lib/codegen/__tests__/nullBitmap.test.ts +207 -0
  346. package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +237 -0
  347. package/src/lib/codegen/evaluatorGenerator.ts +309 -0
  348. package/src/lib/codegen/fixedPositionWriterGenerator.ts +444 -0
  349. package/src/lib/codegen/spanLoggerGenerator.ts +715 -0
  350. package/src/lib/convertToArrow.ts +1805 -0
  351. package/src/lib/defineOpContext.ts +398 -0
  352. package/src/lib/errors/Blocked.ts +165 -0
  353. package/src/lib/errors/CodeError.ts +132 -0
  354. package/src/lib/errors/RetriesExhausted.ts +78 -0
  355. package/src/lib/errors/Transient.ts +168 -0
  356. package/src/lib/errors/__tests__/Blocked-config.test.ts +152 -0
  357. package/src/lib/errors/__tests__/Transient.test.ts +129 -0
  358. package/src/lib/errors/__tests__/retry-policy.test.ts +85 -0
  359. package/src/lib/errors/index.ts +24 -0
  360. package/src/lib/errors/retry-policy.ts +87 -0
  361. package/src/lib/flushScheduler.ts +509 -0
  362. package/src/lib/library.ts +682 -0
  363. package/src/lib/logApi.ts +70 -0
  364. package/src/lib/logBinding.ts +67 -0
  365. package/src/lib/op.ts +103 -0
  366. package/src/lib/opContext/__tests__/retry.test.ts +764 -0
  367. package/src/lib/opContext/contextTypes.ts +130 -0
  368. package/src/lib/opContext/createOpGroup.ts +456 -0
  369. package/src/lib/opContext/defineOp.ts +281 -0
  370. package/src/lib/opContext/featureFlagTypes.ts +54 -0
  371. package/src/lib/opContext/index.ts +16 -0
  372. package/src/lib/opContext/opGroupTypes.ts +342 -0
  373. package/src/lib/opContext/opTypes.ts +80 -0
  374. package/src/lib/opContext/spanContextTypes.ts +398 -0
  375. package/src/lib/opContext/types.ts +403 -0
  376. package/src/lib/result.ts +550 -0
  377. package/src/lib/schema/LogSchema.ts +153 -0
  378. package/src/lib/schema/__tests__/defineLogSchema.test.ts +342 -0
  379. package/src/lib/schema/__tests__/featureFlags.test.ts +443 -0
  380. package/src/lib/schema/builder.ts +201 -0
  381. package/src/lib/schema/defineFeatureFlags.ts +91 -0
  382. package/src/lib/schema/defineLogSchema.ts +291 -0
  383. package/src/lib/schema/evaluator.ts +404 -0
  384. package/src/lib/schema/extend.ts +69 -0
  385. package/src/lib/schema/systemSchema.ts +339 -0
  386. package/src/lib/schema/typeGuards.ts +163 -0
  387. package/src/lib/schema/types.ts +265 -0
  388. package/src/lib/spanBuffer.ts +571 -0
  389. package/src/lib/spanBufferHelpers.ts +73 -0
  390. package/src/lib/spanBufferStats.ts +40 -0
  391. package/src/lib/spanContext.ts +1566 -0
  392. package/src/lib/sqlite/__tests__/sqlite-common.test.ts +89 -0
  393. package/src/lib/sqlite/index.ts +26 -0
  394. package/src/lib/sqlite/sqlite-async-writer.ts +101 -0
  395. package/src/lib/sqlite/sqlite-common.ts +309 -0
  396. package/src/lib/sqlite/sqlite-d1.ts +104 -0
  397. package/src/lib/sqlite/sqlite-db.ts +32 -0
  398. package/src/lib/sqlite/sqlite-node.ts +83 -0
  399. package/src/lib/sqlite/sqlite-writer.ts +128 -0
  400. package/src/lib/testing/TRACE-TESTING.md +100 -0
  401. package/src/lib/testing/__tests__/bun-harness.test.ts +108 -0
  402. package/src/lib/testing/__tests__/extractFacts.test.ts +279 -0
  403. package/src/lib/testing/__tests__/facts.test.ts +324 -0
  404. package/src/lib/testing/__tests__/vitest-harness.test.ts +32 -0
  405. package/src/lib/testing/bun-harness.ts +990 -0
  406. package/src/lib/testing/extractFacts.ts +362 -0
  407. package/src/lib/testing/facts.ts +470 -0
  408. package/src/lib/testing/index.ts +141 -0
  409. package/src/lib/testing/queryable-span.ts +108 -0
  410. package/src/lib/testing/span-query.ts +65 -0
  411. package/src/lib/testing/stdio-replay.ts +50 -0
  412. package/src/lib/testing/trace-query.ts +329 -0
  413. package/src/lib/testing/vitest-harness.ts +691 -0
  414. package/src/lib/threadId.ts +135 -0
  415. package/src/lib/traceContext.ts +182 -0
  416. package/src/lib/traceId.ts +142 -0
  417. package/src/lib/traceRoot.es.ts +157 -0
  418. package/src/lib/traceRoot.node.ts +170 -0
  419. package/src/lib/traceRoot.ts +154 -0
  420. package/src/lib/traceRoot.universal.ts +22 -0
  421. package/src/lib/tracer.ts +896 -0
  422. package/src/lib/tracers/ArrayQueueTracer.ts +76 -0
  423. package/src/lib/tracers/CompositeTracer.ts +76 -0
  424. package/src/lib/tracers/NoOpTracer.ts +73 -0
  425. package/src/lib/tracers/SQLiteTracer.ts +115 -0
  426. package/src/lib/tracers/StdioTracer.ts +380 -0
  427. package/src/lib/tracers/TestTracer.ts +146 -0
  428. package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +184 -0
  429. package/src/lib/tracers/__tests__/NoOpTracer.test.ts +204 -0
  430. package/src/lib/tracers/__tests__/StdioTracer.test.ts +313 -0
  431. package/src/lib/tracers/__tests__/TestTracer.test.ts +200 -0
  432. package/src/lib/tracers/index.ts +12 -0
  433. package/src/lib/types.ts +498 -0
  434. package/src/lib/utf8Cache.ts +201 -0
  435. package/src/lib/wasm/WasmBufferStrategy.ts +219 -0
  436. package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +256 -0
  437. package/src/lib/wasm/__tests__/wasm-integration.test.ts +476 -0
  438. package/src/lib/wasm/__tests__/wasmAllocator.test.ts +699 -0
  439. package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +449 -0
  440. package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +390 -0
  441. package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +444 -0
  442. package/src/lib/wasm/allocator.zig +945 -0
  443. package/src/lib/wasm/wasmAllocator.ts +469 -0
  444. package/src/lib/wasm/wasmSpanBuffer.ts +1014 -0
  445. package/src/lib/wasm/wasmTraceRoot.ts +315 -0
  446. package/src/node.ts +10 -0
  447. 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
+ `;