Skip to content

Commit 7c3a840

Browse files
authored
Log flash continue (google-gemini#4700)
1 parent 67008d4 commit 7c3a840

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

packages/core/src/core/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { ProxyAgent, setGlobalDispatcher } from 'undici';
4343
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
4444
import { LoopDetectionService } from '../services/loopDetectionService.js';
4545
import { ideContext } from '../services/ideContext.js';
46-
import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js';
46+
import { logFlashDecidedToContinue } from '../telemetry/loggers.js';
4747
import { FlashDecidedToContinueEvent } from '../telemetry/types.js';
4848

4949
function isThinkingSupported(model: string) {
@@ -388,7 +388,8 @@ export class GeminiClient {
388388
signal,
389389
);
390390
if (nextSpeakerCheck?.next_speaker === 'model') {
391-
ClearcutLogger.getInstance(this.config)?.logFlashDecidedToContinueEvent(
391+
logFlashDecidedToContinue(
392+
this.config,
392393
new FlashDecidedToContinueEvent(prompt_id),
393394
);
394395
const nextRequest = [{ text: 'Please continue.' }];

packages/core/src/telemetry/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const EVENT_API_ERROR = 'gemini_cli.api_error';
1313
export const EVENT_API_RESPONSE = 'gemini_cli.api_response';
1414
export const EVENT_CLI_CONFIG = 'gemini_cli.config';
1515
export const EVENT_FLASH_FALLBACK = 'gemini_cli.flash_fallback';
16+
export const EVENT_FLASH_DECIDED_TO_CONTINUE =
17+
'gemini_cli.flash_decided_to_continue';
1618

1719
export const METRIC_TOOL_CALL_COUNT = 'gemini_cli.tool.call.count';
1820
export const METRIC_TOOL_CALL_LATENCY = 'gemini_cli.tool.call.latency';

packages/core/src/telemetry/loggers.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
EVENT_TOOL_CALL,
1616
EVENT_USER_PROMPT,
1717
EVENT_FLASH_FALLBACK,
18+
EVENT_FLASH_DECIDED_TO_CONTINUE,
1819
SERVICE_NAME,
1920
} from './constants.js';
2021
import {
@@ -25,6 +26,7 @@ import {
2526
ToolCallEvent,
2627
UserPromptEvent,
2728
FlashFallbackEvent,
29+
FlashDecidedToContinueEvent,
2830
LoopDetectedEvent,
2931
} from './types.js';
3032
import {
@@ -309,3 +311,24 @@ export function logLoopDetected(
309311
};
310312
logger.emit(logRecord);
311313
}
314+
315+
export function logFlashDecidedToContinue(
316+
config: Config,
317+
event: FlashDecidedToContinueEvent,
318+
): void {
319+
ClearcutLogger.getInstance(config)?.logFlashDecidedToContinueEvent(event);
320+
if (!isTelemetrySdkInitialized()) return;
321+
322+
const attributes: LogAttributes = {
323+
...getCommonAttributes(config),
324+
...event,
325+
'event.name': EVENT_FLASH_DECIDED_TO_CONTINUE,
326+
};
327+
328+
const logger = logs.getLogger(SERVICE_NAME);
329+
const logRecord: LogRecord = {
330+
body: `Flash decided to continue.`,
331+
attributes,
332+
};
333+
logger.emit(logRecord);
334+
}

0 commit comments

Comments
 (0)