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

Function startHookSpan

src/utils/telemetry/sessionTracing.ts:844–879  ·  view source on GitHub ↗
(
  hookEvent: string,
  hookName: string,
  numHooks: number,
  hookDefinitions: string,
)

Source from the content-addressed store, hash-verified

842 * @returns The span (or a dummy span if tracing is disabled)
843 */
844export function startHookSpan(
845 hookEvent: string,
846 hookName: string,
847 numHooks: number,
848 hookDefinitions: string,
849): Span {
850 if (!isBetaTracingEnabled()) {
851 return trace.getActiveSpan() || getTracer().startSpan('dummy')
852 }
853
854 const tracer = getTracer()
855 const parentSpanCtx = toolContext.getStore() ?? interactionContext.getStore()
856
857 const attributes = createSpanAttributes('hook', {
858 hook_event: hookEvent,
859 hook_name: hookName,
860 num_hooks: numHooks,
861 hook_definitions: hookDefinitions,
862 })
863
864 const ctx = parentSpanCtx
865 ? trace.setSpan(otelContext.active(), parentSpanCtx.span)
866 : otelContext.active()
867 const span = tracer.startSpan('claude_code.hook', { attributes }, ctx)
868
869 const spanId = getSpanId(span)
870 const spanContextObj: SpanContext = {
871 span,
872 startTime: Date.now(),
873 attributes,
874 }
875 activeSpans.set(spanId, new WeakRef(spanContextObj))
876 strongSpans.set(spanId, spanContextObj)
877
878 return span
879}
880
881/**
882 * End a hook execution span with outcome metadata.

Callers 1

executeHooksFunction · 0.85

Calls 6

isBetaTracingEnabledFunction · 0.85
getTracerFunction · 0.85
createSpanAttributesFunction · 0.85
getSpanIdFunction · 0.85
activeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected