Adds Flash Fallback logging and clearcut logging (#3843)

This commit is contained in:
uttamkanodia14
2025-07-12 02:40:25 +05:30
committed by GitHub
parent 764809753a
commit 5b5f496436
8 changed files with 93 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import {
EVENT_CLI_CONFIG,
EVENT_TOOL_CALL,
EVENT_USER_PROMPT,
EVENT_FLASH_FALLBACK,
SERVICE_NAME,
} from './constants.js';
import {
@@ -23,6 +24,7 @@ import {
StartSessionEvent,
ToolCallEvent,
UserPromptEvent,
FlashFallbackEvent,
} from './types.js';
import {
recordApiErrorMetrics,
@@ -156,6 +158,28 @@ export function logApiRequest(config: Config, event: ApiRequestEvent): void {
logger.emit(logRecord);
}
export function logFlashFallback(
config: Config,
event: FlashFallbackEvent,
): void {
ClearcutLogger.getInstance(config)?.logFlashFallbackEvent(event);
if (!isTelemetrySdkInitialized()) return;
const attributes: LogAttributes = {
...getCommonAttributes(config),
...event,
'event.name': EVENT_FLASH_FALLBACK,
'event.timestamp': new Date().toISOString(),
};
const logger = logs.getLogger(SERVICE_NAME);
const logRecord: LogRecord = {
body: `Switching to flash as Fallback.`,
attributes,
};
logger.emit(logRecord);
}
export function logApiError(config: Config, event: ApiErrorEvent): void {
const uiEvent = {
...event,