MCPcopy Index your code
hub / github.com/codeaashu/claude-code / endToolBlockedOnUserSpan

Function endToolBlockedOnUserSpan

src/utils/telemetry/sessionTracing.ts:577–624  ·  view source on GitHub ↗
(
  decision?: string,
  source?: string,
)

Source from the content-addressed store, hash-verified

575}
576
577export function endToolBlockedOnUserSpan(
578 decision?: string,
579 source?: string,
580): void {
581 const blockedSpanContext = Array.from(activeSpans.values())
582 .findLast(
583 r => r.deref()?.attributes['span.type'] === 'tool.blocked_on_user',
584 )
585 ?.deref()
586
587 if (!blockedSpanContext) {
588 return
589 }
590
591 // End Perfetto span
592 if (blockedSpanContext.perfettoSpanId) {
593 endUserInputPerfettoSpan(blockedSpanContext.perfettoSpanId, {
594 decision,
595 source,
596 })
597 }
598
599 if (!isAnyTracingEnabled()) {
600 const spanId = getSpanId(blockedSpanContext.span)
601 activeSpans.delete(spanId)
602 strongSpans.delete(spanId)
603 return
604 }
605
606 const duration = Date.now() - blockedSpanContext.startTime
607 const attributes: Record<string, string | number | boolean> = {
608 duration_ms: duration,
609 }
610
611 if (decision) {
612 attributes['decision'] = decision
613 }
614 if (source) {
615 attributes['source'] = source
616 }
617
618 blockedSpanContext.span.setAttributes(attributes)
619 blockedSpanContext.span.end()
620
621 const spanId = getSpanId(blockedSpanContext.span)
622 activeSpans.delete(spanId)
623 strongSpans.delete(spanId)
624}
625
626export function startToolExecutionSpan(): Span {
627 if (!isAnyTracingEnabled()) {

Callers 1

Calls 6

endUserInputPerfettoSpanFunction · 0.85
isAnyTracingEnabledFunction · 0.85
getSpanIdFunction · 0.85
valuesMethod · 0.80
deleteMethod · 0.65
endMethod · 0.45

Tested by

no test coverage detected