MCPcopy Create free account
hub / github.com/Noumena-Network/code / logAPISuccessAndDuration

Function logAPISuccessAndDuration

src/services/api/logging.ts:590–797  ·  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

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

Callers 1

queryModelFunction · 0.85

Calls 14

detectGatewayFunction · 0.85
isConnectorTextBlockFunction · 0.85
jsonStringifyFunction · 0.85
addToTotalDurationStateFunction · 0.85
logAPISuccessFunction · 0.85
logOTelEventFunction · 0.85
isBetaTracingEnabledFunction · 0.85
isInternalBuildFunction · 0.85
endLLMRequestSpanFunction · 0.85
getTeleportedSessionInfoFunction · 0.85

Tested by

no test coverage detected