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

Function endHookSpan

src/utils/telemetry/sessionTracing.ts:887–927  ·  view source on GitHub ↗
(
  span: Span,
  metadata?: {
    numSuccess?: number
    numBlocking?: number
    numNonBlockingError?: number
    numCancelled?: number
  },
)

Source from the content-addressed store, hash-verified

885 * @param metadata The outcome metadata for the hook execution
886 */
887export function endHookSpan(
888 span: Span,
889 metadata?: {
890 numSuccess?: number
891 numBlocking?: number
892 numNonBlockingError?: number
893 numCancelled?: number
894 },
895): void {
896 if (!isBetaTracingEnabled()) {
897 return
898 }
899
900 const spanId = getSpanId(span)
901 const spanContext = activeSpans.get(spanId)?.deref()
902
903 if (!spanContext) {
904 return
905 }
906
907 const duration = Date.now() - spanContext.startTime
908 const endAttributes: Record<string, string | number | boolean> = {
909 duration_ms: duration,
910 }
911
912 if (metadata) {
913 if (metadata.numSuccess !== undefined)
914 endAttributes['num_success'] = metadata.numSuccess
915 if (metadata.numBlocking !== undefined)
916 endAttributes['num_blocking'] = metadata.numBlocking
917 if (metadata.numNonBlockingError !== undefined)
918 endAttributes['num_non_blocking_error'] = metadata.numNonBlockingError
919 if (metadata.numCancelled !== undefined)
920 endAttributes['num_cancelled'] = metadata.numCancelled
921 }
922
923 spanContext.span.setAttributes(endAttributes)
924 spanContext.span.end()
925 activeSpans.delete(spanId)
926 strongSpans.delete(spanId)
927}
928

Callers 1

executeHooksFunction · 0.85

Calls 5

isBetaTracingEnabledFunction · 0.85
getSpanIdFunction · 0.85
getMethod · 0.65
deleteMethod · 0.65
endMethod · 0.45

Tested by

no test coverage detected