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

Function endInteractionSpan

src/utils/telemetry/sessionTracing.ts:237–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

235}
236
237export function endInteractionSpan(): void {
238 const spanContext = interactionContext.getStore()
239 if (!spanContext) {
240 return
241 }
242
243 if (spanContext.ended) {
244 return
245 }
246
247 // End Perfetto span
248 if (spanContext.perfettoSpanId) {
249 endInteractionPerfettoSpan(spanContext.perfettoSpanId)
250 }
251
252 if (!isAnyTracingEnabled()) {
253 spanContext.ended = true
254 activeSpans.delete(getSpanId(spanContext.span))
255 // Clear the store so async continuations created after this point (timers,
256 // promise callbacks, I/O) do not inherit a reference to the ended span.
257 // enterWith(undefined) is intentional: exit(() => {}) is a no-op because it
258 // only suppresses the store inside the callback and returns immediately.
259 interactionContext.enterWith(undefined)
260 return
261 }
262
263 const duration = Date.now() - spanContext.startTime
264 spanContext.span.setAttributes({
265 'interaction.duration_ms': duration,
266 })
267
268 spanContext.span.end()
269 spanContext.ended = true
270 activeSpans.delete(getSpanId(spanContext.span))
271 interactionContext.enterWith(undefined)
272}
273
274export function startLLMRequestSpan(
275 model: string,

Callers 2

shutdownTelemetryFunction · 0.85
REPLFunction · 0.85

Calls 5

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

Tested by

no test coverage detected