MCPcopy Index your code
hub / github.com/simstudioai/sim / countTraceSpans

Function countTraceSpans

apps/sim/scripts/backfill-trace-spans.ts:44–51  ·  view source on GitHub ↗

* Recursively counts trace spans (matching the completion path). Legacy rows * predate the inline hasTraceSpans/traceSpanCount markers, so we derive them * before externalizing — otherwise a post-expiry degraded read can't report * "trace data expired (N spans)".

(spans: unknown)

Source from the content-addressed store, hash-verified

42 * "trace data expired (N spans)".
43 */
44function countTraceSpans(spans: unknown): number {
45 if (!Array.isArray(spans)) return 0
46 return spans.reduce(
47 (count: number, span) =>
48 count + 1 + countTraceSpans((span as { children?: unknown } | null)?.children),
49 0
50 )
51}
52
53interface Options {
54 maxBatches: number

Callers 1

backfillTraceStorageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected