Log Model Slash Commands (#9250)

This commit is contained in:
Victor May
2025-09-23 18:06:03 -04:00
committed by GitHub
parent 28c3901513
commit 4bd4cd697b
8 changed files with 128 additions and 31 deletions
+25
View File
@@ -32,6 +32,7 @@ import {
EVENT_RIPGREP_FALLBACK,
EVENT_MODEL_ROUTING,
EVENT_EXTENSION_INSTALL,
EVENT_MODEL_SLASH_COMMAND,
EVENT_EXTENSION_DISABLE,
} from './constants.js';
import type {
@@ -62,6 +63,7 @@ import type {
ExtensionEnableEvent,
ExtensionUninstallEvent,
ExtensionInstallEvent,
ModelSlashCommandEvent,
} from './types.js';
import {
recordApiErrorMetrics,
@@ -74,6 +76,7 @@ import {
recordContentRetry,
recordContentRetryFailure,
recordModelRoutingMetrics,
recordModelSlashCommand,
} from './metrics.js';
import { isTelemetrySdkInitialized } from './sdk.js';
import type { UiEvent } from './uiTelemetry.js';
@@ -700,6 +703,28 @@ export function logModelRouting(
recordModelRoutingMetrics(config, event);
}
export function logModelSlashCommand(
config: Config,
event: ModelSlashCommandEvent,
): void {
ClearcutLogger.getInstance(config)?.logModelSlashCommandEvent(event);
if (!isTelemetrySdkInitialized()) return;
const attributes: LogAttributes = {
...getCommonAttributes(config),
...event,
'event.name': EVENT_MODEL_SLASH_COMMAND,
};
const logger = logs.getLogger(SERVICE_NAME);
const logRecord: LogRecord = {
body: `Model slash command. Model: ${event.model_name}`,
attributes,
};
logger.emit(logRecord);
recordModelSlashCommand(config, event);
}
export function logExtensionInstallEvent(
config: Config,
event: ExtensionInstallEvent,