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

Function selectSpans

apps/sim/lib/logs/log-views.ts:91–108  ·  view source on GitHub ↗
(spans: TraceSpan[], selector?: BlockSelector)

Source from the content-addressed store, hash-verified

89}
90
91function selectSpans(spans: TraceSpan[], selector?: BlockSelector): TraceSpan[] {
92 if (!selector || (!selector.blockId && !selector.blockName)) return spans
93 const out: TraceSpan[] = []
94 const walk = (list: TraceSpan[]): void => {
95 for (const s of list) {
96 const matches =
97 (selector.blockId !== undefined && s.blockId === selector.blockId) ||
98 (selector.blockName !== undefined && s.name === selector.blockName)
99 if (matches) {
100 out.push(s)
101 } else if (s.children && s.children.length > 0) {
102 walk(s.children)
103 }
104 }
105 }
106 walk(spans)
107 return out
108}
109
110async function fullSpan(s: TraceSpan, ctx: LogViewContext): Promise<FullSpan> {
111 const node: FullSpan = {

Callers 1

toFullFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected