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

Function endToolExecutionSpan

src/utils/telemetry/sessionTracing.ts:657–689  ·  view source on GitHub ↗
(metadata?: {
  success?: boolean
  error?: string
})

Source from the content-addressed store, hash-verified

655}
656
657export function endToolExecutionSpan(metadata?: {
658 success?: boolean
659 error?: string
660}): void {
661 if (!isAnyTracingEnabled()) {
662 return
663 }
664
665 const executionSpanContext = Array.from(activeSpans.values())
666 .findLast(r => r.deref()?.attributes['span.type'] === 'tool.execution')
667 ?.deref()
668
669 if (!executionSpanContext) {
670 return
671 }
672
673 const duration = Date.now() - executionSpanContext.startTime
674 const attributes: Record<string, string | number | boolean> = {
675 duration_ms: duration,
676 }
677
678 if (metadata) {
679 if (metadata.success !== undefined) attributes['success'] = metadata.success
680 if (metadata.error !== undefined) attributes['error'] = metadata.error
681 }
682
683 executionSpanContext.span.setAttributes(attributes)
684 executionSpanContext.span.end()
685
686 const spanId = getSpanId(executionSpanContext.span)
687 activeSpans.delete(spanId)
688 strongSpans.delete(spanId)
689}
690
691export function endToolSpan(toolResult?: string, resultTokens?: number): void {
692 const toolSpanContext = toolContext.getStore()

Callers 1

Calls 5

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

Tested by

no test coverage detected