mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-16 21:10:40 -07:00
feat: Add OTEL log event gemini_cli.startup_stats for startup stats. (#14734)
This commit is contained in:
@@ -10,6 +10,8 @@ import * as fs from 'node:fs';
|
||||
import type { Config } from '../config/config.js';
|
||||
import { recordStartupPerformance } from './metrics.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
import { StartupStatsEvent, type StartupPhaseStats } from './types.js';
|
||||
import { logStartupStats } from './loggers.js';
|
||||
|
||||
interface StartupPhase {
|
||||
name: string;
|
||||
@@ -197,6 +199,37 @@ export class StartupProfiler {
|
||||
}
|
||||
}
|
||||
|
||||
// Emit StartupStats event
|
||||
const startupPhases: StartupPhaseStats[] = [];
|
||||
for (const phase of this.phases.values()) {
|
||||
if (!phase.ended) continue;
|
||||
const measure = measures.find((m) => m.name === phase.name);
|
||||
if (measure && phase.cpuUsage) {
|
||||
startupPhases.push({
|
||||
name: phase.name,
|
||||
duration_ms: measure.duration,
|
||||
cpu_usage_user_usec: phase.cpuUsage.user,
|
||||
cpu_usage_system_usec: phase.cpuUsage.system,
|
||||
start_time_usec: (performance.timeOrigin + measure.startTime) * 1000,
|
||||
end_time_usec:
|
||||
(performance.timeOrigin + measure.startTime + measure.duration) *
|
||||
1000,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (startupPhases.length > 0) {
|
||||
logStartupStats(
|
||||
config,
|
||||
new StartupStatsEvent(
|
||||
startupPhases,
|
||||
os.platform(),
|
||||
os.release(),
|
||||
fs.existsSync('/.dockerenv'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Clear performance marks and measures for all tracked phases.
|
||||
for (const phaseName of this.phases.keys()) {
|
||||
const startMarkName = this.getStartMarkName(phaseName);
|
||||
|
||||
Reference in New Issue
Block a user