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

Function logAPISuccessAndDuration

src/services/api/logging.ts:581–788  ·  view source on GitHub ↗
({
  model,
  preNormalizedModel,
  start,
  startIncludingRetries,
  ttftMs,
  usage,
  attempt,
  messageCount,
  messageTokens,
  requestId,
  stopReason,
  didFallBackToNonStreaming,
  querySource,
  headers,
  costUSD,
  queryTracking,
  permissionMode,
  newMessages,
  llmSpan,
  globalCacheStrategy,
  requestSetupMs,
  attemptStartTimes,
  fastMode,
  previousRequestId,
  betas,
}: {
  model: string
  preNormalizedModel: string
  start: number
  startIncludingRetries: number
  ttftMs: number | null
  usage: NonNullableUsage
  attempt: number
  messageCount: number
  messageTokens: number
  requestId: string | null
  stopReason: BetaStopReason | null
  didFallBackToNonStreaming: boolean
  querySource: string
  headers?: globalThis.Headers
  costUSD: number
  queryTracking?: QueryChainTracking
  permissionMode?: PermissionMode
  /** Assistant messages from the response - used to extract model_output and thinking_output
   *  when beta tracing is enabled */
  newMessages?: AssistantMessage[]
  /** The span from startLLMRequestSpan - pass this to correctly match responses to requests */
  llmSpan?: Span
  /** Strategy used for global prompt caching: 'tool_based', 'system_prompt', or 'none' */
  globalCacheStrategy?: GlobalCacheStrategy
  /** Time spent in pre-request setup before the successful attempt */
  requestSetupMs?: number
  /** Timestamps (Date.now()) of each attempt start — used for retry sub-spans in Perfetto */
  attemptStartTimes?: number[]
  fastMode?: boolean
  /** Request ID from the previous API call in this session */
  previousRequestId?: string | null
  betas?: string[]
})

Source from the content-addressed store, hash-verified

579}
580
581export function logAPISuccessAndDuration({
582 model,
583 preNormalizedModel,
584 start,
585 startIncludingRetries,
586 ttftMs,
587 usage,
588 attempt,
589 messageCount,
590 messageTokens,
591 requestId,
592 stopReason,
593 didFallBackToNonStreaming,
594 querySource,
595 headers,
596 costUSD,
597 queryTracking,
598 permissionMode,
599 newMessages,
600 llmSpan,
601 globalCacheStrategy,
602 requestSetupMs,
603 attemptStartTimes,
604 fastMode,
605 previousRequestId,
606 betas,
607}: {
608 model: string
609 preNormalizedModel: string
610 start: number
611 startIncludingRetries: number
612 ttftMs: number | null
613 usage: NonNullableUsage
614 attempt: number
615 messageCount: number
616 messageTokens: number
617 requestId: string | null
618 stopReason: BetaStopReason | null
619 didFallBackToNonStreaming: boolean
620 querySource: string
621 headers?: globalThis.Headers
622 costUSD: number
623 queryTracking?: QueryChainTracking
624 permissionMode?: PermissionMode
625 /** Assistant messages from the response - used to extract model_output and thinking_output
626 * when beta tracing is enabled */
627 newMessages?: AssistantMessage[]
628 /** The span from startLLMRequestSpan - pass this to correctly match responses to requests */
629 llmSpan?: Span
630 /** Strategy used for global prompt caching: 'tool_based', 'system_prompt', or 'none' */
631 globalCacheStrategy?: GlobalCacheStrategy
632 /** Time spent in pre-request setup before the successful attempt */
633 requestSetupMs?: number
634 /** Timestamps (Date.now()) of each attempt start — used for retry sub-spans in Perfetto */
635 attemptStartTimes?: number[]
636 fastMode?: boolean
637 /** Request ID from the previous API call in this session */
638 previousRequestId?: string | null

Callers 1

queryModelFunction · 0.85

Calls 12

detectGatewayFunction · 0.85
featureFunction · 0.85
jsonStringifyFunction · 0.85
addToTotalDurationStateFunction · 0.85
logAPISuccessFunction · 0.85
logOTelEventFunction · 0.85
isBetaTracingEnabledFunction · 0.85
endLLMRequestSpanFunction · 0.85
getTeleportedSessionInfoFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected