* 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)
| 42 | * "trace data expired (N spans)". |
| 43 | */ |
| 44 | function 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 | |
| 53 | interface Options { |
| 54 | maxBatches: number |
no outgoing calls
no test coverage detected