mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-18 22:10:52 -07:00
feat: Add OTEL log event gemini_cli.startup_stats for startup stats. (#14734)
This commit is contained in:
@@ -13,6 +13,11 @@ vi.mock('./metrics.js', () => ({
|
||||
recordStartupPerformance: vi.fn(),
|
||||
}));
|
||||
|
||||
// Mock loggers module
|
||||
vi.mock('./loggers.js', () => ({
|
||||
logStartupStats: vi.fn(),
|
||||
}));
|
||||
|
||||
// Mock os module
|
||||
vi.mock('node:os', () => ({
|
||||
platform: vi.fn(() => 'darwin'),
|
||||
@@ -33,6 +38,7 @@ describe('StartupProfiler', () => {
|
||||
let profiler: StartupProfiler;
|
||||
let mockConfig: Config;
|
||||
let recordStartupPerformance: ReturnType<typeof vi.fn>;
|
||||
let logStartupStats: ReturnType<typeof vi.fn>;
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetAllMocks();
|
||||
@@ -42,6 +48,9 @@ describe('StartupProfiler', () => {
|
||||
recordStartupPerformance =
|
||||
metricsModule.recordStartupPerformance as ReturnType<typeof vi.fn>;
|
||||
|
||||
const loggersModule = await import('./loggers.js');
|
||||
logStartupStats = loggersModule.logStartupStats as ReturnType<typeof vi.fn>;
|
||||
|
||||
// Create a fresh profiler instance
|
||||
profiler = StartupProfiler.getInstance();
|
||||
|
||||
@@ -343,5 +352,28 @@ describe('StartupProfiler', () => {
|
||||
expect.objectContaining({ phase: 'complete_phase' }),
|
||||
);
|
||||
});
|
||||
it('should log startup stats event', () => {
|
||||
const handle = profiler.start('test_phase');
|
||||
handle?.end();
|
||||
|
||||
profiler.flush(mockConfig);
|
||||
|
||||
expect(logStartupStats).toHaveBeenCalledWith(
|
||||
mockConfig,
|
||||
expect.objectContaining({
|
||||
phases: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
name: 'test_phase',
|
||||
duration_ms: expect.any(Number),
|
||||
start_time_usec: expect.any(Number),
|
||||
end_time_usec: expect.any(Number),
|
||||
}),
|
||||
]),
|
||||
os_platform: 'darwin',
|
||||
os_release: '22.6.0',
|
||||
is_docker: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user