mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-11 02:20:48 -07:00
feat(telemetry): ensure all telemetry includes user email and installation id (#10897)
This commit is contained in:
@@ -71,6 +71,7 @@ function originalOtelMockFactory() {
|
||||
}
|
||||
|
||||
vi.mock('@opentelemetry/api');
|
||||
vi.mock('./telemetryAttributes.js');
|
||||
|
||||
describe('Telemetry Metrics', () => {
|
||||
let initializeMetricsModule: typeof import('./metrics.js').initializeMetrics;
|
||||
@@ -100,6 +101,13 @@ describe('Telemetry Metrics', () => {
|
||||
return actualApi;
|
||||
});
|
||||
|
||||
const { getCommonAttributes } = await import('./telemetryAttributes.js');
|
||||
(getCommonAttributes as Mock).mockReturnValue({
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
});
|
||||
|
||||
const metricsJsModule = await import('./metrics.js');
|
||||
initializeMetricsModule = metricsJsModule.initializeMetrics;
|
||||
recordTokenUsageMetricsModule = metricsJsModule.recordTokenUsageMetrics;
|
||||
@@ -138,6 +146,23 @@ describe('Telemetry Metrics', () => {
|
||||
mockCreateHistogramFn.mockReturnValue(mockHistogramInstance);
|
||||
});
|
||||
|
||||
describe('initializeMetrics', () => {
|
||||
const mockConfig = {
|
||||
getSessionId: () => 'test-session-id',
|
||||
getTelemetryEnabled: () => true,
|
||||
} as unknown as Config;
|
||||
|
||||
it('should apply common attributes including email', () => {
|
||||
initializeMetricsModule(mockConfig);
|
||||
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('recordChatCompressionMetrics', () => {
|
||||
it('does not record metrics if not initialized', () => {
|
||||
const lol = makeFakeConfig({});
|
||||
@@ -161,6 +186,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
tokens_after: 100,
|
||||
tokens_before: 200,
|
||||
});
|
||||
@@ -190,9 +217,13 @@ describe('Telemetry Metrics', () => {
|
||||
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
||||
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 100, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
type: 'input',
|
||||
});
|
||||
@@ -208,6 +239,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(50, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
type: 'output',
|
||||
});
|
||||
@@ -218,6 +251,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(25, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
type: 'thought',
|
||||
});
|
||||
@@ -228,6 +263,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(75, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
type: 'cache',
|
||||
});
|
||||
@@ -238,6 +275,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(125, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
type: 'tool',
|
||||
});
|
||||
@@ -253,6 +292,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(200, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-ultra',
|
||||
type: 'input',
|
||||
});
|
||||
@@ -287,9 +328,13 @@ describe('Telemetry Metrics', () => {
|
||||
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
||||
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
operation: FileOperation.CREATE,
|
||||
lines: 10,
|
||||
mimetype: 'text/plain',
|
||||
@@ -306,6 +351,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
operation: FileOperation.READ,
|
||||
});
|
||||
});
|
||||
@@ -320,6 +367,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
operation: FileOperation.UPDATE,
|
||||
mimetype: 'application/javascript',
|
||||
});
|
||||
@@ -335,6 +384,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
operation: FileOperation.UPDATE,
|
||||
});
|
||||
});
|
||||
@@ -352,6 +403,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
operation: FileOperation.UPDATE,
|
||||
lines: 10,
|
||||
mimetype: 'text/plain',
|
||||
@@ -369,6 +422,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
operation: FileOperation.UPDATE,
|
||||
});
|
||||
});
|
||||
@@ -408,6 +463,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'routing.decision_model': 'gemini-pro',
|
||||
'routing.decision_source': 'default',
|
||||
});
|
||||
@@ -429,6 +486,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'routing.decision_model': 'gemini-pro',
|
||||
'routing.decision_source': 'classifier',
|
||||
});
|
||||
@@ -436,6 +495,8 @@ describe('Telemetry Metrics', () => {
|
||||
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
||||
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'routing.decision_source': 'classifier',
|
||||
'routing.error_message': 'test-error',
|
||||
});
|
||||
@@ -478,6 +539,8 @@ describe('Telemetry Metrics', () => {
|
||||
// Verify agent run counter
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
agent_name: 'TestAgent',
|
||||
terminate_reason: 'GOAL',
|
||||
});
|
||||
@@ -485,12 +548,16 @@ describe('Telemetry Metrics', () => {
|
||||
// Verify agent duration histogram
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1000, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
agent_name: 'TestAgent',
|
||||
});
|
||||
|
||||
// Verify agent turns histogram
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(5, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
agent_name: 'TestAgent',
|
||||
});
|
||||
});
|
||||
@@ -527,6 +594,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'gen_ai.operation.name': 'generate_content',
|
||||
'gen_ai.provider.name': 'gcp.gen_ai',
|
||||
'gen_ai.token.type': 'input',
|
||||
@@ -548,6 +617,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(75, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'gen_ai.operation.name': 'generate_content',
|
||||
'gen_ai.provider.name': 'gcp.vertex_ai',
|
||||
'gen_ai.token.type': 'output',
|
||||
@@ -570,6 +641,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'gen_ai.operation.name': 'generate_content',
|
||||
'gen_ai.provider.name': 'gcp.vertex_ai',
|
||||
'gen_ai.token.type': 'input',
|
||||
@@ -603,6 +676,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1.25, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'gen_ai.operation.name': 'generate_content',
|
||||
'gen_ai.provider.name': 'gcp.gen_ai',
|
||||
'gen_ai.request.model': 'gemini-2.0-flash',
|
||||
@@ -623,6 +698,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3.75, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'gen_ai.operation.name': 'generate_content',
|
||||
'gen_ai.provider.name': 'gcp.vertex_ai',
|
||||
'gen_ai.request.model': 'gemini-pro',
|
||||
@@ -645,6 +722,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.95, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'gen_ai.operation.name': 'generate_content',
|
||||
'gen_ai.provider.name': 'gcp.vertex_ai',
|
||||
'gen_ai.request.model': 'gemini-1.5-pro',
|
||||
@@ -665,6 +744,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(2.1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'gen_ai.operation.name': 'generate_content',
|
||||
'gen_ai.provider.name': 'gcp.gen_ai',
|
||||
});
|
||||
@@ -714,6 +795,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
phase: 'settings_loading',
|
||||
auth_type: 'gemini',
|
||||
telemetry_enabled: true,
|
||||
@@ -729,6 +812,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(50, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
phase: 'cleanup',
|
||||
});
|
||||
});
|
||||
@@ -751,6 +836,8 @@ describe('Telemetry Metrics', () => {
|
||||
floatingPointDuration,
|
||||
{
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
phase: 'total_startup',
|
||||
is_tty: true,
|
||||
has_question: false,
|
||||
@@ -771,6 +858,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
memory_type: 'heap_used',
|
||||
component: 'startup',
|
||||
});
|
||||
@@ -796,16 +885,22 @@ describe('Telemetry Metrics', () => {
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 31457280, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
memory_type: 'heap_total',
|
||||
component: 'api_call',
|
||||
});
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 2097152, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
memory_type: 'external',
|
||||
component: 'tool_execution',
|
||||
});
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 41943040, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
memory_type: 'rss',
|
||||
component: 'memory_monitor',
|
||||
});
|
||||
@@ -821,6 +916,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
memory_type: 'heap_used',
|
||||
});
|
||||
});
|
||||
@@ -837,6 +934,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
component: 'tool_execution',
|
||||
});
|
||||
});
|
||||
@@ -849,6 +948,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(42.3, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -862,6 +963,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -873,6 +976,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -889,6 +994,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(25, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
function_name: 'Read',
|
||||
phase: 'validation',
|
||||
});
|
||||
@@ -914,16 +1021,22 @@ describe('Telemetry Metrics', () => {
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 50, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
function_name: 'Bash',
|
||||
phase: 'preparation',
|
||||
});
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 1500, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
function_name: 'Bash',
|
||||
phase: 'execution',
|
||||
});
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 75, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
function_name: 'Bash',
|
||||
phase: 'result_processing',
|
||||
});
|
||||
@@ -943,6 +1056,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.85, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
metric: 'cache_hit_rate',
|
||||
context: 'api_request',
|
||||
@@ -960,6 +1075,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(125.5, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
metric: 'tokens_per_operation',
|
||||
});
|
||||
@@ -978,6 +1095,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
phase: 'request_preparation',
|
||||
});
|
||||
@@ -1003,16 +1122,22 @@ describe('Telemetry Metrics', () => {
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 250, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
phase: 'network_latency',
|
||||
});
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 100, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
phase: 'response_processing',
|
||||
});
|
||||
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 50, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
model: 'gemini-pro',
|
||||
phase: 'token_processing',
|
||||
});
|
||||
@@ -1031,6 +1156,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
category: 'memory_efficiency',
|
||||
baseline: 80.0,
|
||||
});
|
||||
@@ -1046,6 +1173,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(92.3, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
category: 'overall_performance',
|
||||
});
|
||||
});
|
||||
@@ -1067,6 +1196,8 @@ describe('Telemetry Metrics', () => {
|
||||
// Verify regression counter
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
metric: 'startup_time',
|
||||
severity: 'medium',
|
||||
current_value: 1200,
|
||||
@@ -1076,6 +1207,8 @@ describe('Telemetry Metrics', () => {
|
||||
// Verify baseline comparison histogram (20% increase)
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
metric: 'startup_time',
|
||||
severity: 'medium',
|
||||
current_value: 1200,
|
||||
@@ -1098,6 +1231,8 @@ describe('Telemetry Metrics', () => {
|
||||
// Verify regression counter still recorded
|
||||
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
metric: 'memory_usage',
|
||||
severity: 'high',
|
||||
current_value: 100,
|
||||
@@ -1127,6 +1262,8 @@ describe('Telemetry Metrics', () => {
|
||||
|
||||
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
metric: 'api_latency',
|
||||
severity: 'low',
|
||||
current_value: 500,
|
||||
@@ -1134,6 +1271,8 @@ describe('Telemetry Metrics', () => {
|
||||
});
|
||||
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
metric: 'cpu_usage',
|
||||
severity: 'high',
|
||||
current_value: 90,
|
||||
@@ -1157,6 +1296,8 @@ describe('Telemetry Metrics', () => {
|
||||
// 20% increase: (120 - 100) / 100 * 100 = 20%
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
metric: 'memory_usage',
|
||||
category: 'performance_tracking',
|
||||
current_value: 120,
|
||||
@@ -1178,6 +1319,8 @@ describe('Telemetry Metrics', () => {
|
||||
// 20% decrease: (800 - 1000) / 1000 * 100 = -20%
|
||||
expect(mockHistogramRecordFn).toHaveBeenCalledWith(-20, {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
metric: 'startup_time',
|
||||
category: 'optimization',
|
||||
current_value: 800,
|
||||
|
||||
Reference in New Issue
Block a user