@google/gemini-cli-core 0.10.0-nightly.20251009.cd354aeb → 0.10.0-nightly.20251013.cfb71b9d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/google-gemini-cli-core-0.10.0-nightly.20251007.c195a9aa.tgz +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/agents/executor.js +3 -4
- package/dist/src/agents/executor.js.map +1 -1
- package/dist/src/config/config.d.ts +9 -6
- package/dist/src/config/config.js +16 -11
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +24 -2
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/core/client.d.ts +1 -1
- package/dist/src/core/client.js +16 -3
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +85 -0
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/geminiChat.js +9 -1
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +40 -0
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +6 -2
- package/dist/src/core/turn.js +6 -0
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +13 -1
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/services/shellExecutionService.d.ts +1 -0
- package/dist/src/services/shellExecutionService.js +144 -69
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +61 -1
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +3 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +41 -4
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +2 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +5 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -34
- package/dist/src/telemetry/constants.js +0 -36
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -2
- package/dist/src/telemetry/index.js +2 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +3 -2
- package/dist/src/telemetry/loggers.js +93 -314
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +75 -3
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +15 -1
- package/dist/src/telemetry/metrics.js +20 -4
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +160 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +18 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +113 -2
- package/dist/src/telemetry/types.js +604 -33
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
- package/dist/src/telemetry/uiTelemetry.js +1 -1
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +0 -19
- package/dist/src/tools/smart-edit.js +11 -47
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +0 -59
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +21 -0
- package/dist/src/tools/tool-error.js +27 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +1 -0
- package/dist/src/tools/tool-names.js +1 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/web-search.js +2 -1
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -43,6 +43,7 @@ function originalOtelMockFactory() {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
vi.mock('@opentelemetry/api');
|
|
46
|
+
vi.mock('./telemetryAttributes.js');
|
|
46
47
|
describe('Telemetry Metrics', () => {
|
|
47
48
|
let initializeMetricsModule;
|
|
48
49
|
let recordTokenUsageMetricsModule;
|
|
@@ -61,6 +62,7 @@ describe('Telemetry Metrics', () => {
|
|
|
61
62
|
let recordBaselineComparisonModule;
|
|
62
63
|
let recordGenAiClientTokenUsageModule;
|
|
63
64
|
let recordGenAiClientOperationDurationModule;
|
|
65
|
+
let recordFlickerFrameModule;
|
|
64
66
|
let recordAgentRunMetricsModule;
|
|
65
67
|
beforeEach(async () => {
|
|
66
68
|
vi.resetModules();
|
|
@@ -69,6 +71,12 @@ describe('Telemetry Metrics', () => {
|
|
|
69
71
|
actualApi.metrics.getMeter.mockReturnValue(mockMeterInstance);
|
|
70
72
|
return actualApi;
|
|
71
73
|
});
|
|
74
|
+
const { getCommonAttributes } = await import('./telemetryAttributes.js');
|
|
75
|
+
getCommonAttributes.mockReturnValue({
|
|
76
|
+
'session.id': 'test-session-id',
|
|
77
|
+
'installation.id': 'test-installation-id',
|
|
78
|
+
'user.email': 'test@example.com',
|
|
79
|
+
});
|
|
72
80
|
const metricsJsModule = await import('./metrics.js');
|
|
73
81
|
initializeMetricsModule = metricsJsModule.initializeMetrics;
|
|
74
82
|
recordTokenUsageMetricsModule = metricsJsModule.recordTokenUsageMetrics;
|
|
@@ -92,6 +100,7 @@ describe('Telemetry Metrics', () => {
|
|
|
92
100
|
metricsJsModule.recordGenAiClientTokenUsage;
|
|
93
101
|
recordGenAiClientOperationDurationModule =
|
|
94
102
|
metricsJsModule.recordGenAiClientOperationDuration;
|
|
103
|
+
recordFlickerFrameModule = metricsJsModule.recordFlickerFrame;
|
|
95
104
|
recordAgentRunMetricsModule = metricsJsModule.recordAgentRunMetrics;
|
|
96
105
|
const otelApiModule = await import('@opentelemetry/api');
|
|
97
106
|
mockCounterAddFn.mockClear();
|
|
@@ -103,6 +112,39 @@ describe('Telemetry Metrics', () => {
|
|
|
103
112
|
mockCreateCounterFn.mockReturnValue(mockCounterInstance);
|
|
104
113
|
mockCreateHistogramFn.mockReturnValue(mockHistogramInstance);
|
|
105
114
|
});
|
|
115
|
+
describe('recordFlickerFrame', () => {
|
|
116
|
+
it('does not record metrics if not initialized', () => {
|
|
117
|
+
const config = makeFakeConfig({});
|
|
118
|
+
recordFlickerFrameModule(config);
|
|
119
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
it('records a flicker frame event when initialized', () => {
|
|
122
|
+
const config = makeFakeConfig({});
|
|
123
|
+
initializeMetricsModule(config);
|
|
124
|
+
recordFlickerFrameModule(config);
|
|
125
|
+
// Called for session, then for flicker
|
|
126
|
+
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
127
|
+
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
128
|
+
'session.id': 'test-session-id',
|
|
129
|
+
'installation.id': 'test-installation-id',
|
|
130
|
+
'user.email': 'test@example.com',
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
describe('initializeMetrics', () => {
|
|
135
|
+
const mockConfig = {
|
|
136
|
+
getSessionId: () => 'test-session-id',
|
|
137
|
+
getTelemetryEnabled: () => true,
|
|
138
|
+
};
|
|
139
|
+
it('should apply common attributes including email', () => {
|
|
140
|
+
initializeMetricsModule(mockConfig);
|
|
141
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
142
|
+
'session.id': 'test-session-id',
|
|
143
|
+
'installation.id': 'test-installation-id',
|
|
144
|
+
'user.email': 'test@example.com',
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
106
148
|
describe('recordChatCompressionMetrics', () => {
|
|
107
149
|
it('does not record metrics if not initialized', () => {
|
|
108
150
|
const lol = makeFakeConfig({});
|
|
@@ -121,6 +163,8 @@ describe('Telemetry Metrics', () => {
|
|
|
121
163
|
});
|
|
122
164
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
123
165
|
'session.id': 'test-session-id',
|
|
166
|
+
'installation.id': 'test-installation-id',
|
|
167
|
+
'user.email': 'test@example.com',
|
|
124
168
|
tokens_after: 100,
|
|
125
169
|
tokens_before: 200,
|
|
126
170
|
});
|
|
@@ -147,9 +191,13 @@ describe('Telemetry Metrics', () => {
|
|
|
147
191
|
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
148
192
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
149
193
|
'session.id': 'test-session-id',
|
|
194
|
+
'installation.id': 'test-installation-id',
|
|
195
|
+
'user.email': 'test@example.com',
|
|
150
196
|
});
|
|
151
197
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 100, {
|
|
152
198
|
'session.id': 'test-session-id',
|
|
199
|
+
'installation.id': 'test-installation-id',
|
|
200
|
+
'user.email': 'test@example.com',
|
|
153
201
|
model: 'gemini-pro',
|
|
154
202
|
type: 'input',
|
|
155
203
|
});
|
|
@@ -163,6 +211,8 @@ describe('Telemetry Metrics', () => {
|
|
|
163
211
|
});
|
|
164
212
|
expect(mockCounterAddFn).toHaveBeenCalledWith(50, {
|
|
165
213
|
'session.id': 'test-session-id',
|
|
214
|
+
'installation.id': 'test-installation-id',
|
|
215
|
+
'user.email': 'test@example.com',
|
|
166
216
|
model: 'gemini-pro',
|
|
167
217
|
type: 'output',
|
|
168
218
|
});
|
|
@@ -172,6 +222,8 @@ describe('Telemetry Metrics', () => {
|
|
|
172
222
|
});
|
|
173
223
|
expect(mockCounterAddFn).toHaveBeenCalledWith(25, {
|
|
174
224
|
'session.id': 'test-session-id',
|
|
225
|
+
'installation.id': 'test-installation-id',
|
|
226
|
+
'user.email': 'test@example.com',
|
|
175
227
|
model: 'gemini-pro',
|
|
176
228
|
type: 'thought',
|
|
177
229
|
});
|
|
@@ -181,6 +233,8 @@ describe('Telemetry Metrics', () => {
|
|
|
181
233
|
});
|
|
182
234
|
expect(mockCounterAddFn).toHaveBeenCalledWith(75, {
|
|
183
235
|
'session.id': 'test-session-id',
|
|
236
|
+
'installation.id': 'test-installation-id',
|
|
237
|
+
'user.email': 'test@example.com',
|
|
184
238
|
model: 'gemini-pro',
|
|
185
239
|
type: 'cache',
|
|
186
240
|
});
|
|
@@ -190,6 +244,8 @@ describe('Telemetry Metrics', () => {
|
|
|
190
244
|
});
|
|
191
245
|
expect(mockCounterAddFn).toHaveBeenCalledWith(125, {
|
|
192
246
|
'session.id': 'test-session-id',
|
|
247
|
+
'installation.id': 'test-installation-id',
|
|
248
|
+
'user.email': 'test@example.com',
|
|
193
249
|
model: 'gemini-pro',
|
|
194
250
|
type: 'tool',
|
|
195
251
|
});
|
|
@@ -203,6 +259,8 @@ describe('Telemetry Metrics', () => {
|
|
|
203
259
|
});
|
|
204
260
|
expect(mockCounterAddFn).toHaveBeenCalledWith(200, {
|
|
205
261
|
'session.id': 'test-session-id',
|
|
262
|
+
'installation.id': 'test-installation-id',
|
|
263
|
+
'user.email': 'test@example.com',
|
|
206
264
|
model: 'gemini-ultra',
|
|
207
265
|
type: 'input',
|
|
208
266
|
});
|
|
@@ -233,9 +291,13 @@ describe('Telemetry Metrics', () => {
|
|
|
233
291
|
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
234
292
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
235
293
|
'session.id': 'test-session-id',
|
|
294
|
+
'installation.id': 'test-installation-id',
|
|
295
|
+
'user.email': 'test@example.com',
|
|
236
296
|
});
|
|
237
297
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
238
298
|
'session.id': 'test-session-id',
|
|
299
|
+
'installation.id': 'test-installation-id',
|
|
300
|
+
'user.email': 'test@example.com',
|
|
239
301
|
operation: FileOperation.CREATE,
|
|
240
302
|
lines: 10,
|
|
241
303
|
mimetype: 'text/plain',
|
|
@@ -250,6 +312,8 @@ describe('Telemetry Metrics', () => {
|
|
|
250
312
|
});
|
|
251
313
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
252
314
|
'session.id': 'test-session-id',
|
|
315
|
+
'installation.id': 'test-installation-id',
|
|
316
|
+
'user.email': 'test@example.com',
|
|
253
317
|
operation: FileOperation.READ,
|
|
254
318
|
});
|
|
255
319
|
});
|
|
@@ -262,6 +326,8 @@ describe('Telemetry Metrics', () => {
|
|
|
262
326
|
});
|
|
263
327
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
264
328
|
'session.id': 'test-session-id',
|
|
329
|
+
'installation.id': 'test-installation-id',
|
|
330
|
+
'user.email': 'test@example.com',
|
|
265
331
|
operation: FileOperation.UPDATE,
|
|
266
332
|
mimetype: 'application/javascript',
|
|
267
333
|
});
|
|
@@ -274,6 +340,8 @@ describe('Telemetry Metrics', () => {
|
|
|
274
340
|
});
|
|
275
341
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
276
342
|
'session.id': 'test-session-id',
|
|
343
|
+
'installation.id': 'test-installation-id',
|
|
344
|
+
'user.email': 'test@example.com',
|
|
277
345
|
operation: FileOperation.UPDATE,
|
|
278
346
|
});
|
|
279
347
|
});
|
|
@@ -288,6 +356,8 @@ describe('Telemetry Metrics', () => {
|
|
|
288
356
|
});
|
|
289
357
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
290
358
|
'session.id': 'test-session-id',
|
|
359
|
+
'installation.id': 'test-installation-id',
|
|
360
|
+
'user.email': 'test@example.com',
|
|
291
361
|
operation: FileOperation.UPDATE,
|
|
292
362
|
lines: 10,
|
|
293
363
|
mimetype: 'text/plain',
|
|
@@ -302,6 +372,8 @@ describe('Telemetry Metrics', () => {
|
|
|
302
372
|
});
|
|
303
373
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
304
374
|
'session.id': 'test-session-id',
|
|
375
|
+
'installation.id': 'test-installation-id',
|
|
376
|
+
'user.email': 'test@example.com',
|
|
305
377
|
operation: FileOperation.UPDATE,
|
|
306
378
|
});
|
|
307
379
|
});
|
|
@@ -323,6 +395,8 @@ describe('Telemetry Metrics', () => {
|
|
|
323
395
|
recordModelRoutingMetricsModule(mockConfig, event);
|
|
324
396
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
325
397
|
'session.id': 'test-session-id',
|
|
398
|
+
'installation.id': 'test-installation-id',
|
|
399
|
+
'user.email': 'test@example.com',
|
|
326
400
|
'routing.decision_model': 'gemini-pro',
|
|
327
401
|
'routing.decision_source': 'default',
|
|
328
402
|
});
|
|
@@ -335,12 +409,16 @@ describe('Telemetry Metrics', () => {
|
|
|
335
409
|
recordModelRoutingMetricsModule(mockConfig, event);
|
|
336
410
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
|
337
411
|
'session.id': 'test-session-id',
|
|
412
|
+
'installation.id': 'test-installation-id',
|
|
413
|
+
'user.email': 'test@example.com',
|
|
338
414
|
'routing.decision_model': 'gemini-pro',
|
|
339
415
|
'routing.decision_source': 'classifier',
|
|
340
416
|
});
|
|
341
417
|
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
342
418
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
343
419
|
'session.id': 'test-session-id',
|
|
420
|
+
'installation.id': 'test-installation-id',
|
|
421
|
+
'user.email': 'test@example.com',
|
|
344
422
|
'routing.decision_source': 'classifier',
|
|
345
423
|
'routing.error_message': 'test-error',
|
|
346
424
|
});
|
|
@@ -366,17 +444,23 @@ describe('Telemetry Metrics', () => {
|
|
|
366
444
|
// Verify agent run counter
|
|
367
445
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
368
446
|
'session.id': 'test-session-id',
|
|
447
|
+
'installation.id': 'test-installation-id',
|
|
448
|
+
'user.email': 'test@example.com',
|
|
369
449
|
agent_name: 'TestAgent',
|
|
370
450
|
terminate_reason: 'GOAL',
|
|
371
451
|
});
|
|
372
452
|
// Verify agent duration histogram
|
|
373
453
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1000, {
|
|
374
454
|
'session.id': 'test-session-id',
|
|
455
|
+
'installation.id': 'test-installation-id',
|
|
456
|
+
'user.email': 'test@example.com',
|
|
375
457
|
agent_name: 'TestAgent',
|
|
376
458
|
});
|
|
377
459
|
// Verify agent turns histogram
|
|
378
460
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(5, {
|
|
379
461
|
'session.id': 'test-session-id',
|
|
462
|
+
'installation.id': 'test-installation-id',
|
|
463
|
+
'user.email': 'test@example.com',
|
|
380
464
|
agent_name: 'TestAgent',
|
|
381
465
|
});
|
|
382
466
|
});
|
|
@@ -407,6 +491,8 @@ describe('Telemetry Metrics', () => {
|
|
|
407
491
|
});
|
|
408
492
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
409
493
|
'session.id': 'test-session-id',
|
|
494
|
+
'installation.id': 'test-installation-id',
|
|
495
|
+
'user.email': 'test@example.com',
|
|
410
496
|
'gen_ai.operation.name': 'generate_content',
|
|
411
497
|
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
412
498
|
'gen_ai.token.type': 'input',
|
|
@@ -425,6 +511,8 @@ describe('Telemetry Metrics', () => {
|
|
|
425
511
|
});
|
|
426
512
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(75, {
|
|
427
513
|
'session.id': 'test-session-id',
|
|
514
|
+
'installation.id': 'test-installation-id',
|
|
515
|
+
'user.email': 'test@example.com',
|
|
428
516
|
'gen_ai.operation.name': 'generate_content',
|
|
429
517
|
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
430
518
|
'gen_ai.token.type': 'output',
|
|
@@ -444,6 +532,8 @@ describe('Telemetry Metrics', () => {
|
|
|
444
532
|
});
|
|
445
533
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
|
446
534
|
'session.id': 'test-session-id',
|
|
535
|
+
'installation.id': 'test-installation-id',
|
|
536
|
+
'user.email': 'test@example.com',
|
|
447
537
|
'gen_ai.operation.name': 'generate_content',
|
|
448
538
|
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
449
539
|
'gen_ai.token.type': 'input',
|
|
@@ -472,6 +562,8 @@ describe('Telemetry Metrics', () => {
|
|
|
472
562
|
});
|
|
473
563
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1.25, {
|
|
474
564
|
'session.id': 'test-session-id',
|
|
565
|
+
'installation.id': 'test-installation-id',
|
|
566
|
+
'user.email': 'test@example.com',
|
|
475
567
|
'gen_ai.operation.name': 'generate_content',
|
|
476
568
|
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
477
569
|
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
@@ -489,6 +581,8 @@ describe('Telemetry Metrics', () => {
|
|
|
489
581
|
});
|
|
490
582
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3.75, {
|
|
491
583
|
'session.id': 'test-session-id',
|
|
584
|
+
'installation.id': 'test-installation-id',
|
|
585
|
+
'user.email': 'test@example.com',
|
|
492
586
|
'gen_ai.operation.name': 'generate_content',
|
|
493
587
|
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
494
588
|
'gen_ai.request.model': 'gemini-pro',
|
|
@@ -508,6 +602,8 @@ describe('Telemetry Metrics', () => {
|
|
|
508
602
|
});
|
|
509
603
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.95, {
|
|
510
604
|
'session.id': 'test-session-id',
|
|
605
|
+
'installation.id': 'test-installation-id',
|
|
606
|
+
'user.email': 'test@example.com',
|
|
511
607
|
'gen_ai.operation.name': 'generate_content',
|
|
512
608
|
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
513
609
|
'gen_ai.request.model': 'gemini-1.5-pro',
|
|
@@ -525,6 +621,8 @@ describe('Telemetry Metrics', () => {
|
|
|
525
621
|
});
|
|
526
622
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(2.1, {
|
|
527
623
|
'session.id': 'test-session-id',
|
|
624
|
+
'installation.id': 'test-installation-id',
|
|
625
|
+
'user.email': 'test@example.com',
|
|
528
626
|
'gen_ai.operation.name': 'generate_content',
|
|
529
627
|
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
530
628
|
});
|
|
@@ -566,6 +664,8 @@ describe('Telemetry Metrics', () => {
|
|
|
566
664
|
});
|
|
567
665
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
568
666
|
'session.id': 'test-session-id',
|
|
667
|
+
'installation.id': 'test-installation-id',
|
|
668
|
+
'user.email': 'test@example.com',
|
|
569
669
|
phase: 'settings_loading',
|
|
570
670
|
auth_type: 'gemini',
|
|
571
671
|
telemetry_enabled: true,
|
|
@@ -578,6 +678,8 @@ describe('Telemetry Metrics', () => {
|
|
|
578
678
|
recordStartupPerformanceModule(mockConfig, 50, { phase: 'cleanup' });
|
|
579
679
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(50, {
|
|
580
680
|
'session.id': 'test-session-id',
|
|
681
|
+
'installation.id': 'test-installation-id',
|
|
682
|
+
'user.email': 'test@example.com',
|
|
581
683
|
phase: 'cleanup',
|
|
582
684
|
});
|
|
583
685
|
});
|
|
@@ -595,6 +697,8 @@ describe('Telemetry Metrics', () => {
|
|
|
595
697
|
});
|
|
596
698
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(floatingPointDuration, {
|
|
597
699
|
'session.id': 'test-session-id',
|
|
700
|
+
'installation.id': 'test-installation-id',
|
|
701
|
+
'user.email': 'test@example.com',
|
|
598
702
|
phase: 'total_startup',
|
|
599
703
|
is_tty: true,
|
|
600
704
|
has_question: false,
|
|
@@ -611,6 +715,8 @@ describe('Telemetry Metrics', () => {
|
|
|
611
715
|
});
|
|
612
716
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
|
|
613
717
|
'session.id': 'test-session-id',
|
|
718
|
+
'installation.id': 'test-installation-id',
|
|
719
|
+
'user.email': 'test@example.com',
|
|
614
720
|
memory_type: 'heap_used',
|
|
615
721
|
component: 'startup',
|
|
616
722
|
});
|
|
@@ -633,16 +739,22 @@ describe('Telemetry Metrics', () => {
|
|
|
633
739
|
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
634
740
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 31457280, {
|
|
635
741
|
'session.id': 'test-session-id',
|
|
742
|
+
'installation.id': 'test-installation-id',
|
|
743
|
+
'user.email': 'test@example.com',
|
|
636
744
|
memory_type: 'heap_total',
|
|
637
745
|
component: 'api_call',
|
|
638
746
|
});
|
|
639
747
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 2097152, {
|
|
640
748
|
'session.id': 'test-session-id',
|
|
749
|
+
'installation.id': 'test-installation-id',
|
|
750
|
+
'user.email': 'test@example.com',
|
|
641
751
|
memory_type: 'external',
|
|
642
752
|
component: 'tool_execution',
|
|
643
753
|
});
|
|
644
754
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 41943040, {
|
|
645
755
|
'session.id': 'test-session-id',
|
|
756
|
+
'installation.id': 'test-installation-id',
|
|
757
|
+
'user.email': 'test@example.com',
|
|
646
758
|
memory_type: 'rss',
|
|
647
759
|
component: 'memory_monitor',
|
|
648
760
|
});
|
|
@@ -655,6 +767,8 @@ describe('Telemetry Metrics', () => {
|
|
|
655
767
|
});
|
|
656
768
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
|
|
657
769
|
'session.id': 'test-session-id',
|
|
770
|
+
'installation.id': 'test-installation-id',
|
|
771
|
+
'user.email': 'test@example.com',
|
|
658
772
|
memory_type: 'heap_used',
|
|
659
773
|
});
|
|
660
774
|
});
|
|
@@ -668,6 +782,8 @@ describe('Telemetry Metrics', () => {
|
|
|
668
782
|
});
|
|
669
783
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
|
670
784
|
'session.id': 'test-session-id',
|
|
785
|
+
'installation.id': 'test-installation-id',
|
|
786
|
+
'user.email': 'test@example.com',
|
|
671
787
|
component: 'tool_execution',
|
|
672
788
|
});
|
|
673
789
|
});
|
|
@@ -677,6 +793,8 @@ describe('Telemetry Metrics', () => {
|
|
|
677
793
|
recordCpuUsageModule(mockConfig, 42.3, {});
|
|
678
794
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(42.3, {
|
|
679
795
|
'session.id': 'test-session-id',
|
|
796
|
+
'installation.id': 'test-installation-id',
|
|
797
|
+
'user.email': 'test@example.com',
|
|
680
798
|
});
|
|
681
799
|
});
|
|
682
800
|
});
|
|
@@ -687,6 +805,8 @@ describe('Telemetry Metrics', () => {
|
|
|
687
805
|
recordToolQueueDepthModule(mockConfig, 3);
|
|
688
806
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3, {
|
|
689
807
|
'session.id': 'test-session-id',
|
|
808
|
+
'installation.id': 'test-installation-id',
|
|
809
|
+
'user.email': 'test@example.com',
|
|
690
810
|
});
|
|
691
811
|
});
|
|
692
812
|
it('should record zero queue depth', () => {
|
|
@@ -695,6 +815,8 @@ describe('Telemetry Metrics', () => {
|
|
|
695
815
|
recordToolQueueDepthModule(mockConfig, 0);
|
|
696
816
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0, {
|
|
697
817
|
'session.id': 'test-session-id',
|
|
818
|
+
'installation.id': 'test-installation-id',
|
|
819
|
+
'user.email': 'test@example.com',
|
|
698
820
|
});
|
|
699
821
|
});
|
|
700
822
|
});
|
|
@@ -708,6 +830,8 @@ describe('Telemetry Metrics', () => {
|
|
|
708
830
|
});
|
|
709
831
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(25, {
|
|
710
832
|
'session.id': 'test-session-id',
|
|
833
|
+
'installation.id': 'test-installation-id',
|
|
834
|
+
'user.email': 'test@example.com',
|
|
711
835
|
function_name: 'Read',
|
|
712
836
|
phase: 'validation',
|
|
713
837
|
});
|
|
@@ -730,16 +854,22 @@ describe('Telemetry Metrics', () => {
|
|
|
730
854
|
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
731
855
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 50, {
|
|
732
856
|
'session.id': 'test-session-id',
|
|
857
|
+
'installation.id': 'test-installation-id',
|
|
858
|
+
'user.email': 'test@example.com',
|
|
733
859
|
function_name: 'Bash',
|
|
734
860
|
phase: 'preparation',
|
|
735
861
|
});
|
|
736
862
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 1500, {
|
|
737
863
|
'session.id': 'test-session-id',
|
|
864
|
+
'installation.id': 'test-installation-id',
|
|
865
|
+
'user.email': 'test@example.com',
|
|
738
866
|
function_name: 'Bash',
|
|
739
867
|
phase: 'execution',
|
|
740
868
|
});
|
|
741
869
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 75, {
|
|
742
870
|
'session.id': 'test-session-id',
|
|
871
|
+
'installation.id': 'test-installation-id',
|
|
872
|
+
'user.email': 'test@example.com',
|
|
743
873
|
function_name: 'Bash',
|
|
744
874
|
phase: 'result_processing',
|
|
745
875
|
});
|
|
@@ -756,6 +886,8 @@ describe('Telemetry Metrics', () => {
|
|
|
756
886
|
});
|
|
757
887
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.85, {
|
|
758
888
|
'session.id': 'test-session-id',
|
|
889
|
+
'installation.id': 'test-installation-id',
|
|
890
|
+
'user.email': 'test@example.com',
|
|
759
891
|
model: 'gemini-pro',
|
|
760
892
|
metric: 'cache_hit_rate',
|
|
761
893
|
context: 'api_request',
|
|
@@ -770,6 +902,8 @@ describe('Telemetry Metrics', () => {
|
|
|
770
902
|
});
|
|
771
903
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(125.5, {
|
|
772
904
|
'session.id': 'test-session-id',
|
|
905
|
+
'installation.id': 'test-installation-id',
|
|
906
|
+
'user.email': 'test@example.com',
|
|
773
907
|
model: 'gemini-pro',
|
|
774
908
|
metric: 'tokens_per_operation',
|
|
775
909
|
});
|
|
@@ -785,6 +919,8 @@ describe('Telemetry Metrics', () => {
|
|
|
785
919
|
});
|
|
786
920
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15, {
|
|
787
921
|
'session.id': 'test-session-id',
|
|
922
|
+
'installation.id': 'test-installation-id',
|
|
923
|
+
'user.email': 'test@example.com',
|
|
788
924
|
model: 'gemini-pro',
|
|
789
925
|
phase: 'request_preparation',
|
|
790
926
|
});
|
|
@@ -807,16 +943,22 @@ describe('Telemetry Metrics', () => {
|
|
|
807
943
|
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
808
944
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 250, {
|
|
809
945
|
'session.id': 'test-session-id',
|
|
946
|
+
'installation.id': 'test-installation-id',
|
|
947
|
+
'user.email': 'test@example.com',
|
|
810
948
|
model: 'gemini-pro',
|
|
811
949
|
phase: 'network_latency',
|
|
812
950
|
});
|
|
813
951
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 100, {
|
|
814
952
|
'session.id': 'test-session-id',
|
|
953
|
+
'installation.id': 'test-installation-id',
|
|
954
|
+
'user.email': 'test@example.com',
|
|
815
955
|
model: 'gemini-pro',
|
|
816
956
|
phase: 'response_processing',
|
|
817
957
|
});
|
|
818
958
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 50, {
|
|
819
959
|
'session.id': 'test-session-id',
|
|
960
|
+
'installation.id': 'test-installation-id',
|
|
961
|
+
'user.email': 'test@example.com',
|
|
820
962
|
model: 'gemini-pro',
|
|
821
963
|
phase: 'token_processing',
|
|
822
964
|
});
|
|
@@ -832,6 +974,8 @@ describe('Telemetry Metrics', () => {
|
|
|
832
974
|
});
|
|
833
975
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
|
834
976
|
'session.id': 'test-session-id',
|
|
977
|
+
'installation.id': 'test-installation-id',
|
|
978
|
+
'user.email': 'test@example.com',
|
|
835
979
|
category: 'memory_efficiency',
|
|
836
980
|
baseline: 80.0,
|
|
837
981
|
});
|
|
@@ -844,6 +988,8 @@ describe('Telemetry Metrics', () => {
|
|
|
844
988
|
});
|
|
845
989
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(92.3, {
|
|
846
990
|
'session.id': 'test-session-id',
|
|
991
|
+
'installation.id': 'test-installation-id',
|
|
992
|
+
'user.email': 'test@example.com',
|
|
847
993
|
category: 'overall_performance',
|
|
848
994
|
});
|
|
849
995
|
});
|
|
@@ -862,6 +1008,8 @@ describe('Telemetry Metrics', () => {
|
|
|
862
1008
|
// Verify regression counter
|
|
863
1009
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
864
1010
|
'session.id': 'test-session-id',
|
|
1011
|
+
'installation.id': 'test-installation-id',
|
|
1012
|
+
'user.email': 'test@example.com',
|
|
865
1013
|
metric: 'startup_time',
|
|
866
1014
|
severity: 'medium',
|
|
867
1015
|
current_value: 1200,
|
|
@@ -870,6 +1018,8 @@ describe('Telemetry Metrics', () => {
|
|
|
870
1018
|
// Verify baseline comparison histogram (20% increase)
|
|
871
1019
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
|
872
1020
|
'session.id': 'test-session-id',
|
|
1021
|
+
'installation.id': 'test-installation-id',
|
|
1022
|
+
'user.email': 'test@example.com',
|
|
873
1023
|
metric: 'startup_time',
|
|
874
1024
|
severity: 'medium',
|
|
875
1025
|
current_value: 1200,
|
|
@@ -889,6 +1039,8 @@ describe('Telemetry Metrics', () => {
|
|
|
889
1039
|
// Verify regression counter still recorded
|
|
890
1040
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
891
1041
|
'session.id': 'test-session-id',
|
|
1042
|
+
'installation.id': 'test-installation-id',
|
|
1043
|
+
'user.email': 'test@example.com',
|
|
892
1044
|
metric: 'memory_usage',
|
|
893
1045
|
severity: 'high',
|
|
894
1046
|
current_value: 100,
|
|
@@ -914,6 +1066,8 @@ describe('Telemetry Metrics', () => {
|
|
|
914
1066
|
});
|
|
915
1067
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
916
1068
|
'session.id': 'test-session-id',
|
|
1069
|
+
'installation.id': 'test-installation-id',
|
|
1070
|
+
'user.email': 'test@example.com',
|
|
917
1071
|
metric: 'api_latency',
|
|
918
1072
|
severity: 'low',
|
|
919
1073
|
current_value: 500,
|
|
@@ -921,6 +1075,8 @@ describe('Telemetry Metrics', () => {
|
|
|
921
1075
|
});
|
|
922
1076
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
923
1077
|
'session.id': 'test-session-id',
|
|
1078
|
+
'installation.id': 'test-installation-id',
|
|
1079
|
+
'user.email': 'test@example.com',
|
|
924
1080
|
metric: 'cpu_usage',
|
|
925
1081
|
severity: 'high',
|
|
926
1082
|
current_value: 90,
|
|
@@ -941,6 +1097,8 @@ describe('Telemetry Metrics', () => {
|
|
|
941
1097
|
// 20% increase: (120 - 100) / 100 * 100 = 20%
|
|
942
1098
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
|
943
1099
|
'session.id': 'test-session-id',
|
|
1100
|
+
'installation.id': 'test-installation-id',
|
|
1101
|
+
'user.email': 'test@example.com',
|
|
944
1102
|
metric: 'memory_usage',
|
|
945
1103
|
category: 'performance_tracking',
|
|
946
1104
|
current_value: 120,
|
|
@@ -959,6 +1117,8 @@ describe('Telemetry Metrics', () => {
|
|
|
959
1117
|
// 20% decrease: (800 - 1000) / 1000 * 100 = -20%
|
|
960
1118
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(-20, {
|
|
961
1119
|
'session.id': 'test-session-id',
|
|
1120
|
+
'installation.id': 'test-installation-id',
|
|
1121
|
+
'user.email': 'test@example.com',
|
|
962
1122
|
metric: 'startup_time',
|
|
963
1123
|
category: 'optimization',
|
|
964
1124
|
current_value: 800,
|