@smoothbricks/lmao 0.2.2 → 0.2.3
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/dist/allocator.wasm +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/JsBufferStrategy.d.ts +4 -3
- package/dist/lib/JsBufferStrategy.d.ts.map +1 -1
- package/dist/lib/JsBufferStrategy.js +18 -11
- package/dist/lib/arrow/lease.d.ts +10 -0
- package/dist/lib/arrow/lease.d.ts.map +1 -0
- package/dist/lib/arrow/lease.js +33 -0
- package/dist/lib/arrow/utils.d.ts +3 -4
- package/dist/lib/arrow/utils.d.ts.map +1 -1
- package/dist/lib/arrow/utils.js +12 -13
- package/dist/lib/arrow/vocabularyDictionary.d.ts +21 -0
- package/dist/lib/arrow/vocabularyDictionary.d.ts.map +1 -0
- package/dist/lib/arrow/vocabularyDictionary.js +95 -0
- package/dist/lib/bufferStrategy.d.ts +3 -2
- package/dist/lib/bufferStrategy.d.ts.map +1 -1
- package/dist/lib/cloudflare/traceRows.d.ts.map +1 -1
- package/dist/lib/cloudflare/traceRows.js +3 -2
- package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/evaluatorGenerator.js +12 -11
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +44 -82
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/fixedPositionWriterGenerator.js +223 -162
- package/dist/lib/codegen/spanLoggerClosureMaterializer.d.ts +63 -0
- package/dist/lib/codegen/spanLoggerClosureMaterializer.d.ts.map +1 -0
- package/dist/lib/codegen/spanLoggerClosureMaterializer.js +447 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts +36 -19
- package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/spanLoggerGenerator.js +164 -158
- package/dist/lib/convertToArrow.d.ts +7 -2
- package/dist/lib/convertToArrow.d.ts.map +1 -1
- package/dist/lib/convertToArrow.js +499 -285
- package/dist/lib/defineOpContext.js +1 -1
- package/dist/lib/enumMetadata.d.ts +19 -0
- package/dist/lib/enumMetadata.d.ts.map +1 -0
- package/dist/lib/enumMetadata.js +86 -0
- package/dist/lib/flushScheduler.d.ts.map +1 -1
- package/dist/lib/flushScheduler.js +13 -4
- package/dist/lib/library.d.ts +16 -98
- package/dist/lib/library.d.ts.map +1 -1
- package/dist/lib/library.js +32 -525
- package/dist/lib/logBinding.d.ts +21 -27
- package/dist/lib/logBinding.d.ts.map +1 -1
- package/dist/lib/op.d.ts +30 -30
- package/dist/lib/op.d.ts.map +1 -1
- package/dist/lib/op.js +15 -22
- package/dist/lib/opContext/createOpGroup.d.ts +1 -1
- package/dist/lib/opContext/createOpGroup.d.ts.map +1 -1
- package/dist/lib/opContext/createOpGroup.js +22 -29
- package/dist/lib/opContext/defineOp.d.ts +4 -4
- package/dist/lib/opContext/defineOp.d.ts.map +1 -1
- package/dist/lib/opContext/defineOp.js +53 -10
- package/dist/lib/opContext/opGroupTypes.d.ts +2 -2
- package/dist/lib/opContext/opTypes.d.ts +1 -1
- package/dist/lib/opContext/opTypes.d.ts.map +1 -1
- package/dist/lib/opContext/spanContextTypes.d.ts +29 -14
- package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -1
- package/dist/lib/opContext/types.d.ts +4 -4
- package/dist/lib/opContext/types.d.ts.map +1 -1
- package/dist/lib/physicalLayoutPlan.d.ts +89 -0
- package/dist/lib/physicalLayoutPlan.d.ts.map +1 -0
- package/dist/lib/physicalLayoutPlan.js +442 -0
- package/dist/lib/resolveMessage.d.ts +9 -0
- package/dist/lib/resolveMessage.d.ts.map +1 -0
- package/dist/lib/resolveMessage.js +63 -0
- package/dist/lib/result.d.ts +5 -7
- package/dist/lib/result.d.ts.map +1 -1
- package/dist/lib/result.js +19 -26
- package/dist/lib/runtimeHint.d.ts +35 -0
- package/dist/lib/runtimeHint.d.ts.map +1 -0
- package/dist/lib/runtimeHint.js +79 -0
- package/dist/lib/schema/types.d.ts +1 -1
- package/dist/lib/schema/types.d.ts.map +1 -1
- package/dist/lib/span-buffer/aot/v1.d.ts +2 -0
- package/dist/lib/span-buffer/aot/v1.d.ts.map +1 -0
- package/dist/lib/span-buffer/aot/v1.js +24 -0
- package/dist/lib/spanBuffer.d.ts +33 -4
- package/dist/lib/spanBuffer.d.ts.map +1 -1
- package/dist/lib/spanBuffer.js +583 -91
- package/dist/lib/spanBufferStats.d.ts +1 -1
- package/dist/lib/spanBufferStats.d.ts.map +1 -1
- package/dist/lib/spanContext.d.ts +27 -51
- package/dist/lib/spanContext.d.ts.map +1 -1
- package/dist/lib/spanContext.js +822 -344
- package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -1
- package/dist/lib/sqlite/sqlite-common.js +20 -21
- package/dist/lib/testing/bun-harness.d.ts +8 -3
- package/dist/lib/testing/bun-harness.d.ts.map +1 -1
- package/dist/lib/testing/bun-harness.js +30 -18
- package/dist/lib/testing/extractFacts.d.ts +1 -1
- package/dist/lib/testing/extractFacts.d.ts.map +1 -1
- package/dist/lib/testing/extractFacts.js +55 -63
- package/dist/lib/testing/facts.d.ts +1 -1
- package/dist/lib/testing/facts.d.ts.map +1 -1
- package/dist/lib/testing/queryable-span.d.ts +1 -1
- package/dist/lib/testing/queryable-span.d.ts.map +1 -1
- package/dist/lib/testing/queryable-span.js +26 -28
- package/dist/lib/testing/span-query.d.ts.map +1 -1
- package/dist/lib/testing/span-query.js +19 -22
- package/dist/lib/testing/stdio-replay.d.ts.map +1 -1
- package/dist/lib/testing/stdio-replay.js +19 -8
- package/dist/lib/threadId.d.ts.map +1 -1
- package/dist/lib/threadId.js +6 -3
- package/dist/lib/traceRoot.d.ts +30 -8
- package/dist/lib/traceRoot.d.ts.map +1 -1
- package/dist/lib/traceRoot.es.d.ts +17 -15
- package/dist/lib/traceRoot.es.d.ts.map +1 -1
- package/dist/lib/traceRoot.es.js +68 -34
- package/dist/lib/traceRoot.js +11 -0
- package/dist/lib/traceRoot.node.d.ts +17 -19
- package/dist/lib/traceRoot.node.d.ts.map +1 -1
- package/dist/lib/traceRoot.node.js +66 -38
- package/dist/lib/traceTopology.d.ts +42 -0
- package/dist/lib/traceTopology.d.ts.map +1 -0
- package/dist/lib/traceTopology.js +260 -0
- package/dist/lib/tracer.d.ts +9 -5
- package/dist/lib/tracer.d.ts.map +1 -1
- package/dist/lib/tracer.js +65 -71
- package/dist/lib/tracers/ArrayQueueTracer.d.ts +1 -1
- package/dist/lib/tracers/ArrayQueueTracer.js +1 -1
- package/dist/lib/tracers/StdioTracer.d.ts.map +1 -1
- package/dist/lib/tracers/StdioTracer.js +15 -13
- package/dist/lib/tracers/TestTracer.d.ts +4 -6
- package/dist/lib/tracers/TestTracer.d.ts.map +1 -1
- package/dist/lib/tracers/TestTracer.js +6 -8
- package/dist/lib/types.d.ts +49 -32
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/vocabularyRegistry.d.ts +25 -0
- package/dist/lib/vocabularyRegistry.d.ts.map +1 -0
- package/dist/lib/vocabularyRegistry.js +372 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts +6 -10
- package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -1
- package/dist/lib/wasm/WasmBufferStrategy.js +44 -37
- package/dist/lib/wasm/wasmAllocator.d.ts +27 -22
- package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -1
- package/dist/lib/wasm/wasmAllocator.js +66 -44
- package/dist/lib/wasm/wasmPhysicalLayout.d.ts +67 -0
- package/dist/lib/wasm/wasmPhysicalLayout.d.ts.map +1 -0
- package/dist/lib/wasm/wasmPhysicalLayout.js +179 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts +79 -31
- package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -1
- package/dist/lib/wasm/wasmSpanBuffer.js +442 -272
- package/dist/lib/wasm/wasmTraceRoot.d.ts +24 -22
- package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -1
- package/dist/lib/wasm/wasmTraceRoot.js +110 -71
- package/dist/vocabulary/register/v1.d.ts +2 -0
- package/dist/vocabulary/register/v1.d.ts.map +1 -0
- package/dist/vocabulary/register/v1.js +1 -0
- package/dist/wasm.d.ts +5 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +4 -0
- package/package.json +54 -6
- package/src/index.ts +1 -0
- package/src/lib/JsBufferStrategy.ts +27 -9
- package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +335 -37
- package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +97 -26
- package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +75 -15
- package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +30 -6
- package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +18 -21
- package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +5 -2
- package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +25 -7
- package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +3 -2
- package/src/lib/__tests__/buffer-overflow.test.ts +24 -18
- package/src/lib/__tests__/capability-span-context.test.ts +505 -0
- package/src/lib/__tests__/capacity-tuning.test.ts +5 -3
- package/src/lib/__tests__/eager-columns.test.ts +345 -0
- package/src/lib/__tests__/enum-metadata-aot.test.ts +153 -0
- package/src/lib/__tests__/enum-metadata.test.ts +177 -0
- package/src/lib/__tests__/fixtures/empty-vocabulary-runtime.fixture.ts +15 -0
- package/src/lib/__tests__/flushScheduler.test.ts +5 -1
- package/src/lib/__tests__/identity-view.property.test.ts +179 -0
- package/src/lib/__tests__/library.test.ts +19 -235
- package/src/lib/__tests__/message-buffer-families.test.ts +878 -0
- package/src/lib/__tests__/nested-library-tasks.test.ts +14 -15
- package/src/lib/__tests__/op-metadata.test.ts +1 -1
- package/src/lib/__tests__/op-type-safety.test.ts +5 -16
- package/src/lib/__tests__/physical-layout-plan.test.ts +333 -0
- package/src/lib/__tests__/remap-descriptor-integration.test.ts +381 -0
- package/src/lib/__tests__/root-context-construction.test.ts +414 -0
- package/src/lib/__tests__/span-auto-runtime.test.ts +386 -0
- package/src/lib/__tests__/span-buffer-segment-stats.test.ts +221 -0
- package/src/lib/__tests__/span-lifecycle.test.ts +53 -25
- package/src/lib/__tests__/spanbuffer-materializer-parity.test.ts +266 -0
- package/src/lib/__tests__/sync-async-trace.test.ts +24 -23
- package/src/lib/__tests__/tag-writer-aot.test.ts +214 -0
- package/src/lib/__tests__/test-helpers.ts +67 -12
- package/src/lib/__tests__/threadId.test.ts +62 -0
- package/src/lib/__tests__/timestamp.test.ts +221 -93
- package/src/lib/__tests__/traceTopology.property.test.ts +383 -0
- package/src/lib/__tests__/type-narrowing.test.ts +63 -0
- package/src/lib/__tests__/vocabulary-dense-decoding.test.ts +405 -0
- package/src/lib/__tests__/vocabularyRegistry.test.ts +313 -0
- package/src/lib/arrow/lease.ts +43 -0
- package/src/lib/arrow/utils.ts +10 -14
- package/src/lib/arrow/vocabularyDictionary.ts +123 -0
- package/src/lib/bufferStrategy.ts +9 -1
- package/src/lib/cloudflare/traceRows.ts +3 -2
- package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +21 -141
- package/src/lib/codegen/__tests__/fixedPositionWriter-parity.test.ts +273 -0
- package/src/lib/codegen/__tests__/fixedPositionWriter-uint64.test.ts +61 -34
- package/src/lib/codegen/__tests__/nullBitmap.test.ts +33 -37
- package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +34 -18
- package/src/lib/codegen/__tests__/spanLoggerMaterializerParity.test.ts +503 -0
- package/src/lib/codegen/evaluatorGenerator.ts +18 -13
- package/src/lib/codegen/fixedPositionWriterGenerator.ts +329 -245
- package/src/lib/codegen/spanLoggerClosureMaterializer.ts +598 -0
- package/src/lib/codegen/spanLoggerGenerator.ts +241 -177
- package/src/lib/convertToArrow.ts +598 -311
- package/src/lib/defineOpContext.ts +1 -1
- package/src/lib/enumMetadata.ts +121 -0
- package/src/lib/flushScheduler.ts +11 -5
- package/src/lib/library.ts +37 -595
- package/src/lib/logBinding.ts +21 -27
- package/src/lib/op.ts +75 -18
- package/src/lib/opContext/__tests__/retry.test.ts +27 -21
- package/src/lib/opContext/createOpGroup.ts +33 -31
- package/src/lib/opContext/defineOp.ts +88 -11
- package/src/lib/opContext/opGroupTypes.ts +2 -2
- package/src/lib/opContext/opTypes.ts +1 -1
- package/src/lib/opContext/spanContextTypes.ts +98 -17
- package/src/lib/opContext/types.ts +7 -3
- package/src/lib/physicalLayoutPlan.ts +598 -0
- package/src/lib/resolveMessage.ts +67 -0
- package/src/lib/result.ts +20 -33
- package/src/lib/runtimeHint.ts +98 -0
- package/src/lib/schema/__tests__/featureFlags.test.ts +2 -1
- package/src/lib/schema/builder.ts +1 -1
- package/src/lib/schema/types.ts +1 -1
- package/src/lib/span-buffer/aot/v1.ts +26 -0
- package/src/lib/spanBuffer.ts +658 -92
- package/src/lib/spanBufferStats.ts +1 -1
- package/src/lib/spanContext.ts +1350 -861
- package/src/lib/sqlite/sqlite-common.ts +20 -31
- package/src/lib/testing/__tests__/topology-traversal.test.ts +174 -0
- package/src/lib/testing/__tests__/vitest-harness.test.ts +2 -1
- package/src/lib/testing/bun-harness.ts +94 -43
- package/src/lib/testing/extractFacts.ts +64 -78
- package/src/lib/testing/facts.ts +1 -1
- package/src/lib/testing/queryable-span.ts +23 -30
- package/src/lib/testing/span-query.ts +16 -20
- package/src/lib/testing/stdio-replay.ts +25 -8
- package/src/lib/testing/vitest-harness.ts +1 -1
- package/src/lib/threadId.ts +6 -3
- package/src/lib/traceRoot.es.ts +77 -42
- package/src/lib/traceRoot.node.ts +75 -46
- package/src/lib/traceRoot.ts +41 -14
- package/src/lib/traceTopology.ts +279 -0
- package/src/lib/tracer.ts +109 -98
- package/src/lib/tracers/ArrayQueueTracer.ts +1 -1
- package/src/lib/tracers/StdioTracer.ts +15 -13
- package/src/lib/tracers/TestTracer.ts +6 -8
- package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +15 -10
- package/src/lib/tracers/__tests__/TestTracer.test.ts +23 -13
- package/src/lib/types.ts +64 -33
- package/src/lib/vocabularyRegistry.ts +439 -0
- package/src/lib/wasm/WasmBufferStrategy.ts +56 -48
- package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +215 -11
- package/src/lib/wasm/__tests__/allocatorFreeBlockClamp.test.ts +86 -0
- package/src/lib/wasm/__tests__/wasm-identity-view.test.ts +311 -0
- package/src/lib/wasm/__tests__/wasm-integration.test.ts +417 -44
- package/src/lib/wasm/__tests__/wasm-message-buffer-families.test.ts +588 -0
- package/src/lib/wasm/__tests__/wasmAllocator.test.ts +100 -668
- package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +419 -63
- package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +24 -29
- package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +2 -2
- package/src/lib/wasm/wasmAllocator.ts +131 -96
- package/src/lib/wasm/wasmPhysicalLayout.ts +309 -0
- package/src/lib/wasm/wasmSpanBuffer.ts +597 -341
- package/src/lib/wasm/wasmTraceRoot.ts +140 -78
- package/src/vocabulary/register/v1.ts +1 -0
- package/src/wasm.ts +19 -0
- package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +0 -319
- package/src/lib/__tests__/remapped-buffer-view.test.ts +0 -635
- package/src/lib/wasm/allocator.zig +0 -948
package/dist/lib/spanContext.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/* biome-ignore-all lint/complexity/noArguments: hot-path overload dispatch avoids rest-arg allocations */
|
|
2
|
-
import { createTagWriter } from './codegen/fixedPositionWriterGenerator.js';
|
|
3
2
|
import { createSpanLogger as createSpanLoggerFromGenerator, } from './codegen/spanLoggerGenerator.js';
|
|
4
|
-
import { Blocked } from './errors/Blocked.js';
|
|
5
3
|
import { TransientError } from './errors/Transient.js';
|
|
6
|
-
import { Op } from './op.js';
|
|
7
4
|
import { Err, hasErrorCode, Ok } from './result.js';
|
|
5
|
+
import { RUNTIME_HINT_DEPS, RUNTIME_HINT_FF, RUNTIME_HINT_FULL_CAPABILITIES, RUNTIME_HINT_LOG, RUNTIME_HINT_RESULT, RUNTIME_HINT_SCOPE, RUNTIME_HINT_SPAN, RUNTIME_HINT_TAG, } from './runtimeHint.js';
|
|
8
6
|
import { ENTRY_TYPE_SPAN_ERR, ENTRY_TYPE_SPAN_EXCEPTION, ENTRY_TYPE_SPAN_OK, ENTRY_TYPE_SPAN_RETRY, } from './schema/systemSchema.js';
|
|
9
7
|
// Note: TraceRoot.writeSpanStart() is used instead of direct timestamp writes.
|
|
10
8
|
// The platform-specific TraceRoot (traceRoot.es.ts or traceRoot.node.ts) handles
|
|
@@ -17,8 +15,15 @@ import { ENTRY_TYPE_SPAN_ERR, ENTRY_TYPE_SPAN_EXCEPTION, ENTRY_TYPE_SPAN_OK, ENT
|
|
|
17
15
|
* Used for type guards and prototype chain detection
|
|
18
16
|
*/
|
|
19
17
|
export const SPAN_CONTEXT_MARKER = Symbol.for('lmao.SpanContext');
|
|
18
|
+
function isOpLike(value) {
|
|
19
|
+
return (typeof value === 'object' &&
|
|
20
|
+
value !== null &&
|
|
21
|
+
typeof Reflect.get(value, 'fn') === 'function' &&
|
|
22
|
+
typeof Reflect.get(value, 'callsitePlan') === 'object' &&
|
|
23
|
+
typeof Reflect.get(value, 'metadata') === 'object');
|
|
24
|
+
}
|
|
20
25
|
function isOpInstance(value) {
|
|
21
|
-
return value
|
|
26
|
+
return isOpLike(value);
|
|
22
27
|
}
|
|
23
28
|
// WHY: resolveSpanTarget() accepts either an Op instance or a raw span
|
|
24
29
|
// function. TypeScript needs an explicit predicate here to preserve the call
|
|
@@ -26,43 +31,19 @@ function isOpInstance(value) {
|
|
|
26
31
|
function isSpanDispatchFn(value) {
|
|
27
32
|
return typeof value === 'function';
|
|
28
33
|
}
|
|
29
|
-
function isSpanBufferConstructorForSchema(value, schema) {
|
|
30
|
-
return (typeof value === 'function' &&
|
|
31
|
-
Reflect.get(value, 'schema') === schema &&
|
|
32
|
-
typeof Reflect.get(value, 'stats') === 'object');
|
|
33
|
-
}
|
|
34
|
-
function getBufferConstructor(buffer) {
|
|
35
|
-
const ctor = buffer.constructor;
|
|
36
|
-
if (!isSpanBufferConstructorForSchema(ctor, buffer._logSchema)) {
|
|
37
|
-
throw new TypeError('Span buffer constructor does not match the buffer schema');
|
|
38
|
-
}
|
|
39
|
-
return ctor;
|
|
40
|
-
}
|
|
41
|
-
function isSpanBufferForSchema(buffer, schema) {
|
|
42
|
-
return (typeof buffer === 'object' &&
|
|
43
|
-
buffer !== null &&
|
|
44
|
-
Reflect.get(buffer, '_logSchema') === schema &&
|
|
45
|
-
isSpanBufferConstructorForSchema(Reflect.get(buffer, 'constructor'), schema));
|
|
46
|
-
}
|
|
47
34
|
function isSpanContextInstance(value) {
|
|
48
35
|
return (isSpanContext(value) &&
|
|
36
|
+
Reflect.has(value, '_spanBuffer') &&
|
|
49
37
|
Reflect.has(value, '_buffer') &&
|
|
50
|
-
Reflect.has(value, '
|
|
51
|
-
Reflect.has(value, '
|
|
38
|
+
Reflect.has(value, '_schema') &&
|
|
39
|
+
Reflect.has(value, '_logBinding') &&
|
|
40
|
+
Reflect.has(value, '_physicalLayoutPlan'));
|
|
52
41
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw new TypeError('Failed to create child span context');
|
|
42
|
+
function asSpanContextInstance(value) {
|
|
43
|
+
if (!isSpanContextInstance(value)) {
|
|
44
|
+
throw new TypeError('Callsite plan created an invalid child span context');
|
|
57
45
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
function createInheritedContextWithOverrides(parent, overrides) {
|
|
61
|
-
const child = Object.assign(Object.create(parent), overrides);
|
|
62
|
-
if (!isSpanContextInstance(child)) {
|
|
63
|
-
throw new TypeError('Failed to create overridden child span context');
|
|
64
|
-
}
|
|
65
|
-
return child;
|
|
46
|
+
return value;
|
|
66
47
|
}
|
|
67
48
|
function readStringArgument(args, index, label) {
|
|
68
49
|
const value = args[index];
|
|
@@ -71,11 +52,10 @@ function readStringArgument(args, index, label) {
|
|
|
71
52
|
}
|
|
72
53
|
return value;
|
|
73
54
|
}
|
|
74
|
-
function resolveSpanTarget(value,
|
|
55
|
+
function resolveSpanTarget(value, fallbackPlan, fallbackMetadata) {
|
|
75
56
|
if (isOpInstance(value)) {
|
|
76
57
|
return {
|
|
77
|
-
|
|
78
|
-
remappedViewClass: value.remappedViewClass,
|
|
58
|
+
callsitePlan: value.callsitePlan,
|
|
79
59
|
opMetadata: value.metadata,
|
|
80
60
|
fn: value.fn,
|
|
81
61
|
};
|
|
@@ -84,12 +64,19 @@ function resolveSpanTarget(value, fallbackBuffer) {
|
|
|
84
64
|
throw new TypeError('span() expects an Op or function');
|
|
85
65
|
}
|
|
86
66
|
return {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
opMetadata: fallbackBuffer._opMetadata,
|
|
67
|
+
callsitePlan: fallbackPlan,
|
|
68
|
+
opMetadata: fallbackMetadata,
|
|
90
69
|
fn: value,
|
|
91
70
|
};
|
|
92
71
|
}
|
|
72
|
+
function isSynchronousResult(value) {
|
|
73
|
+
return value instanceof Ok || value instanceof Err;
|
|
74
|
+
}
|
|
75
|
+
function getRetryableError(result, attempt) {
|
|
76
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
77
|
+
return undefined;
|
|
78
|
+
return attempt < result.error.policy.maxAttempts ? result.error : undefined;
|
|
79
|
+
}
|
|
93
80
|
// =============================================================================
|
|
94
81
|
// Helper Functions
|
|
95
82
|
// =============================================================================
|
|
@@ -109,21 +96,12 @@ function resolveSpanTarget(value, fallbackBuffer) {
|
|
|
109
96
|
*/
|
|
110
97
|
export function writeSpanStart(buffer, spanName) {
|
|
111
98
|
// Delegate to TraceRoot - platform-specific implementation handles timestamps
|
|
112
|
-
buffer._traceRoot.
|
|
99
|
+
buffer._traceRoot._writeSpanStart(buffer._traceRoot, buffer, spanName);
|
|
113
100
|
}
|
|
114
101
|
//#endregion smoo/lmao!n/lmao-entry-span-lifecycle-entry-types.start
|
|
115
|
-
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
* Per specs/lmao/01i_span_scope_attributes.md: Scope values are stored directly on buffer._scopeValues.
|
|
119
|
-
* The SpanLogger reads/writes scope via buffer._scopeValues - no separate Scope class needed.
|
|
120
|
-
*
|
|
121
|
-
* @param schema - Tag attribute schema with field definitions
|
|
122
|
-
* @param buffer - SpanBuffer to write entries to (per-span instance)
|
|
123
|
-
* @returns SpanLogger with typed methods matching schema
|
|
124
|
-
*/
|
|
125
|
-
export function createSpanLogger(schema, buffer) {
|
|
126
|
-
return createSpanLoggerFromGenerator(schema, buffer);
|
|
102
|
+
/** Create a SpanLogger bound to an existing SpanContext writer state. */
|
|
103
|
+
export function createSpanLogger(schema, state) {
|
|
104
|
+
return createSpanLoggerFromGenerator(schema, state);
|
|
127
105
|
}
|
|
128
106
|
//#region smoo/lmao!n/op-retry.delay
|
|
129
107
|
/**
|
|
@@ -175,9 +153,9 @@ function calculateDelay(policy, attempt) {
|
|
|
175
153
|
function writeRetryEntry(buffer, attempt, error, delayMs) {
|
|
176
154
|
// Get current write index and advance for next write
|
|
177
155
|
const index = buffer._writeIndex;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
156
|
+
const traceRoot = buffer._traceRoot;
|
|
157
|
+
const appendLogEntry = buffer._opMetadata._physicalLayoutPlan?.appendLogEntry ?? traceRoot._appendLogEntry;
|
|
158
|
+
appendLogEntry(traceRoot, buffer, ENTRY_TYPE_SPAN_RETRY);
|
|
181
159
|
// Write retry-specific message: retry:op:{opName} for prefix-based querying
|
|
182
160
|
const opName = buffer._opMetadata?.name ?? 'unknown';
|
|
183
161
|
buffer.message(index, `retry:op:${opName}`);
|
|
@@ -200,54 +178,130 @@ function writeRetryEntry(buffer, attempt, error, delayMs) {
|
|
|
200
178
|
function sleep(ms) {
|
|
201
179
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
202
180
|
}
|
|
203
|
-
|
|
204
|
-
* Execute function with retry loop for TransientError handling.
|
|
205
|
-
*
|
|
206
|
-
* Per plan 19-03: Op class handles retry loop internally.
|
|
207
|
-
* - TransientError from op body triggers retry based on error.policy
|
|
208
|
-
* - Retry respects maxAttempts from TransientError.policy
|
|
209
|
-
* - span-retry entry written for each transient failure
|
|
210
|
-
* - Only final result written as span-ok or span-err
|
|
211
|
-
* - BlockedError returns immediately without retry
|
|
212
|
-
*
|
|
213
|
-
* @param buffer - SpanBuffer to write retry entries to
|
|
214
|
-
* @param fn - Function to execute (may be retried)
|
|
215
|
-
* @returns Final result (success, non-transient error, or exhausted transient error)
|
|
216
|
-
*/
|
|
217
|
-
async function executeWithRetry(buffer, fn) {
|
|
181
|
+
async function executeWithRetry0(buffer, fn, ctx) {
|
|
218
182
|
let attempt = 0;
|
|
219
183
|
while (true) {
|
|
220
184
|
attempt++;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// Success - return immediately
|
|
224
|
-
if (result instanceof Ok) {
|
|
185
|
+
const result = await fn(ctx);
|
|
186
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
225
187
|
return result;
|
|
226
|
-
|
|
227
|
-
// Error result - check error type for retry behavior
|
|
228
|
-
const error = result.error;
|
|
229
|
-
// BlockedError - return immediately, no retry
|
|
230
|
-
if (error instanceof Blocked) {
|
|
188
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
231
189
|
return result;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
190
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
191
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
192
|
+
await sleep(delay);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function executeWithRetry1(buffer, fn, ctx, a1) {
|
|
196
|
+
let attempt = 0;
|
|
197
|
+
while (true) {
|
|
198
|
+
attempt++;
|
|
199
|
+
const result = await fn(ctx, a1);
|
|
200
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
201
|
+
return result;
|
|
202
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
203
|
+
return result;
|
|
204
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
205
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
206
|
+
await sleep(delay);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function executeWithRetry2(buffer, fn, ctx, a1, a2) {
|
|
210
|
+
let attempt = 0;
|
|
211
|
+
while (true) {
|
|
212
|
+
attempt++;
|
|
213
|
+
const result = await fn(ctx, a1, a2);
|
|
214
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
215
|
+
return result;
|
|
216
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
217
|
+
return result;
|
|
218
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
219
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
220
|
+
await sleep(delay);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async function executeWithRetry3(buffer, fn, ctx, a1, a2, a3) {
|
|
224
|
+
let attempt = 0;
|
|
225
|
+
while (true) {
|
|
226
|
+
attempt++;
|
|
227
|
+
const result = await fn(ctx, a1, a2, a3);
|
|
228
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
229
|
+
return result;
|
|
230
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
231
|
+
return result;
|
|
232
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
233
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
234
|
+
await sleep(delay);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async function executeWithRetry4(buffer, fn, ctx, a1, a2, a3, a4) {
|
|
238
|
+
let attempt = 0;
|
|
239
|
+
while (true) {
|
|
240
|
+
attempt++;
|
|
241
|
+
const result = await fn(ctx, a1, a2, a3, a4);
|
|
242
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
243
|
+
return result;
|
|
244
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
245
|
+
return result;
|
|
246
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
247
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
248
|
+
await sleep(delay);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async function executeWithRetry5(buffer, fn, ctx, a1, a2, a3, a4, a5) {
|
|
252
|
+
let attempt = 0;
|
|
253
|
+
while (true) {
|
|
254
|
+
attempt++;
|
|
255
|
+
const result = await fn(ctx, a1, a2, a3, a4, a5);
|
|
256
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
257
|
+
return result;
|
|
258
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
259
|
+
return result;
|
|
260
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
261
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
262
|
+
await sleep(delay);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
async function executeWithRetry6(buffer, fn, ctx, a1, a2, a3, a4, a5, a6) {
|
|
266
|
+
let attempt = 0;
|
|
267
|
+
while (true) {
|
|
268
|
+
attempt++;
|
|
269
|
+
const result = await fn(ctx, a1, a2, a3, a4, a5, a6);
|
|
270
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
271
|
+
return result;
|
|
272
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
273
|
+
return result;
|
|
274
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
275
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
276
|
+
await sleep(delay);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async function executeWithRetry7(buffer, fn, ctx, a1, a2, a3, a4, a5, a6, a7) {
|
|
280
|
+
let attempt = 0;
|
|
281
|
+
while (true) {
|
|
282
|
+
attempt++;
|
|
283
|
+
const result = await fn(ctx, a1, a2, a3, a4, a5, a6, a7);
|
|
284
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
285
|
+
return result;
|
|
286
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
287
|
+
return result;
|
|
288
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
289
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
290
|
+
await sleep(delay);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
async function executeWithRetry8(buffer, fn, ctx, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
294
|
+
let attempt = 0;
|
|
295
|
+
while (true) {
|
|
296
|
+
attempt++;
|
|
297
|
+
const result = await fn(ctx, a1, a2, a3, a4, a5, a6, a7, a8);
|
|
298
|
+
if (!(result instanceof Err) || !(result.error instanceof TransientError))
|
|
299
|
+
return result;
|
|
300
|
+
if (attempt >= result.error.policy.maxAttempts)
|
|
301
|
+
return result;
|
|
302
|
+
const delay = calculateDelay(result.error.policy, attempt);
|
|
303
|
+
writeRetryEntry(buffer, attempt, result.error, delay);
|
|
304
|
+
await sleep(delay);
|
|
251
305
|
}
|
|
252
306
|
}
|
|
253
307
|
//#endregion smoo/lmao!n/op-retry.loop
|
|
@@ -264,13 +318,18 @@ async function executeWithRetry(buffer, fn) {
|
|
|
264
318
|
* @param buffer - SpanBuffer to write to
|
|
265
319
|
* @param result - The result returned by the span function
|
|
266
320
|
*/
|
|
321
|
+
function writeSpanEndEntry(buffer, entryType) {
|
|
322
|
+
const appenders = buffer._opMetadata._physicalLayoutPlan?.appenders;
|
|
323
|
+
if (appenders === undefined)
|
|
324
|
+
throw new TypeError('SpanBuffer metadata is missing physical lifecycle appenders');
|
|
325
|
+
appenders.writeSpanEnd(buffer, entryType);
|
|
326
|
+
}
|
|
267
327
|
export function writeSpanEnd(buffer, result) {
|
|
268
|
-
// Write entry_type and timestamp via TraceRoot (platform-specific)
|
|
269
328
|
if (result instanceof Ok) {
|
|
270
|
-
|
|
329
|
+
writeSpanEndEntry(buffer, ENTRY_TYPE_SPAN_OK);
|
|
271
330
|
}
|
|
272
331
|
else if (result instanceof Err) {
|
|
273
|
-
|
|
332
|
+
writeSpanEndEntry(buffer, ENTRY_TYPE_SPAN_ERR);
|
|
274
333
|
// Write error_code if the error has a code property
|
|
275
334
|
if (hasErrorCode(result.error)) {
|
|
276
335
|
buffer.error_code(1, result.error.code);
|
|
@@ -281,6 +340,19 @@ export function writeSpanEnd(buffer, result) {
|
|
|
281
340
|
// =============================================================================
|
|
282
341
|
// SpanContext Class Factory
|
|
283
342
|
// =============================================================================
|
|
343
|
+
const spanContextClassCaches = new WeakMap();
|
|
344
|
+
function isSpanContextClass(value) {
|
|
345
|
+
return typeof value === 'function';
|
|
346
|
+
}
|
|
347
|
+
export function isPhysicalLayoutPlanForContext(value, schema) {
|
|
348
|
+
return (typeof value === 'object' &&
|
|
349
|
+
value !== null &&
|
|
350
|
+
Reflect.get(value, 'schema') === schema &&
|
|
351
|
+
isSpanContextClass(Reflect.get(value, 'SpanContextClass')));
|
|
352
|
+
}
|
|
353
|
+
function isFlagEvaluatorForContext(value) {
|
|
354
|
+
return typeof value === 'object' && value !== null && typeof Reflect.get(value, 'forContext') === 'function';
|
|
355
|
+
}
|
|
284
356
|
/**
|
|
285
357
|
* Create a SpanContext class for the given schema and logBinding.
|
|
286
358
|
*
|
|
@@ -288,14 +360,33 @@ export function writeSpanEnd(buffer, result) {
|
|
|
288
360
|
* - Closes over schema/logBinding (available to all methods)
|
|
289
361
|
* - Constructor takes buffer, spanLogger, tag directly (no temp object allocation)
|
|
290
362
|
* - Uses prototype methods for internal methods (_spanPre, _spanException, span0-span8)
|
|
291
|
-
* -
|
|
292
|
-
* -
|
|
363
|
+
* - Reuses the parent context as the zero-override source without allocating a carrier object
|
|
364
|
+
* - Context overrides use the plan's schema-specific context factory
|
|
293
365
|
*
|
|
294
366
|
* @param schemaOnly - Tag attribute schema
|
|
295
367
|
* @param logBinding - LogBinding with schema and stats
|
|
296
368
|
* @returns Class constructor for SpanContext instances
|
|
297
369
|
*/
|
|
298
|
-
export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
370
|
+
export function createSpanContextClass(_schemaOnly, logBinding, capabilities = RUNTIME_HINT_FULL_CAPABILITIES, userContextKeys = []) {
|
|
371
|
+
const canonicalUserContextKeys = [...userContextKeys].sort();
|
|
372
|
+
const layoutKey = canonicalUserContextKeys.join('\u0000');
|
|
373
|
+
const cacheKey = `${capabilities}:${layoutKey}`;
|
|
374
|
+
let cache = spanContextClassCaches.get(logBinding);
|
|
375
|
+
if (!cache) {
|
|
376
|
+
cache = new Map();
|
|
377
|
+
spanContextClassCaches.set(logBinding, cache);
|
|
378
|
+
}
|
|
379
|
+
const cached = cache.get(cacheKey);
|
|
380
|
+
if (isSpanContextClass(cached))
|
|
381
|
+
return cached;
|
|
382
|
+
const hasTag = (capabilities & RUNTIME_HINT_TAG) !== 0;
|
|
383
|
+
const hasLog = (capabilities & RUNTIME_HINT_LOG) !== 0;
|
|
384
|
+
const hasFf = (capabilities & RUNTIME_HINT_FF) !== 0;
|
|
385
|
+
const hasSpan = (capabilities & RUNTIME_HINT_SPAN) !== 0;
|
|
386
|
+
const hasResult = (capabilities & RUNTIME_HINT_RESULT) !== 0;
|
|
387
|
+
const hasScope = (capabilities & RUNTIME_HINT_SCOPE) !== 0;
|
|
388
|
+
const hasDeps = (capabilities & RUNTIME_HINT_DEPS) !== 0;
|
|
389
|
+
const needsLogger = hasLog || hasFf || hasScope;
|
|
299
390
|
/**
|
|
300
391
|
* SpanContext implementation class.
|
|
301
392
|
*
|
|
@@ -303,39 +394,57 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
303
394
|
* avoiding both temp object allocation and property lookups in hot paths.
|
|
304
395
|
*/
|
|
305
396
|
class SpanContextImpl {
|
|
306
|
-
|
|
307
|
-
_buffer;
|
|
308
|
-
_schema;
|
|
309
|
-
_spanLogger;
|
|
310
|
-
_logBinding = logBinding;
|
|
311
|
-
// User-facing properties
|
|
312
|
-
tag;
|
|
313
|
-
log;
|
|
314
|
-
ff;
|
|
315
|
-
deps;
|
|
316
|
-
// Arrow functions that close over constructor args directly
|
|
317
|
-
setScope;
|
|
318
|
-
ok;
|
|
319
|
-
err;
|
|
320
|
-
span;
|
|
321
|
-
spanSync;
|
|
322
|
-
constructor(buffer, schema, spanLogger, tag) {
|
|
397
|
+
constructor(buffer, schema, callsitePlan, contextSource, contextOverrides, deps, ffSource) {
|
|
323
398
|
//#region smoo/lmao!n/codegen-destructured-context
|
|
324
399
|
// Destructured-context assembly (01g): every property an op destructures —
|
|
325
400
|
// tag, log, scope (setScope), ok, err, span — is wired here as a closed-over
|
|
326
401
|
// field/closure so `op(({ tag, log, span, ok, err }) => ...)` needs no ctx drilling.
|
|
402
|
+
this._spanBuffer = buffer;
|
|
327
403
|
this._buffer = buffer;
|
|
404
|
+
this._appendLogEntry = callsitePlan.appendLogEntry;
|
|
328
405
|
this._schema = schema;
|
|
329
|
-
this.
|
|
330
|
-
this.
|
|
331
|
-
|
|
406
|
+
this._logBinding = logBinding;
|
|
407
|
+
this._physicalLayoutPlan = callsitePlan;
|
|
408
|
+
const spanLogger = callsitePlan.newSpanLogger?.(this);
|
|
409
|
+
const tag = callsitePlan.newTagWriter?.(this);
|
|
410
|
+
if (needsLogger) {
|
|
411
|
+
if (!spanLogger)
|
|
412
|
+
throw new TypeError('SpanContext capability requires a logger');
|
|
413
|
+
this._spanLogger = spanLogger;
|
|
414
|
+
}
|
|
415
|
+
if (hasTag) {
|
|
416
|
+
if (!tag)
|
|
417
|
+
throw new TypeError('SpanContext tag capability requires a tag writer');
|
|
418
|
+
this.tag = tag;
|
|
419
|
+
}
|
|
420
|
+
if (hasLog && spanLogger)
|
|
421
|
+
this.log = spanLogger;
|
|
422
|
+
if (hasDeps)
|
|
423
|
+
this.deps = deps ?? {};
|
|
424
|
+
if (hasFf && ffSource)
|
|
425
|
+
this.ff = ffSource.forContext(this);
|
|
426
|
+
for (const key of canonicalUserContextKeys) {
|
|
427
|
+
let value = contextSource?.[key];
|
|
428
|
+
if (contextOverrides && Object.prototype.propertyIsEnumerable.call(contextOverrides, key)) {
|
|
429
|
+
const overrideValue = contextOverrides[key];
|
|
430
|
+
if (overrideValue !== undefined)
|
|
431
|
+
value = overrideValue;
|
|
432
|
+
}
|
|
433
|
+
this[key] = value;
|
|
434
|
+
}
|
|
332
435
|
// Regular functions close over constructor args directly - no property lookups
|
|
333
436
|
// Using regular function (not arrow) allows destructuring while closing over args
|
|
334
|
-
|
|
335
|
-
spanLogger
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
437
|
+
if (hasScope) {
|
|
438
|
+
if (!spanLogger)
|
|
439
|
+
throw new TypeError('SpanContext scope capability requires a logger');
|
|
440
|
+
this.setScope = (attributes) => {
|
|
441
|
+
spanLogger._setScope(attributes ?? {});
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
if (hasResult) {
|
|
445
|
+
this.ok = (value) => new Ok(value, this);
|
|
446
|
+
this.err = (error) => new Err(error, this);
|
|
447
|
+
}
|
|
339
448
|
//#endregion smoo/lmao!n/codegen-destructured-context
|
|
340
449
|
//#region smoo/lmao!n/context-flow-span-promise
|
|
341
450
|
// 01c "Why span() Is Promise-Based" + "Child Span Creation via span()" + "spanSync()".
|
|
@@ -346,61 +455,63 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
346
455
|
// span uses regular function to access `arguments` (no ...rest spread allocation)
|
|
347
456
|
// Closes over `self` for calling prototype methods
|
|
348
457
|
// Named function for better stack traces
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
458
|
+
if (hasSpan) {
|
|
459
|
+
const self = this;
|
|
460
|
+
const span = function span(nameOrLine, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11) {
|
|
461
|
+
// Use arguments.length instead of ...rest to avoid array allocation
|
|
462
|
+
const len = arguments.length;
|
|
463
|
+
// Detect call pattern:
|
|
464
|
+
// - span(name, fn) - len=2, typeof arg0 === 'string'
|
|
465
|
+
// - span(line, name, fn) - len=3, typeof arg0 === 'number'
|
|
466
|
+
// - span(name, overrides, fn) - len=3, typeof arg0 === 'string', typeof arg1 === 'object'
|
|
467
|
+
// - span(line, name, overrides, fn) - len=4, typeof arg0 === 'number', typeof arg2 === 'object'
|
|
468
|
+
// Plus additional args for span arguments
|
|
469
|
+
const hasLine = typeof nameOrLine === 'number';
|
|
470
|
+
const spanLine = hasLine ? nameOrLine : 0;
|
|
471
|
+
const spanName = hasLine ? readStringArgument(arguments, 1, 'span name') : nameOrLine;
|
|
472
|
+
// Index where fn/op or overrides starts
|
|
473
|
+
const checkIdx = hasLine ? 2 : 1;
|
|
474
|
+
const maybeOverrides = arguments[checkIdx];
|
|
475
|
+
// Check if it's an overrides object (not Op, not function)
|
|
476
|
+
const hasOverrides = maybeOverrides !== null &&
|
|
477
|
+
typeof maybeOverrides === 'object' &&
|
|
478
|
+
!isOpLike(maybeOverrides) &&
|
|
479
|
+
typeof maybeOverrides !== 'function';
|
|
480
|
+
const fnIdx = checkIdx + (hasOverrides ? 1 : 0);
|
|
481
|
+
const target = resolveSpanTarget(arguments[fnIdx], self._physicalLayoutPlan, self._spanBuffer._opMetadata);
|
|
482
|
+
const childCtx = asSpanContextInstance(hasOverrides ? target.callsitePlan.newCtx1(self, maybeOverrides) : target.callsitePlan.newCtx0(self));
|
|
483
|
+
// Dispatch to monomorphic methods with all Op properties extracted
|
|
484
|
+
const argCount = len - fnIdx - 1;
|
|
485
|
+
switch (argCount) {
|
|
486
|
+
case 0:
|
|
487
|
+
return self.span0(spanLine, spanName, childCtx, target.callsitePlan, target.fn);
|
|
488
|
+
case 1:
|
|
489
|
+
return self.span1(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1]);
|
|
490
|
+
case 2:
|
|
491
|
+
return self.span2(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2]);
|
|
492
|
+
case 3:
|
|
493
|
+
return self.span3(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3]);
|
|
494
|
+
case 4:
|
|
495
|
+
return self.span4(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4]);
|
|
496
|
+
case 5:
|
|
497
|
+
return self.span5(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5]);
|
|
498
|
+
case 6:
|
|
499
|
+
return self.span6(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5], arguments[fnIdx + 6]);
|
|
500
|
+
case 7:
|
|
501
|
+
return self.span7(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5], arguments[fnIdx + 6], arguments[fnIdx + 7]);
|
|
502
|
+
case 8:
|
|
503
|
+
return self.span8(spanLine, spanName, childCtx, target.callsitePlan, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5], arguments[fnIdx + 6], arguments[fnIdx + 7], arguments[fnIdx + 8]);
|
|
504
|
+
default:
|
|
505
|
+
throw new Error(`span() supports up to 8 arguments, got ${argCount}`);
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
this.span = span;
|
|
509
|
+
this.spanSync = function spanSync(name, op) {
|
|
510
|
+
const callsitePlan = op.callsitePlan;
|
|
511
|
+
const childCtx = asSpanContextInstance(callsitePlan.newCtx0(self));
|
|
512
|
+
return self.spanSync0(0, name, childCtx, callsitePlan, op.fn);
|
|
513
|
+
};
|
|
514
|
+
}
|
|
404
515
|
//#endregion smoo/lmao!n/context-flow-span-promise
|
|
405
516
|
}
|
|
406
517
|
// =========================================================================
|
|
@@ -410,35 +521,43 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
410
521
|
return true;
|
|
411
522
|
}
|
|
412
523
|
get module() {
|
|
413
|
-
return this.
|
|
524
|
+
return this._spanBuffer._opMetadata;
|
|
414
525
|
}
|
|
415
526
|
get callee_package() {
|
|
416
|
-
return this.
|
|
527
|
+
return this._spanBuffer._opMetadata.package_name;
|
|
417
528
|
}
|
|
418
529
|
get callee_file() {
|
|
419
|
-
return this.
|
|
530
|
+
return this._spanBuffer._opMetadata.package_file;
|
|
420
531
|
}
|
|
421
532
|
get callee_line() {
|
|
422
533
|
// Access the line_values array directly to read line number at row 0
|
|
423
534
|
// line_values is a Float64Array per the system schema (LazyNumberSchema)
|
|
424
|
-
return this.
|
|
535
|
+
return this._spanBuffer.line_values[0];
|
|
425
536
|
}
|
|
426
537
|
get callee_git_sha() {
|
|
427
|
-
return this.
|
|
538
|
+
return this._spanBuffer._opMetadata.git_sha;
|
|
428
539
|
}
|
|
429
540
|
get buffer() {
|
|
430
|
-
return this.
|
|
541
|
+
return this._spanBuffer;
|
|
431
542
|
}
|
|
432
543
|
//#region smoo/lmao!n/scope-attributes.read
|
|
433
544
|
// 01i read-only scope view: the immutable _scopeValues snapshot (setScope is wired in the
|
|
434
545
|
// destructured-context region; the immutable merge is _setScope in spanLoggerGenerator).
|
|
435
546
|
get scope() {
|
|
436
|
-
return this.
|
|
547
|
+
return this._spanBuffer._scopeValues;
|
|
437
548
|
}
|
|
438
549
|
//#endregion smoo/lmao!n/scope-attributes.read
|
|
439
550
|
// =========================================================================
|
|
440
551
|
// Internal methods (on prototype)
|
|
441
552
|
// =========================================================================
|
|
553
|
+
_appendWriterEntry(entryType) {
|
|
554
|
+
if (this._buffer._writeIndex >= this._buffer._capacity) {
|
|
555
|
+
this._buffer = this._buffer.getOrCreateOverflow();
|
|
556
|
+
this._spanLogger._prefillScopedAttributesOn(this._buffer);
|
|
557
|
+
}
|
|
558
|
+
const traceRoot = this._buffer._traceRoot;
|
|
559
|
+
return this._appendLogEntry(traceRoot, this._buffer, entryType);
|
|
560
|
+
}
|
|
442
561
|
/**
|
|
443
562
|
* Create a new child context with prototype chain inheritance.
|
|
444
563
|
* Called by transformer for spans without overrides.
|
|
@@ -446,7 +565,7 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
446
565
|
* Transformer emits: ctx.span0(line, name, ctx._newCtx0(), fn)
|
|
447
566
|
*/
|
|
448
567
|
_newCtx0() {
|
|
449
|
-
return
|
|
568
|
+
return asSpanContextInstance(this._physicalLayoutPlan.newCtx0(this));
|
|
450
569
|
}
|
|
451
570
|
/**
|
|
452
571
|
* Create a new child context with prototype chain inheritance + user overrides.
|
|
@@ -455,7 +574,7 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
455
574
|
* Transformer emits: ctx.span0(line, name, ctx._newCtx1({ requestId }), fn)
|
|
456
575
|
*/
|
|
457
576
|
_newCtx1(overrides) {
|
|
458
|
-
return
|
|
577
|
+
return asSpanContextInstance(this._physicalLayoutPlan.newCtx1(this, overrides));
|
|
459
578
|
}
|
|
460
579
|
/**
|
|
461
580
|
* Complete child span context setup - creates buffer, registers with parent.
|
|
@@ -468,116 +587,27 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
468
587
|
* @param line - Source line number (0 if not provided by transformer)
|
|
469
588
|
* @param name - Child span name
|
|
470
589
|
* @param SpanBufferClass - Buffer class to use (Op's class or parent's class for plain functions)
|
|
471
|
-
* @param
|
|
590
|
+
* @param remapDescriptor - Optional immutable cold-path output mapping
|
|
472
591
|
* @param opMetadata - Metadata for the executing op (Op's metadata or parent's for plain functions)
|
|
473
592
|
*/
|
|
474
593
|
//#region smoo/lmao!n/context-flow-child-span
|
|
475
594
|
// 01c "Child Span Creation via span()" / "How span() Works" and 01e "Op's Responsibility:
|
|
476
|
-
//
|
|
477
|
-
//
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
// Get Op's schema for cross-library calls (child may have different schema than parent)
|
|
482
|
-
const childSchema = SpanBufferClass.schema;
|
|
483
|
-
// Use buffer strategy for child span creation (supports both JS and WASM buffers)
|
|
484
|
-
// Pass schema for cross-library calls where child has different schema than parent
|
|
485
|
-
const createdBuffer = this._buffer._traceRoot.tracer.bufferStrategy.createChildSpanBuffer(this._buffer, // parentBuffer
|
|
486
|
-
this._buffer._opMetadata, // callsiteMetadata - WHO called span() (for row 0)
|
|
487
|
-
opMetadata, // opMetadata - WHICH op is executing (for rows 1+)
|
|
488
|
-
undefined, // capacity - use default
|
|
489
|
-
childSchema);
|
|
490
|
-
if (!isSpanBufferForSchema(createdBuffer, childSchema)) {
|
|
491
|
-
throw new TypeError('Child span buffer does not match the requested schema');
|
|
492
|
-
}
|
|
595
|
+
// _spanPre creates the child through the planned schema/capacity, attaches the immutable
|
|
596
|
+
// cold-path remap descriptor to the raw buffer, registers it, and writes row 0.
|
|
597
|
+
_spanPre(childCtx, line, name, callsitePlan, opMetadata) {
|
|
598
|
+
const childSchema = callsitePlan.schema;
|
|
599
|
+
const createdBuffer = this._spanBuffer._traceRoot.tracer.bufferStrategy.createChildSpanBuffer(this._spanBuffer, this._spanBuffer._opMetadata, opMetadata, callsitePlan.capacityTier, childSchema, callsitePlan.SpanBufferClass);
|
|
493
600
|
const childBuffer = createdBuffer;
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
const bufferOrView = remappedViewClass ? new remappedViewClass(childBuffer) : childBuffer;
|
|
497
|
-
// Why push wrapped buffer: Parent's _children see remapped names for Arrow conversion
|
|
498
|
-
this._buffer._children.push(bufferOrView);
|
|
499
|
-
// Write span-start for child span (row 0) and pre-initialize span-end (row 1)
|
|
500
|
-
writeSpanStart(childBuffer, name);
|
|
501
|
-
// Write line number to row 0 (line() takes pos and value)
|
|
601
|
+
childBuffer._remapDescriptor = callsitePlan.remapDescriptor ?? undefined;
|
|
602
|
+
callsitePlan.appenders.writeSpanStart(childBuffer, name);
|
|
502
603
|
childBuffer.line(0, line);
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
511
|
-
// SLOT 1-4: HOTTEST - accessed on every span operation
|
|
512
|
-
ctx._buffer = childBuffer;
|
|
513
|
-
ctx._spanLogger = childLogger;
|
|
514
|
-
ctx.tag = childTagAPI;
|
|
515
|
-
ctx.log = childLogger;
|
|
516
|
-
// SLOT 5-7: HOT - reserved keys copied from parent for O(1) access
|
|
517
|
-
ctx.deps = this.deps;
|
|
518
|
-
// Create child-bound FF evaluator so flag access logs to child buffer
|
|
519
|
-
// If no evaluator (ff is EMPTY_SCOPE), just copy the reference
|
|
520
|
-
ctx.ff = this.ff.forContext ? this.ff.forContext(ctx) : this.ff;
|
|
521
|
-
// Note: user-defined extras (env, requestId, etc.) inherited via prototype chain
|
|
522
|
-
// SLOT 8-11: WARM - function properties (created per-context for destructuring)
|
|
523
|
-
// Regular functions close over local variables directly - no property lookups
|
|
524
|
-
const childSpan = function span(nameOrLine, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10, _arg11) {
|
|
525
|
-
const len = arguments.length;
|
|
526
|
-
const hasLine = typeof nameOrLine === 'number';
|
|
527
|
-
const spanLine = hasLine ? nameOrLine : 0;
|
|
528
|
-
const spanName = hasLine ? readStringArgument(arguments, 1, 'span name') : nameOrLine;
|
|
529
|
-
const checkIdx = hasLine ? 2 : 1;
|
|
530
|
-
const maybeOverrides = arguments[checkIdx];
|
|
531
|
-
const hasOverrides = maybeOverrides !== null &&
|
|
532
|
-
typeof maybeOverrides === 'object' &&
|
|
533
|
-
!(maybeOverrides instanceof Op) &&
|
|
534
|
-
typeof maybeOverrides !== 'function';
|
|
535
|
-
const fnIdx = checkIdx + (hasOverrides ? 1 : 0);
|
|
536
|
-
const target = resolveSpanTarget(arguments[fnIdx], childBuffer);
|
|
537
|
-
// Create child context - use _newCtx0 or _newCtx1 based on overrides
|
|
538
|
-
const newChildCtx = hasOverrides ? ctx._newCtx1(maybeOverrides) : ctx._newCtx0();
|
|
539
|
-
const argCount = len - fnIdx - 1;
|
|
540
|
-
switch (argCount) {
|
|
541
|
-
case 0:
|
|
542
|
-
return ctx.span0(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn);
|
|
543
|
-
case 1:
|
|
544
|
-
return ctx.span1(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1]);
|
|
545
|
-
case 2:
|
|
546
|
-
return ctx.span2(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2]);
|
|
547
|
-
case 3:
|
|
548
|
-
return ctx.span3(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3]);
|
|
549
|
-
case 4:
|
|
550
|
-
return ctx.span4(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4]);
|
|
551
|
-
case 5:
|
|
552
|
-
return ctx.span5(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5]);
|
|
553
|
-
case 6:
|
|
554
|
-
return ctx.span6(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5], arguments[fnIdx + 6]);
|
|
555
|
-
case 7:
|
|
556
|
-
return ctx.span7(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5], arguments[fnIdx + 6], arguments[fnIdx + 7]);
|
|
557
|
-
case 8:
|
|
558
|
-
return ctx.span8(spanLine, spanName, newChildCtx, target.SpanBufferClass, target.remappedViewClass, target.opMetadata, target.fn, arguments[fnIdx + 1], arguments[fnIdx + 2], arguments[fnIdx + 3], arguments[fnIdx + 4], arguments[fnIdx + 5], arguments[fnIdx + 6], arguments[fnIdx + 7], arguments[fnIdx + 8]);
|
|
559
|
-
default:
|
|
560
|
-
throw new Error(`span() supports up to 8 arguments, got ${argCount}`);
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
ctx.span = childSpan;
|
|
564
|
-
ctx.spanSync = function spanSync(name, fn) {
|
|
565
|
-
const newChildCtx = ctx._newCtx0();
|
|
566
|
-
return ctx.spanSync0(0, name, newChildCtx, getBufferConstructor(childBuffer), undefined, childBuffer._opMetadata, fn);
|
|
567
|
-
};
|
|
568
|
-
ctx.ok = function ok(value) {
|
|
569
|
-
return new Ok(value, childSchema, childBuffer);
|
|
570
|
-
};
|
|
571
|
-
ctx.err = function err(error) {
|
|
572
|
-
return new Err(error, childSchema, childBuffer);
|
|
573
|
-
};
|
|
574
|
-
ctx.setScope = function setScope(attributes) {
|
|
575
|
-
childLogger._setScope(attributes ?? {});
|
|
576
|
-
};
|
|
577
|
-
// SLOT 12+: COLD - internal/rarely accessed
|
|
578
|
-
ctx._schema = childSchema;
|
|
579
|
-
ctx._logBinding = logBinding;
|
|
580
|
-
return ctx;
|
|
604
|
+
const childFfSource = Object.hasOwn(this, 'ff')
|
|
605
|
+
? this.ff
|
|
606
|
+
: this._spanBuffer._traceRoot.tracer.getFlagEvaluatorForContext();
|
|
607
|
+
if (!isFlagEvaluatorForContext(childFfSource)) {
|
|
608
|
+
throw new TypeError('Span context requires a context evaluator');
|
|
609
|
+
}
|
|
610
|
+
return new callsitePlan.SpanContextClass(childBuffer, childSchema, callsitePlan, childCtx, undefined, this.deps, childFfSource);
|
|
581
611
|
}
|
|
582
612
|
//#endregion smoo/lmao!n/context-flow-child-span
|
|
583
613
|
//#region smoo/lmao!n/lmao-entry-span-lifecycle-entry-types.exception
|
|
@@ -586,8 +616,7 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
586
616
|
* Called in catch blocks of span methods.
|
|
587
617
|
*/
|
|
588
618
|
_spanException(childBuffer, error) {
|
|
589
|
-
|
|
590
|
-
childBuffer._traceRoot.writeSpanEnd(childBuffer, ENTRY_TYPE_SPAN_EXCEPTION);
|
|
619
|
+
writeSpanEndEntry(childBuffer, ENTRY_TYPE_SPAN_EXCEPTION);
|
|
591
620
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
592
621
|
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
593
622
|
childBuffer.message(1, errorMessage);
|
|
@@ -596,18 +625,466 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
596
625
|
}
|
|
597
626
|
}
|
|
598
627
|
//#endregion smoo/lmao!n/lmao-entry-span-lifecycle-entry-types.exception
|
|
628
|
+
_spanAutoPre(line, name, op) {
|
|
629
|
+
const child = asSpanContextInstance(op.callsitePlan.newCtx0(this));
|
|
630
|
+
return this._spanPre(child, line, name, op.callsitePlan, op.metadata);
|
|
631
|
+
}
|
|
632
|
+
spanAuto0(line, name, op) {
|
|
633
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
634
|
+
const buffer = ctx._spanBuffer;
|
|
635
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
636
|
+
let isAsync = false;
|
|
637
|
+
try {
|
|
638
|
+
const result = op.fn(ctx);
|
|
639
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
640
|
+
isAsync = true;
|
|
641
|
+
return this._spanAutoAsync0(ctx, buffer, op, result);
|
|
642
|
+
}
|
|
643
|
+
writeSpanEnd(buffer, result);
|
|
644
|
+
return result;
|
|
645
|
+
}
|
|
646
|
+
catch (error) {
|
|
647
|
+
this._spanException(buffer, error);
|
|
648
|
+
throw error;
|
|
649
|
+
}
|
|
650
|
+
finally {
|
|
651
|
+
if (!isAsync) {
|
|
652
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
async _spanAutoAsync0(ctx, buffer, op, first) {
|
|
657
|
+
try {
|
|
658
|
+
let attempt = 1;
|
|
659
|
+
let result = await first;
|
|
660
|
+
while (true) {
|
|
661
|
+
const retryError = getRetryableError(result, attempt);
|
|
662
|
+
if (!retryError)
|
|
663
|
+
break;
|
|
664
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
665
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
666
|
+
await sleep(delay);
|
|
667
|
+
attempt++;
|
|
668
|
+
result = await op.fn(ctx);
|
|
669
|
+
}
|
|
670
|
+
writeSpanEnd(buffer, result);
|
|
671
|
+
return result;
|
|
672
|
+
}
|
|
673
|
+
catch (error) {
|
|
674
|
+
this._spanException(buffer, error);
|
|
675
|
+
throw error;
|
|
676
|
+
}
|
|
677
|
+
finally {
|
|
678
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
spanAuto1(line, name, op, a1) {
|
|
682
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
683
|
+
const buffer = ctx._spanBuffer;
|
|
684
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
685
|
+
let isAsync = false;
|
|
686
|
+
try {
|
|
687
|
+
const result = op.fn(ctx, a1);
|
|
688
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
689
|
+
isAsync = true;
|
|
690
|
+
return this._spanAutoAsync1(ctx, buffer, op, result, a1);
|
|
691
|
+
}
|
|
692
|
+
writeSpanEnd(buffer, result);
|
|
693
|
+
return result;
|
|
694
|
+
}
|
|
695
|
+
catch (error) {
|
|
696
|
+
this._spanException(buffer, error);
|
|
697
|
+
throw error;
|
|
698
|
+
}
|
|
699
|
+
finally {
|
|
700
|
+
if (!isAsync) {
|
|
701
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
async _spanAutoAsync1(ctx, buffer, op, first, a1) {
|
|
706
|
+
try {
|
|
707
|
+
let attempt = 1;
|
|
708
|
+
let result = await first;
|
|
709
|
+
while (true) {
|
|
710
|
+
const retryError = getRetryableError(result, attempt);
|
|
711
|
+
if (!retryError)
|
|
712
|
+
break;
|
|
713
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
714
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
715
|
+
await sleep(delay);
|
|
716
|
+
attempt++;
|
|
717
|
+
result = await op.fn(ctx, a1);
|
|
718
|
+
}
|
|
719
|
+
writeSpanEnd(buffer, result);
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
catch (error) {
|
|
723
|
+
this._spanException(buffer, error);
|
|
724
|
+
throw error;
|
|
725
|
+
}
|
|
726
|
+
finally {
|
|
727
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
spanAuto2(line, name, op, a1, a2) {
|
|
731
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
732
|
+
const buffer = ctx._spanBuffer;
|
|
733
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
734
|
+
let isAsync = false;
|
|
735
|
+
try {
|
|
736
|
+
const result = op.fn(ctx, a1, a2);
|
|
737
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
738
|
+
isAsync = true;
|
|
739
|
+
return this._spanAutoAsync2(ctx, buffer, op, result, a1, a2);
|
|
740
|
+
}
|
|
741
|
+
writeSpanEnd(buffer, result);
|
|
742
|
+
return result;
|
|
743
|
+
}
|
|
744
|
+
catch (error) {
|
|
745
|
+
this._spanException(buffer, error);
|
|
746
|
+
throw error;
|
|
747
|
+
}
|
|
748
|
+
finally {
|
|
749
|
+
if (!isAsync) {
|
|
750
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
async _spanAutoAsync2(ctx, buffer, op, first, a1, a2) {
|
|
755
|
+
try {
|
|
756
|
+
let attempt = 1;
|
|
757
|
+
let result = await first;
|
|
758
|
+
while (true) {
|
|
759
|
+
const retryError = getRetryableError(result, attempt);
|
|
760
|
+
if (!retryError)
|
|
761
|
+
break;
|
|
762
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
763
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
764
|
+
await sleep(delay);
|
|
765
|
+
attempt++;
|
|
766
|
+
result = await op.fn(ctx, a1, a2);
|
|
767
|
+
}
|
|
768
|
+
writeSpanEnd(buffer, result);
|
|
769
|
+
return result;
|
|
770
|
+
}
|
|
771
|
+
catch (error) {
|
|
772
|
+
this._spanException(buffer, error);
|
|
773
|
+
throw error;
|
|
774
|
+
}
|
|
775
|
+
finally {
|
|
776
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
spanAuto3(line, name, op, a1, a2, a3) {
|
|
780
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
781
|
+
const buffer = ctx._spanBuffer;
|
|
782
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
783
|
+
let isAsync = false;
|
|
784
|
+
try {
|
|
785
|
+
const result = op.fn(ctx, a1, a2, a3);
|
|
786
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
787
|
+
isAsync = true;
|
|
788
|
+
return this._spanAutoAsync3(ctx, buffer, op, result, a1, a2, a3);
|
|
789
|
+
}
|
|
790
|
+
writeSpanEnd(buffer, result);
|
|
791
|
+
return result;
|
|
792
|
+
}
|
|
793
|
+
catch (error) {
|
|
794
|
+
this._spanException(buffer, error);
|
|
795
|
+
throw error;
|
|
796
|
+
}
|
|
797
|
+
finally {
|
|
798
|
+
if (!isAsync) {
|
|
799
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async _spanAutoAsync3(ctx, buffer, op, first, a1, a2, a3) {
|
|
804
|
+
try {
|
|
805
|
+
let attempt = 1;
|
|
806
|
+
let result = await first;
|
|
807
|
+
while (true) {
|
|
808
|
+
const retryError = getRetryableError(result, attempt);
|
|
809
|
+
if (!retryError)
|
|
810
|
+
break;
|
|
811
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
812
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
813
|
+
await sleep(delay);
|
|
814
|
+
attempt++;
|
|
815
|
+
result = await op.fn(ctx, a1, a2, a3);
|
|
816
|
+
}
|
|
817
|
+
writeSpanEnd(buffer, result);
|
|
818
|
+
return result;
|
|
819
|
+
}
|
|
820
|
+
catch (error) {
|
|
821
|
+
this._spanException(buffer, error);
|
|
822
|
+
throw error;
|
|
823
|
+
}
|
|
824
|
+
finally {
|
|
825
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
spanAuto4(line, name, op, a1, a2, a3, a4) {
|
|
829
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
830
|
+
const buffer = ctx._spanBuffer;
|
|
831
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
832
|
+
let isAsync = false;
|
|
833
|
+
try {
|
|
834
|
+
const result = op.fn(ctx, a1, a2, a3, a4);
|
|
835
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
836
|
+
isAsync = true;
|
|
837
|
+
return this._spanAutoAsync4(ctx, buffer, op, result, a1, a2, a3, a4);
|
|
838
|
+
}
|
|
839
|
+
writeSpanEnd(buffer, result);
|
|
840
|
+
return result;
|
|
841
|
+
}
|
|
842
|
+
catch (error) {
|
|
843
|
+
this._spanException(buffer, error);
|
|
844
|
+
throw error;
|
|
845
|
+
}
|
|
846
|
+
finally {
|
|
847
|
+
if (!isAsync) {
|
|
848
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
async _spanAutoAsync4(ctx, buffer, op, first, a1, a2, a3, a4) {
|
|
853
|
+
try {
|
|
854
|
+
let attempt = 1;
|
|
855
|
+
let result = await first;
|
|
856
|
+
while (true) {
|
|
857
|
+
const retryError = getRetryableError(result, attempt);
|
|
858
|
+
if (!retryError)
|
|
859
|
+
break;
|
|
860
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
861
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
862
|
+
await sleep(delay);
|
|
863
|
+
attempt++;
|
|
864
|
+
result = await op.fn(ctx, a1, a2, a3, a4);
|
|
865
|
+
}
|
|
866
|
+
writeSpanEnd(buffer, result);
|
|
867
|
+
return result;
|
|
868
|
+
}
|
|
869
|
+
catch (error) {
|
|
870
|
+
this._spanException(buffer, error);
|
|
871
|
+
throw error;
|
|
872
|
+
}
|
|
873
|
+
finally {
|
|
874
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
spanAuto5(line, name, op, a1, a2, a3, a4, a5) {
|
|
878
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
879
|
+
const buffer = ctx._spanBuffer;
|
|
880
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
881
|
+
let isAsync = false;
|
|
882
|
+
try {
|
|
883
|
+
const result = op.fn(ctx, a1, a2, a3, a4, a5);
|
|
884
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
885
|
+
isAsync = true;
|
|
886
|
+
return this._spanAutoAsync5(ctx, buffer, op, result, a1, a2, a3, a4, a5);
|
|
887
|
+
}
|
|
888
|
+
writeSpanEnd(buffer, result);
|
|
889
|
+
return result;
|
|
890
|
+
}
|
|
891
|
+
catch (error) {
|
|
892
|
+
this._spanException(buffer, error);
|
|
893
|
+
throw error;
|
|
894
|
+
}
|
|
895
|
+
finally {
|
|
896
|
+
if (!isAsync) {
|
|
897
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
async _spanAutoAsync5(ctx, buffer, op, first, a1, a2, a3, a4, a5) {
|
|
902
|
+
try {
|
|
903
|
+
let attempt = 1;
|
|
904
|
+
let result = await first;
|
|
905
|
+
while (true) {
|
|
906
|
+
const retryError = getRetryableError(result, attempt);
|
|
907
|
+
if (!retryError)
|
|
908
|
+
break;
|
|
909
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
910
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
911
|
+
await sleep(delay);
|
|
912
|
+
attempt++;
|
|
913
|
+
result = await op.fn(ctx, a1, a2, a3, a4, a5);
|
|
914
|
+
}
|
|
915
|
+
writeSpanEnd(buffer, result);
|
|
916
|
+
return result;
|
|
917
|
+
}
|
|
918
|
+
catch (error) {
|
|
919
|
+
this._spanException(buffer, error);
|
|
920
|
+
throw error;
|
|
921
|
+
}
|
|
922
|
+
finally {
|
|
923
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
spanAuto6(line, name, op, a1, a2, a3, a4, a5, a6) {
|
|
927
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
928
|
+
const buffer = ctx._spanBuffer;
|
|
929
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
930
|
+
let isAsync = false;
|
|
931
|
+
try {
|
|
932
|
+
const result = op.fn(ctx, a1, a2, a3, a4, a5, a6);
|
|
933
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
934
|
+
isAsync = true;
|
|
935
|
+
return this._spanAutoAsync6(ctx, buffer, op, result, a1, a2, a3, a4, a5, a6);
|
|
936
|
+
}
|
|
937
|
+
writeSpanEnd(buffer, result);
|
|
938
|
+
return result;
|
|
939
|
+
}
|
|
940
|
+
catch (error) {
|
|
941
|
+
this._spanException(buffer, error);
|
|
942
|
+
throw error;
|
|
943
|
+
}
|
|
944
|
+
finally {
|
|
945
|
+
if (!isAsync) {
|
|
946
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
async _spanAutoAsync6(ctx, buffer, op, first, a1, a2, a3, a4, a5, a6) {
|
|
951
|
+
try {
|
|
952
|
+
let attempt = 1;
|
|
953
|
+
let result = await first;
|
|
954
|
+
while (true) {
|
|
955
|
+
const retryError = getRetryableError(result, attempt);
|
|
956
|
+
if (!retryError)
|
|
957
|
+
break;
|
|
958
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
959
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
960
|
+
await sleep(delay);
|
|
961
|
+
attempt++;
|
|
962
|
+
result = await op.fn(ctx, a1, a2, a3, a4, a5, a6);
|
|
963
|
+
}
|
|
964
|
+
writeSpanEnd(buffer, result);
|
|
965
|
+
return result;
|
|
966
|
+
}
|
|
967
|
+
catch (error) {
|
|
968
|
+
this._spanException(buffer, error);
|
|
969
|
+
throw error;
|
|
970
|
+
}
|
|
971
|
+
finally {
|
|
972
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
spanAuto7(line, name, op, a1, a2, a3, a4, a5, a6, a7) {
|
|
976
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
977
|
+
const buffer = ctx._spanBuffer;
|
|
978
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
979
|
+
let isAsync = false;
|
|
980
|
+
try {
|
|
981
|
+
const result = op.fn(ctx, a1, a2, a3, a4, a5, a6, a7);
|
|
982
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
983
|
+
isAsync = true;
|
|
984
|
+
return this._spanAutoAsync7(ctx, buffer, op, result, a1, a2, a3, a4, a5, a6, a7);
|
|
985
|
+
}
|
|
986
|
+
writeSpanEnd(buffer, result);
|
|
987
|
+
return result;
|
|
988
|
+
}
|
|
989
|
+
catch (error) {
|
|
990
|
+
this._spanException(buffer, error);
|
|
991
|
+
throw error;
|
|
992
|
+
}
|
|
993
|
+
finally {
|
|
994
|
+
if (!isAsync) {
|
|
995
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
async _spanAutoAsync7(ctx, buffer, op, first, a1, a2, a3, a4, a5, a6, a7) {
|
|
1000
|
+
try {
|
|
1001
|
+
let attempt = 1;
|
|
1002
|
+
let result = await first;
|
|
1003
|
+
while (true) {
|
|
1004
|
+
const retryError = getRetryableError(result, attempt);
|
|
1005
|
+
if (!retryError)
|
|
1006
|
+
break;
|
|
1007
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
1008
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
1009
|
+
await sleep(delay);
|
|
1010
|
+
attempt++;
|
|
1011
|
+
result = await op.fn(ctx, a1, a2, a3, a4, a5, a6, a7);
|
|
1012
|
+
}
|
|
1013
|
+
writeSpanEnd(buffer, result);
|
|
1014
|
+
return result;
|
|
1015
|
+
}
|
|
1016
|
+
catch (error) {
|
|
1017
|
+
this._spanException(buffer, error);
|
|
1018
|
+
throw error;
|
|
1019
|
+
}
|
|
1020
|
+
finally {
|
|
1021
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
spanAuto8(line, name, op, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
1025
|
+
const ctx = this._spanAutoPre(line, name, op);
|
|
1026
|
+
const buffer = ctx._spanBuffer;
|
|
1027
|
+
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
1028
|
+
let isAsync = false;
|
|
1029
|
+
try {
|
|
1030
|
+
const result = op.fn(ctx, a1, a2, a3, a4, a5, a6, a7, a8);
|
|
1031
|
+
if (!isSynchronousResult(result) || getRetryableError(result, 1) !== undefined) {
|
|
1032
|
+
isAsync = true;
|
|
1033
|
+
return this._spanAutoAsync8(ctx, buffer, op, result, a1, a2, a3, a4, a5, a6, a7, a8);
|
|
1034
|
+
}
|
|
1035
|
+
writeSpanEnd(buffer, result);
|
|
1036
|
+
return result;
|
|
1037
|
+
}
|
|
1038
|
+
catch (error) {
|
|
1039
|
+
this._spanException(buffer, error);
|
|
1040
|
+
throw error;
|
|
1041
|
+
}
|
|
1042
|
+
finally {
|
|
1043
|
+
if (!isAsync) {
|
|
1044
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
async _spanAutoAsync8(ctx, buffer, op, first, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
1049
|
+
try {
|
|
1050
|
+
let attempt = 1;
|
|
1051
|
+
let result = await first;
|
|
1052
|
+
while (true) {
|
|
1053
|
+
const retryError = getRetryableError(result, attempt);
|
|
1054
|
+
if (!retryError)
|
|
1055
|
+
break;
|
|
1056
|
+
const delay = calculateDelay(retryError.policy, attempt);
|
|
1057
|
+
writeRetryEntry(buffer, attempt, retryError, delay);
|
|
1058
|
+
await sleep(delay);
|
|
1059
|
+
attempt++;
|
|
1060
|
+
result = await op.fn(ctx, a1, a2, a3, a4, a5, a6, a7, a8);
|
|
1061
|
+
}
|
|
1062
|
+
writeSpanEnd(buffer, result);
|
|
1063
|
+
return result;
|
|
1064
|
+
}
|
|
1065
|
+
catch (error) {
|
|
1066
|
+
this._spanException(buffer, error);
|
|
1067
|
+
throw error;
|
|
1068
|
+
}
|
|
1069
|
+
finally {
|
|
1070
|
+
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
599
1073
|
// =========================================================================
|
|
600
1074
|
// Monomorphic span methods (for transformer output)
|
|
601
|
-
// Transformer emits: ctx.span0(line, name, ctx, fn)
|
|
602
|
-
//
|
|
603
|
-
//
|
|
1075
|
+
// Transformer emits: ctx.span0(line, name, plan.newCtx0(ctx), plan, fn)
|
|
1076
|
+
// The frozen plan supplies the exact context source factory for each callsite.
|
|
1077
|
+
// User overrides are materialized by plan.newCtx1 without prototype allocation.
|
|
604
1078
|
// =========================================================================
|
|
605
|
-
spanSync0(line, name, childCtx,
|
|
606
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
607
|
-
const buffer = ctx.
|
|
1079
|
+
spanSync0(line, name, childCtx, callsitePlan, fn) {
|
|
1080
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1081
|
+
const buffer = ctx._spanBuffer;
|
|
608
1082
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
609
1083
|
try {
|
|
610
1084
|
const result = fn(ctx);
|
|
1085
|
+
if (!isSynchronousResult(result)) {
|
|
1086
|
+
throw new TypeError('spanSync operation returned a Promise');
|
|
1087
|
+
}
|
|
611
1088
|
writeSpanEnd(buffer, result);
|
|
612
1089
|
return result;
|
|
613
1090
|
}
|
|
@@ -619,13 +1096,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
619
1096
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
620
1097
|
}
|
|
621
1098
|
}
|
|
622
|
-
async span0(line, name, childCtx,
|
|
623
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
624
|
-
const buffer = ctx.
|
|
1099
|
+
async span0(line, name, childCtx, callsitePlan, fn) {
|
|
1100
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1101
|
+
const buffer = ctx._spanBuffer;
|
|
625
1102
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
626
1103
|
try {
|
|
627
1104
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
628
|
-
const result = await
|
|
1105
|
+
const result = await executeWithRetry0(buffer, fn, ctx);
|
|
629
1106
|
writeSpanEnd(buffer, result);
|
|
630
1107
|
return result;
|
|
631
1108
|
}
|
|
@@ -637,13 +1114,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
637
1114
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
638
1115
|
}
|
|
639
1116
|
}
|
|
640
|
-
async span1(line, name, childCtx,
|
|
641
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
642
|
-
const buffer = ctx.
|
|
1117
|
+
async span1(line, name, childCtx, callsitePlan, fn, a1) {
|
|
1118
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1119
|
+
const buffer = ctx._spanBuffer;
|
|
643
1120
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
644
1121
|
try {
|
|
645
1122
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
646
|
-
const result = await
|
|
1123
|
+
const result = await executeWithRetry1(buffer, fn, ctx, a1);
|
|
647
1124
|
writeSpanEnd(buffer, result);
|
|
648
1125
|
return result;
|
|
649
1126
|
}
|
|
@@ -655,13 +1132,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
655
1132
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
656
1133
|
}
|
|
657
1134
|
}
|
|
658
|
-
async span2(line, name, childCtx,
|
|
659
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
660
|
-
const buffer = ctx.
|
|
1135
|
+
async span2(line, name, childCtx, callsitePlan, fn, a1, a2) {
|
|
1136
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1137
|
+
const buffer = ctx._spanBuffer;
|
|
661
1138
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
662
1139
|
try {
|
|
663
1140
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
664
|
-
const result = await
|
|
1141
|
+
const result = await executeWithRetry2(buffer, fn, ctx, a1, a2);
|
|
665
1142
|
writeSpanEnd(buffer, result);
|
|
666
1143
|
return result;
|
|
667
1144
|
}
|
|
@@ -673,13 +1150,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
673
1150
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
674
1151
|
}
|
|
675
1152
|
}
|
|
676
|
-
async span3(line, name, childCtx,
|
|
677
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
678
|
-
const buffer = ctx.
|
|
1153
|
+
async span3(line, name, childCtx, callsitePlan, fn, a1, a2, a3) {
|
|
1154
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1155
|
+
const buffer = ctx._spanBuffer;
|
|
679
1156
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
680
1157
|
try {
|
|
681
1158
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
682
|
-
const result = await
|
|
1159
|
+
const result = await executeWithRetry3(buffer, fn, ctx, a1, a2, a3);
|
|
683
1160
|
writeSpanEnd(buffer, result);
|
|
684
1161
|
return result;
|
|
685
1162
|
}
|
|
@@ -691,13 +1168,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
691
1168
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
692
1169
|
}
|
|
693
1170
|
}
|
|
694
|
-
async span4(line, name, childCtx,
|
|
695
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
696
|
-
const buffer = ctx.
|
|
1171
|
+
async span4(line, name, childCtx, callsitePlan, fn, a1, a2, a3, a4) {
|
|
1172
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1173
|
+
const buffer = ctx._spanBuffer;
|
|
697
1174
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
698
1175
|
try {
|
|
699
1176
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
700
|
-
const result = await
|
|
1177
|
+
const result = await executeWithRetry4(buffer, fn, ctx, a1, a2, a3, a4);
|
|
701
1178
|
writeSpanEnd(buffer, result);
|
|
702
1179
|
return result;
|
|
703
1180
|
}
|
|
@@ -709,13 +1186,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
709
1186
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
710
1187
|
}
|
|
711
1188
|
}
|
|
712
|
-
async span5(line, name, childCtx,
|
|
713
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
714
|
-
const buffer = ctx.
|
|
1189
|
+
async span5(line, name, childCtx, callsitePlan, fn, a1, a2, a3, a4, a5) {
|
|
1190
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1191
|
+
const buffer = ctx._spanBuffer;
|
|
715
1192
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
716
1193
|
try {
|
|
717
1194
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
718
|
-
const result = await
|
|
1195
|
+
const result = await executeWithRetry5(buffer, fn, ctx, a1, a2, a3, a4, a5);
|
|
719
1196
|
writeSpanEnd(buffer, result);
|
|
720
1197
|
return result;
|
|
721
1198
|
}
|
|
@@ -727,13 +1204,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
727
1204
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
728
1205
|
}
|
|
729
1206
|
}
|
|
730
|
-
async span6(line, name, childCtx,
|
|
731
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
732
|
-
const buffer = ctx.
|
|
1207
|
+
async span6(line, name, childCtx, callsitePlan, fn, a1, a2, a3, a4, a5, a6) {
|
|
1208
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1209
|
+
const buffer = ctx._spanBuffer;
|
|
733
1210
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
734
1211
|
try {
|
|
735
1212
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
736
|
-
const result = await
|
|
1213
|
+
const result = await executeWithRetry6(buffer, fn, ctx, a1, a2, a3, a4, a5, a6);
|
|
737
1214
|
writeSpanEnd(buffer, result);
|
|
738
1215
|
return result;
|
|
739
1216
|
}
|
|
@@ -745,13 +1222,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
745
1222
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
746
1223
|
}
|
|
747
1224
|
}
|
|
748
|
-
async span7(line, name, childCtx,
|
|
749
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
750
|
-
const buffer = ctx.
|
|
1225
|
+
async span7(line, name, childCtx, callsitePlan, fn, a1, a2, a3, a4, a5, a6, a7) {
|
|
1226
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1227
|
+
const buffer = ctx._spanBuffer;
|
|
751
1228
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
752
1229
|
try {
|
|
753
1230
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
754
|
-
const result = await
|
|
1231
|
+
const result = await executeWithRetry7(buffer, fn, ctx, a1, a2, a3, a4, a5, a6, a7);
|
|
755
1232
|
writeSpanEnd(buffer, result);
|
|
756
1233
|
return result;
|
|
757
1234
|
}
|
|
@@ -763,13 +1240,13 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
763
1240
|
buffer._traceRoot.tracer.onSpanEnd(buffer);
|
|
764
1241
|
}
|
|
765
1242
|
}
|
|
766
|
-
async span8(line, name, childCtx,
|
|
767
|
-
const ctx = this._spanPre(childCtx, line, name,
|
|
768
|
-
const buffer = ctx.
|
|
1243
|
+
async span8(line, name, childCtx, callsitePlan, fn, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
1244
|
+
const ctx = this._spanPre(childCtx, line, name, callsitePlan, callsitePlan.metadata);
|
|
1245
|
+
const buffer = ctx._spanBuffer;
|
|
769
1246
|
buffer._traceRoot.tracer.onSpanStart(buffer);
|
|
770
1247
|
try {
|
|
771
1248
|
// Execute with retry loop - TransientError triggers retry, BlockedError returns immediately
|
|
772
|
-
const result = await
|
|
1249
|
+
const result = await executeWithRetry8(buffer, fn, ctx, a1, a2, a3, a4, a5, a6, a7, a8);
|
|
773
1250
|
writeSpanEnd(buffer, result);
|
|
774
1251
|
return result;
|
|
775
1252
|
}
|
|
@@ -783,6 +1260,7 @@ export function createSpanContextClass(_schemaOnly, logBinding) {
|
|
|
783
1260
|
}
|
|
784
1261
|
}
|
|
785
1262
|
const SpanContextCtor = SpanContextImpl;
|
|
1263
|
+
cache.set(cacheKey, SpanContextCtor);
|
|
786
1264
|
return SpanContextCtor;
|
|
787
1265
|
}
|
|
788
1266
|
// =============================================================================
|