mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-17 21:40:39 -07:00
feat(telemetry): add browser agent clearcut metrics (#24688)
This commit is contained in:
@@ -32,11 +32,11 @@ import { createAnalyzeScreenshotTool } from './analyzeScreenshot.js';
|
||||
import { injectAutomationOverlay } from './automationOverlay.js';
|
||||
import { injectInputBlocker } from './inputBlocker.js';
|
||||
import { debugLogger } from '../../utils/debugLogger.js';
|
||||
import { recordBrowserAgentToolDiscovery } from '../../telemetry/metrics.js';
|
||||
import {
|
||||
recordBrowserAgentToolDiscovery,
|
||||
recordBrowserAgentVisionStatus,
|
||||
recordBrowserAgentCleanup,
|
||||
} from '../../telemetry/metrics.js';
|
||||
logBrowserAgentVisionStatus,
|
||||
logBrowserAgentCleanup,
|
||||
} from '../../telemetry/loggers.js';
|
||||
import {
|
||||
PolicyDecision,
|
||||
PRIORITY_SUBAGENT_TOOL,
|
||||
@@ -248,7 +248,7 @@ export async function createBrowserAgentDefinition(
|
||||
const allTools: AnyDeclarativeTool[] = [...mcpTools];
|
||||
const visionDisabledReason = getVisionDisabledReason();
|
||||
|
||||
recordBrowserAgentVisionStatus(config, {
|
||||
logBrowserAgentVisionStatus(config, {
|
||||
enabled: !visionDisabledReason,
|
||||
disabled_reason: visionDisabledReason?.code,
|
||||
});
|
||||
@@ -299,13 +299,13 @@ export async function cleanupBrowserAgent(
|
||||
const startMs = Date.now();
|
||||
try {
|
||||
await browserManager.close();
|
||||
recordBrowserAgentCleanup(config, Date.now() - startMs, {
|
||||
logBrowserAgentCleanup(config, Date.now() - startMs, {
|
||||
session_mode: sessionMode,
|
||||
success: true,
|
||||
});
|
||||
debugLogger.log('Browser agent cleanup complete');
|
||||
} catch (error) {
|
||||
recordBrowserAgentCleanup(config, Date.now() - startMs, {
|
||||
logBrowserAgentCleanup(config, Date.now() - startMs, {
|
||||
session_mode: sessionMode,
|
||||
success: false,
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
import type { MessageBus } from '../../confirmation-bus/message-bus.js';
|
||||
import { createBrowserAgentDefinition } from './browserAgentFactory.js';
|
||||
import { removeInputBlocker } from './inputBlocker.js';
|
||||
import { recordBrowserAgentTaskOutcome } from '../../telemetry/metrics.js';
|
||||
import { logBrowserAgentTaskOutcome } from '../../telemetry/loggers.js';
|
||||
import {
|
||||
sanitizeThoughtContent,
|
||||
sanitizeToolArgs,
|
||||
@@ -397,7 +397,7 @@ ${output.result}`;
|
||||
},
|
||||
};
|
||||
} finally {
|
||||
recordBrowserAgentTaskOutcome(this.config, {
|
||||
logBrowserAgentTaskOutcome(this.config, {
|
||||
success: taskSuccess,
|
||||
session_mode: sessionMode,
|
||||
vision_enabled: visionEnabled,
|
||||
|
||||
@@ -373,6 +373,7 @@ describe('BrowserManager', () => {
|
||||
session_mode: 'persistent',
|
||||
headless: false,
|
||||
success: true,
|
||||
tool_count: 4,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ import * as path from 'node:path';
|
||||
import * as fs from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { injectAutomationOverlay } from './automationOverlay.js';
|
||||
import { recordBrowserAgentConnection } from '../../telemetry/metrics.js';
|
||||
import { logBrowserAgentConnection } from '../../telemetry/loggers.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
@@ -563,7 +563,9 @@ export class BrowserManager {
|
||||
// Add optional settings from config.
|
||||
// Force headless in seatbelt sandbox since Chrome profile/display access
|
||||
// may be restricted, and the user is running in a sandboxed environment.
|
||||
if (browserConfig.customConfig.headless || isSeatbeltSandbox) {
|
||||
const effectiveHeadless =
|
||||
!!browserConfig.customConfig.headless || isSeatbeltSandbox;
|
||||
if (effectiveHeadless) {
|
||||
mcpArgs.push('--headless');
|
||||
}
|
||||
if (browserConfig.customConfig.profilePath) {
|
||||
@@ -667,15 +669,12 @@ export class BrowserManager {
|
||||
// clear the action counter for each connection
|
||||
this.actionCounter = 0;
|
||||
|
||||
recordBrowserAgentConnection(
|
||||
this.config,
|
||||
Date.now() - connectStartMs,
|
||||
{
|
||||
session_mode: sessionMode,
|
||||
headless: !!browserConfig.customConfig.headless,
|
||||
success: true,
|
||||
},
|
||||
);
|
||||
logBrowserAgentConnection(this.config, Date.now() - connectStartMs, {
|
||||
session_mode: sessionMode,
|
||||
headless: effectiveHeadless,
|
||||
success: true,
|
||||
tool_count: this.discoveredTools.length,
|
||||
});
|
||||
})(),
|
||||
new Promise<never>((_, reject) => {
|
||||
timeoutId = setTimeout(
|
||||
@@ -696,9 +695,9 @@ export class BrowserManager {
|
||||
error instanceof Error ? error.message : String(error);
|
||||
const errorType = BrowserManager.classifyConnectionError(rawErrorMessage);
|
||||
|
||||
recordBrowserAgentConnection(this.config, Date.now() - connectStartMs, {
|
||||
logBrowserAgentConnection(this.config, Date.now() - connectStartMs, {
|
||||
session_mode: sessionMode,
|
||||
headless: !!browserConfig.customConfig.headless,
|
||||
headless: effectiveHeadless,
|
||||
success: false,
|
||||
error_type: errorType,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user