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

@@ -23,6 +23,7 @@ import {
EVENT_CLI_CONFIG,
EVENT_TOOL_CALL,
EVENT_USER_PROMPT,
EVENT_FLASH_FALLBACK,
} from './constants.js';
import {
logApiRequest,
@@ -30,6 +31,7 @@ import {
logCliConfiguration,
logUserPrompt,
logToolCall,
logFlashFallback,
} from './loggers.js';
import {
ApiRequestEvent,
@@ -38,6 +40,7 @@ import {
ToolCallDecision,
ToolCallEvent,
UserPromptEvent,
FlashFallbackEvent,
} from './types.js';
import * as metrics from './metrics.js';
import * as sdk from './sdk.js';
@@ -350,6 +353,29 @@ describe('loggers', () => {
});
});
describe('logFlashFallback', () => {
const mockConfig = {
getSessionId: () => 'test-session-id',
getUsageStatisticsEnabled: () => true,
} as unknown as Config;
it('should log flash fallback event', () => {
const event = new FlashFallbackEvent(AuthType.USE_VERTEX_AI);
logFlashFallback(mockConfig, event);
expect(mockLogger.emit).toHaveBeenCalledWith({
body: 'Switching to flash as Fallback.',
attributes: {
'session.id': 'test-session-id',
'event.name': EVENT_FLASH_FALLBACK,
'event.timestamp': '2025-01-01T00:00:00.000Z',
auth_type: 'vertex-ai',
},
});
});
});
describe('logToolCall', () => {
const cfg1 = {
getSessionId: () => 'test-session-id',