Smart Edit Strategy Logging (#10345)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Victor May
2025-10-01 17:53:53 -04:00
committed by GitHub
parent a404fb8d2e
commit 8174e1d5b8
7 changed files with 76 additions and 6 deletions
@@ -31,6 +31,7 @@ import type {
ExtensionEnableEvent,
ModelSlashCommandEvent,
ExtensionDisableEvent,
SmartEditStrategyEvent,
} from '../types.js';
import { EventMetadataKey } from './event-metadata-key.js';
import type { Config } from '../../config/config.js';
@@ -75,6 +76,7 @@ export enum EventNames {
TOOL_OUTPUT_TRUNCATED = 'tool_output_truncated',
MODEL_ROUTING = 'model_routing',
MODEL_SLASH_COMMAND = 'model_slash_command',
SMART_EDIT_STRATEGY = 'smart_edit_strategy',
}
export interface LogResponse {
@@ -1039,6 +1041,20 @@ export class ClearcutLogger {
this.flushIfNeeded();
}
logSmartEditStrategyEvent(event: SmartEditStrategyEvent): void {
const data: EventValue[] = [
{
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SMART_EDIT_STRATEGY,
value: event.strategy,
},
];
this.enqueueLogEvent(
this.createLogEvent(EventNames.SMART_EDIT_STRATEGY, data),
);
this.flushIfNeeded();
}
/**
* Adds default fields to data, and returns a new data array. This fields
* should exist on all log events.
@@ -416,4 +416,7 @@ export enum EventMetadataKey {
// Logs an event when the user uses the /model command.
GEMINI_CLI_MODEL_SLASH_COMMAND = 108,
// Logs a smart edit tool strategy choice.
GEMINI_CLI_SMART_EDIT_STRATEGY = 109,
}
+1
View File
@@ -31,6 +31,7 @@ export const EVENT_CONTENT_RETRY_FAILURE =
'gemini_cli.chat.content_retry_failure';
export const EVENT_FILE_OPERATION = 'gemini_cli.file_operation';
export const EVENT_MODEL_SLASH_COMMAND = 'gemini_cli.slash_command.model';
export const EVENT_SMART_EDIT_STRATEGY = 'gemini_cli.smart_edit.strategy';
export const EVENT_MODEL_ROUTING = 'gemini_cli.model_routing';
// Performance Events
+23
View File
@@ -34,6 +34,7 @@ import {
EVENT_EXTENSION_INSTALL,
EVENT_MODEL_SLASH_COMMAND,
EVENT_EXTENSION_DISABLE,
EVENT_SMART_EDIT_STRATEGY,
} from './constants.js';
import type {
ApiErrorEvent,
@@ -64,6 +65,7 @@ import type {
ExtensionUninstallEvent,
ExtensionInstallEvent,
ModelSlashCommandEvent,
SmartEditStrategyEvent,
} from './types.js';
import {
recordApiErrorMetrics,
@@ -816,3 +818,24 @@ export function logExtensionDisable(
};
logger.emit(logRecord);
}
export function logSmartEditStrategy(
config: Config,
event: SmartEditStrategyEvent,
): void {
ClearcutLogger.getInstance(config)?.logSmartEditStrategyEvent(event);
if (!isTelemetrySdkInitialized()) return;
const attributes: LogAttributes = {
...getCommonAttributes(config),
...event,
'event.name': EVENT_SMART_EDIT_STRATEGY,
};
const logger = logs.getLogger(SERVICE_NAME);
const logRecord: LogRecord = {
body: `Smart Edit Tool Strategy: ${event.strategy}`,
attributes,
};
logger.emit(logRecord);
}
+12
View File
@@ -702,3 +702,15 @@ export class ExtensionDisableEvent implements BaseTelemetryEvent {
this.setting_scope = settingScope;
}
}
export class SmartEditStrategyEvent implements BaseTelemetryEvent {
'event.name': 'smart_edit_strategy';
'event.timestamp': string;
strategy: string;
constructor(strategy: string) {
this['event.name'] = 'smart_edit_strategy';
this['event.timestamp'] = new Date().toISOString();
this.strategy = strategy;
}
}