@machina.ai/cell-cli-core 1.8.2-rc1 → 1.10.0-rc1
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +36 -1
- package/dist/src/agents/codebase-investigator.js +93 -31
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/executor.d.ts +15 -11
- package/dist/src/agents/executor.js +265 -103
- package/dist/src/agents/executor.js.map +1 -1
- package/dist/src/agents/executor.test.js +493 -232
- package/dist/src/agents/executor.test.js.map +1 -1
- package/dist/src/agents/invocation.d.ts +5 -2
- package/dist/src/agents/invocation.js +4 -2
- package/dist/src/agents/invocation.js.map +1 -1
- package/dist/src/agents/invocation.test.js +9 -0
- package/dist/src/agents/invocation.test.js.map +1 -1
- package/dist/src/agents/registry.d.ts +2 -1
- package/dist/src/agents/registry.js +24 -1
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.d.ts +3 -1
- package/dist/src/agents/subagent-tool-wrapper.js +4 -3
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +8 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/types.d.ts +35 -6
- package/dist/src/agents/types.js +1 -0
- package/dist/src/agents/types.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.js +1 -1
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.test.js +1 -1
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +14 -13
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +4 -2
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/config/config.d.ts +48 -9
- package/dist/src/config/config.js +91 -16
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +67 -3
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +0 -1
- package/dist/src/config/storage.js +2 -2
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +7 -6
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/core/client.d.ts +3 -1
- package/dist/src/core/client.js +67 -17
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +199 -5
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.js +3 -1
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +12 -12
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +227 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +7 -11
- package/dist/src/core/geminiChat.js +32 -70
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +93 -228
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/logger.test.js +2 -2
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -2
- package/dist/src/core/nonInteractiveToolExecutor.js +2 -2
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +8 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +2 -1
- package/dist/src/core/prompts.js +51 -110
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +83 -29
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/subagent.js +1 -1
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +38 -12
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +14 -2
- package/dist/src/core/turn.js +12 -1
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +14 -2
- 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/generated/git-commit.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +11 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +3 -3
- package/dist/src/ide/ide-client.test.js +4 -4
- package/dist/src/ide/ide-installer.js +1 -1
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +13 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/process-utils.js +85 -75
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.js +83 -90
- package/dist/src/ide/process-utils.test.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.js +2 -1
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.test.js +4 -3
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +2 -1
- package/dist/src/services/chatRecordingService.js +2 -1
- package/dist/src/services/chatRecordingService.js.map +1 -1
- 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 +14 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +104 -8
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +81 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +13 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +32 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -28
- package/dist/src/telemetry/constants.js +0 -29
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +5 -3
- package/dist/src/telemetry/index.js +11 -4
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +8 -2
- package/dist/src/telemetry/loggers.js +165 -299
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +195 -7
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +131 -4
- package/dist/src/telemetry/metrics.js +182 -6
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +360 -1
- 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 +150 -3
- package/dist/src/telemetry/types.js +664 -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/glob.js +2 -1
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +3 -2
- package/dist/src/tools/mcp-client.js +29 -33
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +168 -5
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +1 -1
- package/dist/src/tools/memoryTool.js +1 -2
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +9 -8
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/shell.js +55 -2
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +2 -1
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +1 -20
- package/dist/src/tools/smart-edit.js +57 -55
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +70 -86
- 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 +9 -0
- package/dist/src/tools/tool-names.js +18 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +7 -0
- package/dist/src/tools/web-fetch.js +42 -10
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +127 -8
- package/dist/src/tools/web-fetch.test.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/tools/write-file.js +2 -1
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +1 -1
- package/dist/src/tools/write-todos.js +4 -3
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/utils/editCorrector.js +2 -2
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editor.js +1 -0
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +1 -0
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.test.js +7 -6
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/installationManager.test.js +2 -1
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +3 -3
- package/dist/src/utils/memoryDiscovery.d.ts +1 -0
- package/dist/src/utils/memoryDiscovery.js +2 -1
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +99 -21
- package/dist/src/utils/memoryDiscovery.test.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/src/utils/retry.d.ts +2 -1
- package/dist/src/utils/retry.js +22 -14
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +83 -39
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +1 -0
- package/dist/src/utils/shell-utils.js +1 -1
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.js +2 -2
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +8 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +2 -1
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
7
7
|
import { FileOperation, MemoryMetricType, ToolExecutionPhase, ApiRequestPhase, } from './metrics.js';
|
|
8
8
|
import { makeFakeConfig } from '../test-utils/config.js';
|
|
9
|
-
import { ModelRoutingEvent } from './types.js';
|
|
9
|
+
import { ModelRoutingEvent, AgentFinishEvent } from './types.js';
|
|
10
|
+
import { AgentTerminateMode } from '../agents/types.js';
|
|
10
11
|
const mockCounterAddFn = vi.fn();
|
|
11
12
|
const mockHistogramRecordFn = vi.fn();
|
|
12
13
|
const mockCreateCounterFn = vi.fn();
|
|
@@ -34,9 +35,15 @@ function originalOtelMockFactory() {
|
|
|
34
35
|
setLogger: vi.fn(),
|
|
35
36
|
warn: vi.fn(),
|
|
36
37
|
},
|
|
38
|
+
DiagConsoleLogger: vi.fn(),
|
|
39
|
+
DiagLogLevel: {
|
|
40
|
+
NONE: 0,
|
|
41
|
+
INFO: 1,
|
|
42
|
+
},
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
45
|
vi.mock('@opentelemetry/api');
|
|
46
|
+
vi.mock('./telemetryAttributes.js');
|
|
40
47
|
describe('Telemetry Metrics', () => {
|
|
41
48
|
let initializeMetricsModule;
|
|
42
49
|
let recordTokenUsageMetricsModule;
|
|
@@ -53,6 +60,10 @@ describe('Telemetry Metrics', () => {
|
|
|
53
60
|
let recordPerformanceScoreModule;
|
|
54
61
|
let recordPerformanceRegressionModule;
|
|
55
62
|
let recordBaselineComparisonModule;
|
|
63
|
+
let recordGenAiClientTokenUsageModule;
|
|
64
|
+
let recordGenAiClientOperationDurationModule;
|
|
65
|
+
let recordFlickerFrameModule;
|
|
66
|
+
let recordAgentRunMetricsModule;
|
|
56
67
|
beforeEach(async () => {
|
|
57
68
|
vi.resetModules();
|
|
58
69
|
vi.doMock('@opentelemetry/api', () => {
|
|
@@ -60,6 +71,12 @@ describe('Telemetry Metrics', () => {
|
|
|
60
71
|
actualApi.metrics.getMeter.mockReturnValue(mockMeterInstance);
|
|
61
72
|
return actualApi;
|
|
62
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
|
+
});
|
|
63
80
|
const metricsJsModule = await import('./metrics.js');
|
|
64
81
|
initializeMetricsModule = metricsJsModule.initializeMetrics;
|
|
65
82
|
recordTokenUsageMetricsModule = metricsJsModule.recordTokenUsageMetrics;
|
|
@@ -79,6 +96,12 @@ describe('Telemetry Metrics', () => {
|
|
|
79
96
|
recordPerformanceRegressionModule =
|
|
80
97
|
metricsJsModule.recordPerformanceRegression;
|
|
81
98
|
recordBaselineComparisonModule = metricsJsModule.recordBaselineComparison;
|
|
99
|
+
recordGenAiClientTokenUsageModule =
|
|
100
|
+
metricsJsModule.recordGenAiClientTokenUsage;
|
|
101
|
+
recordGenAiClientOperationDurationModule =
|
|
102
|
+
metricsJsModule.recordGenAiClientOperationDuration;
|
|
103
|
+
recordFlickerFrameModule = metricsJsModule.recordFlickerFrame;
|
|
104
|
+
recordAgentRunMetricsModule = metricsJsModule.recordAgentRunMetrics;
|
|
82
105
|
const otelApiModule = await import('@opentelemetry/api');
|
|
83
106
|
mockCounterAddFn.mockClear();
|
|
84
107
|
mockCreateCounterFn.mockClear();
|
|
@@ -89,6 +112,39 @@ describe('Telemetry Metrics', () => {
|
|
|
89
112
|
mockCreateCounterFn.mockReturnValue(mockCounterInstance);
|
|
90
113
|
mockCreateHistogramFn.mockReturnValue(mockHistogramInstance);
|
|
91
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
|
+
});
|
|
92
148
|
describe('recordChatCompressionMetrics', () => {
|
|
93
149
|
it('does not record metrics if not initialized', () => {
|
|
94
150
|
const lol = makeFakeConfig({});
|
|
@@ -107,6 +163,8 @@ describe('Telemetry Metrics', () => {
|
|
|
107
163
|
});
|
|
108
164
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
109
165
|
'session.id': 'test-session-id',
|
|
166
|
+
'installation.id': 'test-installation-id',
|
|
167
|
+
'user.email': 'test@example.com',
|
|
110
168
|
tokens_after: 100,
|
|
111
169
|
tokens_before: 200,
|
|
112
170
|
});
|
|
@@ -133,9 +191,13 @@ describe('Telemetry Metrics', () => {
|
|
|
133
191
|
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
134
192
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
135
193
|
'session.id': 'test-session-id',
|
|
194
|
+
'installation.id': 'test-installation-id',
|
|
195
|
+
'user.email': 'test@example.com',
|
|
136
196
|
});
|
|
137
197
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 100, {
|
|
138
198
|
'session.id': 'test-session-id',
|
|
199
|
+
'installation.id': 'test-installation-id',
|
|
200
|
+
'user.email': 'test@example.com',
|
|
139
201
|
model: 'gemini-pro',
|
|
140
202
|
type: 'input',
|
|
141
203
|
});
|
|
@@ -149,6 +211,8 @@ describe('Telemetry Metrics', () => {
|
|
|
149
211
|
});
|
|
150
212
|
expect(mockCounterAddFn).toHaveBeenCalledWith(50, {
|
|
151
213
|
'session.id': 'test-session-id',
|
|
214
|
+
'installation.id': 'test-installation-id',
|
|
215
|
+
'user.email': 'test@example.com',
|
|
152
216
|
model: 'gemini-pro',
|
|
153
217
|
type: 'output',
|
|
154
218
|
});
|
|
@@ -158,6 +222,8 @@ describe('Telemetry Metrics', () => {
|
|
|
158
222
|
});
|
|
159
223
|
expect(mockCounterAddFn).toHaveBeenCalledWith(25, {
|
|
160
224
|
'session.id': 'test-session-id',
|
|
225
|
+
'installation.id': 'test-installation-id',
|
|
226
|
+
'user.email': 'test@example.com',
|
|
161
227
|
model: 'gemini-pro',
|
|
162
228
|
type: 'thought',
|
|
163
229
|
});
|
|
@@ -167,6 +233,8 @@ describe('Telemetry Metrics', () => {
|
|
|
167
233
|
});
|
|
168
234
|
expect(mockCounterAddFn).toHaveBeenCalledWith(75, {
|
|
169
235
|
'session.id': 'test-session-id',
|
|
236
|
+
'installation.id': 'test-installation-id',
|
|
237
|
+
'user.email': 'test@example.com',
|
|
170
238
|
model: 'gemini-pro',
|
|
171
239
|
type: 'cache',
|
|
172
240
|
});
|
|
@@ -176,6 +244,8 @@ describe('Telemetry Metrics', () => {
|
|
|
176
244
|
});
|
|
177
245
|
expect(mockCounterAddFn).toHaveBeenCalledWith(125, {
|
|
178
246
|
'session.id': 'test-session-id',
|
|
247
|
+
'installation.id': 'test-installation-id',
|
|
248
|
+
'user.email': 'test@example.com',
|
|
179
249
|
model: 'gemini-pro',
|
|
180
250
|
type: 'tool',
|
|
181
251
|
});
|
|
@@ -189,6 +259,8 @@ describe('Telemetry Metrics', () => {
|
|
|
189
259
|
});
|
|
190
260
|
expect(mockCounterAddFn).toHaveBeenCalledWith(200, {
|
|
191
261
|
'session.id': 'test-session-id',
|
|
262
|
+
'installation.id': 'test-installation-id',
|
|
263
|
+
'user.email': 'test@example.com',
|
|
192
264
|
model: 'gemini-ultra',
|
|
193
265
|
type: 'input',
|
|
194
266
|
});
|
|
@@ -219,9 +291,13 @@ describe('Telemetry Metrics', () => {
|
|
|
219
291
|
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
220
292
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
221
293
|
'session.id': 'test-session-id',
|
|
294
|
+
'installation.id': 'test-installation-id',
|
|
295
|
+
'user.email': 'test@example.com',
|
|
222
296
|
});
|
|
223
297
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
224
298
|
'session.id': 'test-session-id',
|
|
299
|
+
'installation.id': 'test-installation-id',
|
|
300
|
+
'user.email': 'test@example.com',
|
|
225
301
|
operation: FileOperation.CREATE,
|
|
226
302
|
lines: 10,
|
|
227
303
|
mimetype: 'text/plain',
|
|
@@ -236,6 +312,8 @@ describe('Telemetry Metrics', () => {
|
|
|
236
312
|
});
|
|
237
313
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
238
314
|
'session.id': 'test-session-id',
|
|
315
|
+
'installation.id': 'test-installation-id',
|
|
316
|
+
'user.email': 'test@example.com',
|
|
239
317
|
operation: FileOperation.READ,
|
|
240
318
|
});
|
|
241
319
|
});
|
|
@@ -248,6 +326,8 @@ describe('Telemetry Metrics', () => {
|
|
|
248
326
|
});
|
|
249
327
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
250
328
|
'session.id': 'test-session-id',
|
|
329
|
+
'installation.id': 'test-installation-id',
|
|
330
|
+
'user.email': 'test@example.com',
|
|
251
331
|
operation: FileOperation.UPDATE,
|
|
252
332
|
mimetype: 'application/javascript',
|
|
253
333
|
});
|
|
@@ -260,6 +340,8 @@ describe('Telemetry Metrics', () => {
|
|
|
260
340
|
});
|
|
261
341
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
262
342
|
'session.id': 'test-session-id',
|
|
343
|
+
'installation.id': 'test-installation-id',
|
|
344
|
+
'user.email': 'test@example.com',
|
|
263
345
|
operation: FileOperation.UPDATE,
|
|
264
346
|
});
|
|
265
347
|
});
|
|
@@ -274,6 +356,8 @@ describe('Telemetry Metrics', () => {
|
|
|
274
356
|
});
|
|
275
357
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
276
358
|
'session.id': 'test-session-id',
|
|
359
|
+
'installation.id': 'test-installation-id',
|
|
360
|
+
'user.email': 'test@example.com',
|
|
277
361
|
operation: FileOperation.UPDATE,
|
|
278
362
|
lines: 10,
|
|
279
363
|
mimetype: 'text/plain',
|
|
@@ -288,6 +372,8 @@ describe('Telemetry Metrics', () => {
|
|
|
288
372
|
});
|
|
289
373
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
290
374
|
'session.id': 'test-session-id',
|
|
375
|
+
'installation.id': 'test-installation-id',
|
|
376
|
+
'user.email': 'test@example.com',
|
|
291
377
|
operation: FileOperation.UPDATE,
|
|
292
378
|
});
|
|
293
379
|
});
|
|
@@ -309,6 +395,8 @@ describe('Telemetry Metrics', () => {
|
|
|
309
395
|
recordModelRoutingMetricsModule(mockConfig, event);
|
|
310
396
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
311
397
|
'session.id': 'test-session-id',
|
|
398
|
+
'installation.id': 'test-installation-id',
|
|
399
|
+
'user.email': 'test@example.com',
|
|
312
400
|
'routing.decision_model': 'gemini-pro',
|
|
313
401
|
'routing.decision_source': 'default',
|
|
314
402
|
});
|
|
@@ -321,17 +409,226 @@ describe('Telemetry Metrics', () => {
|
|
|
321
409
|
recordModelRoutingMetricsModule(mockConfig, event);
|
|
322
410
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
|
323
411
|
'session.id': 'test-session-id',
|
|
412
|
+
'installation.id': 'test-installation-id',
|
|
413
|
+
'user.email': 'test@example.com',
|
|
324
414
|
'routing.decision_model': 'gemini-pro',
|
|
325
415
|
'routing.decision_source': 'classifier',
|
|
326
416
|
});
|
|
327
417
|
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
328
418
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
329
419
|
'session.id': 'test-session-id',
|
|
420
|
+
'installation.id': 'test-installation-id',
|
|
421
|
+
'user.email': 'test@example.com',
|
|
330
422
|
'routing.decision_source': 'classifier',
|
|
331
423
|
'routing.error_message': 'test-error',
|
|
332
424
|
});
|
|
333
425
|
});
|
|
334
426
|
});
|
|
427
|
+
describe('recordAgentRunMetrics', () => {
|
|
428
|
+
const mockConfig = {
|
|
429
|
+
getSessionId: () => 'test-session-id',
|
|
430
|
+
getTelemetryEnabled: () => true,
|
|
431
|
+
};
|
|
432
|
+
it('should not record metrics if not initialized', () => {
|
|
433
|
+
const event = new AgentFinishEvent('agent-123', 'TestAgent', 1000, 5, AgentTerminateMode.GOAL);
|
|
434
|
+
recordAgentRunMetricsModule(mockConfig, event);
|
|
435
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
436
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
437
|
+
});
|
|
438
|
+
it('should record agent run metrics', () => {
|
|
439
|
+
initializeMetricsModule(mockConfig);
|
|
440
|
+
mockCounterAddFn.mockClear();
|
|
441
|
+
mockHistogramRecordFn.mockClear();
|
|
442
|
+
const event = new AgentFinishEvent('agent-123', 'TestAgent', 1000, 5, AgentTerminateMode.GOAL);
|
|
443
|
+
recordAgentRunMetricsModule(mockConfig, event);
|
|
444
|
+
// Verify agent run counter
|
|
445
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
446
|
+
'session.id': 'test-session-id',
|
|
447
|
+
'installation.id': 'test-installation-id',
|
|
448
|
+
'user.email': 'test@example.com',
|
|
449
|
+
agent_name: 'TestAgent',
|
|
450
|
+
terminate_reason: 'GOAL',
|
|
451
|
+
});
|
|
452
|
+
// Verify agent duration histogram
|
|
453
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1000, {
|
|
454
|
+
'session.id': 'test-session-id',
|
|
455
|
+
'installation.id': 'test-installation-id',
|
|
456
|
+
'user.email': 'test@example.com',
|
|
457
|
+
agent_name: 'TestAgent',
|
|
458
|
+
});
|
|
459
|
+
// Verify agent turns histogram
|
|
460
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(5, {
|
|
461
|
+
'session.id': 'test-session-id',
|
|
462
|
+
'installation.id': 'test-installation-id',
|
|
463
|
+
'user.email': 'test@example.com',
|
|
464
|
+
agent_name: 'TestAgent',
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
describe('OpenTelemetry GenAI Semantic Convention Metrics', () => {
|
|
469
|
+
const mockConfig = {
|
|
470
|
+
getSessionId: () => 'test-session-id',
|
|
471
|
+
getTelemetryEnabled: () => true,
|
|
472
|
+
};
|
|
473
|
+
describe('recordGenAiClientTokenUsage', () => {
|
|
474
|
+
it('should not record metrics when not initialized', () => {
|
|
475
|
+
recordGenAiClientTokenUsageModule(mockConfig, 100, {
|
|
476
|
+
'gen_ai.operation.name': 'generate_content',
|
|
477
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
478
|
+
'gen_ai.token.type': 'input',
|
|
479
|
+
});
|
|
480
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
481
|
+
});
|
|
482
|
+
it('should record input token usage with correct attributes', () => {
|
|
483
|
+
initializeMetricsModule(mockConfig);
|
|
484
|
+
mockHistogramRecordFn.mockClear();
|
|
485
|
+
recordGenAiClientTokenUsageModule(mockConfig, 150, {
|
|
486
|
+
'gen_ai.operation.name': 'generate_content',
|
|
487
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
488
|
+
'gen_ai.token.type': 'input',
|
|
489
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
490
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
491
|
+
});
|
|
492
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
493
|
+
'session.id': 'test-session-id',
|
|
494
|
+
'installation.id': 'test-installation-id',
|
|
495
|
+
'user.email': 'test@example.com',
|
|
496
|
+
'gen_ai.operation.name': 'generate_content',
|
|
497
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
498
|
+
'gen_ai.token.type': 'input',
|
|
499
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
500
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
it('should record output token usage with correct attributes', () => {
|
|
504
|
+
initializeMetricsModule(mockConfig);
|
|
505
|
+
mockHistogramRecordFn.mockClear();
|
|
506
|
+
recordGenAiClientTokenUsageModule(mockConfig, 75, {
|
|
507
|
+
'gen_ai.operation.name': 'generate_content',
|
|
508
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
509
|
+
'gen_ai.token.type': 'output',
|
|
510
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
511
|
+
});
|
|
512
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(75, {
|
|
513
|
+
'session.id': 'test-session-id',
|
|
514
|
+
'installation.id': 'test-installation-id',
|
|
515
|
+
'user.email': 'test@example.com',
|
|
516
|
+
'gen_ai.operation.name': 'generate_content',
|
|
517
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
518
|
+
'gen_ai.token.type': 'output',
|
|
519
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
it('should record token usage with optional attributes', () => {
|
|
523
|
+
initializeMetricsModule(mockConfig);
|
|
524
|
+
mockHistogramRecordFn.mockClear();
|
|
525
|
+
recordGenAiClientTokenUsageModule(mockConfig, 200, {
|
|
526
|
+
'gen_ai.operation.name': 'generate_content',
|
|
527
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
528
|
+
'gen_ai.token.type': 'input',
|
|
529
|
+
'gen_ai.request.model': 'text-embedding-004',
|
|
530
|
+
'server.address': 'aiplatform.googleapis.com',
|
|
531
|
+
'server.port': 443,
|
|
532
|
+
});
|
|
533
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
|
534
|
+
'session.id': 'test-session-id',
|
|
535
|
+
'installation.id': 'test-installation-id',
|
|
536
|
+
'user.email': 'test@example.com',
|
|
537
|
+
'gen_ai.operation.name': 'generate_content',
|
|
538
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
539
|
+
'gen_ai.token.type': 'input',
|
|
540
|
+
'gen_ai.request.model': 'text-embedding-004',
|
|
541
|
+
'server.address': 'aiplatform.googleapis.com',
|
|
542
|
+
'server.port': 443,
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
describe('recordGenAiClientOperationDuration', () => {
|
|
547
|
+
it('should not record metrics when not initialized', () => {
|
|
548
|
+
recordGenAiClientOperationDurationModule(mockConfig, 2.5, {
|
|
549
|
+
'gen_ai.operation.name': 'generate_content',
|
|
550
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
551
|
+
});
|
|
552
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
553
|
+
});
|
|
554
|
+
it('should record successful operation duration with correct attributes', () => {
|
|
555
|
+
initializeMetricsModule(mockConfig);
|
|
556
|
+
mockHistogramRecordFn.mockClear();
|
|
557
|
+
recordGenAiClientOperationDurationModule(mockConfig, 1.25, {
|
|
558
|
+
'gen_ai.operation.name': 'generate_content',
|
|
559
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
560
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
561
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
562
|
+
});
|
|
563
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1.25, {
|
|
564
|
+
'session.id': 'test-session-id',
|
|
565
|
+
'installation.id': 'test-installation-id',
|
|
566
|
+
'user.email': 'test@example.com',
|
|
567
|
+
'gen_ai.operation.name': 'generate_content',
|
|
568
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
569
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
570
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
it('should record failed operation duration with error type', () => {
|
|
574
|
+
initializeMetricsModule(mockConfig);
|
|
575
|
+
mockHistogramRecordFn.mockClear();
|
|
576
|
+
recordGenAiClientOperationDurationModule(mockConfig, 3.75, {
|
|
577
|
+
'gen_ai.operation.name': 'generate_content',
|
|
578
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
579
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
580
|
+
'error.type': 'quota_exceeded',
|
|
581
|
+
});
|
|
582
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3.75, {
|
|
583
|
+
'session.id': 'test-session-id',
|
|
584
|
+
'installation.id': 'test-installation-id',
|
|
585
|
+
'user.email': 'test@example.com',
|
|
586
|
+
'gen_ai.operation.name': 'generate_content',
|
|
587
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
588
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
589
|
+
'error.type': 'quota_exceeded',
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
it('should record operation duration with server details', () => {
|
|
593
|
+
initializeMetricsModule(mockConfig);
|
|
594
|
+
mockHistogramRecordFn.mockClear();
|
|
595
|
+
recordGenAiClientOperationDurationModule(mockConfig, 0.95, {
|
|
596
|
+
'gen_ai.operation.name': 'generate_content',
|
|
597
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
598
|
+
'gen_ai.request.model': 'gemini-1.5-pro',
|
|
599
|
+
'gen_ai.response.model': 'gemini-1.5-pro-001',
|
|
600
|
+
'server.address': 'us-central1-aiplatform.googleapis.com',
|
|
601
|
+
'server.port': 443,
|
|
602
|
+
});
|
|
603
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.95, {
|
|
604
|
+
'session.id': 'test-session-id',
|
|
605
|
+
'installation.id': 'test-installation-id',
|
|
606
|
+
'user.email': 'test@example.com',
|
|
607
|
+
'gen_ai.operation.name': 'generate_content',
|
|
608
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
609
|
+
'gen_ai.request.model': 'gemini-1.5-pro',
|
|
610
|
+
'gen_ai.response.model': 'gemini-1.5-pro-001',
|
|
611
|
+
'server.address': 'us-central1-aiplatform.googleapis.com',
|
|
612
|
+
'server.port': 443,
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
it('should handle minimal required attributes', () => {
|
|
616
|
+
initializeMetricsModule(mockConfig);
|
|
617
|
+
mockHistogramRecordFn.mockClear();
|
|
618
|
+
recordGenAiClientOperationDurationModule(mockConfig, 2.1, {
|
|
619
|
+
'gen_ai.operation.name': 'generate_content',
|
|
620
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
621
|
+
});
|
|
622
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(2.1, {
|
|
623
|
+
'session.id': 'test-session-id',
|
|
624
|
+
'installation.id': 'test-installation-id',
|
|
625
|
+
'user.email': 'test@example.com',
|
|
626
|
+
'gen_ai.operation.name': 'generate_content',
|
|
627
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
});
|
|
335
632
|
describe('Performance Monitoring Metrics', () => {
|
|
336
633
|
const mockConfig = {
|
|
337
634
|
getSessionId: () => 'test-session-id',
|
|
@@ -367,6 +664,8 @@ describe('Telemetry Metrics', () => {
|
|
|
367
664
|
});
|
|
368
665
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
369
666
|
'session.id': 'test-session-id',
|
|
667
|
+
'installation.id': 'test-installation-id',
|
|
668
|
+
'user.email': 'test@example.com',
|
|
370
669
|
phase: 'settings_loading',
|
|
371
670
|
auth_type: 'gemini',
|
|
372
671
|
telemetry_enabled: true,
|
|
@@ -379,6 +678,8 @@ describe('Telemetry Metrics', () => {
|
|
|
379
678
|
recordStartupPerformanceModule(mockConfig, 50, { phase: 'cleanup' });
|
|
380
679
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(50, {
|
|
381
680
|
'session.id': 'test-session-id',
|
|
681
|
+
'installation.id': 'test-installation-id',
|
|
682
|
+
'user.email': 'test@example.com',
|
|
382
683
|
phase: 'cleanup',
|
|
383
684
|
});
|
|
384
685
|
});
|
|
@@ -396,6 +697,8 @@ describe('Telemetry Metrics', () => {
|
|
|
396
697
|
});
|
|
397
698
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(floatingPointDuration, {
|
|
398
699
|
'session.id': 'test-session-id',
|
|
700
|
+
'installation.id': 'test-installation-id',
|
|
701
|
+
'user.email': 'test@example.com',
|
|
399
702
|
phase: 'total_startup',
|
|
400
703
|
is_tty: true,
|
|
401
704
|
has_question: false,
|
|
@@ -412,6 +715,8 @@ describe('Telemetry Metrics', () => {
|
|
|
412
715
|
});
|
|
413
716
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
|
|
414
717
|
'session.id': 'test-session-id',
|
|
718
|
+
'installation.id': 'test-installation-id',
|
|
719
|
+
'user.email': 'test@example.com',
|
|
415
720
|
memory_type: 'heap_used',
|
|
416
721
|
component: 'startup',
|
|
417
722
|
});
|
|
@@ -434,16 +739,22 @@ describe('Telemetry Metrics', () => {
|
|
|
434
739
|
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
435
740
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 31457280, {
|
|
436
741
|
'session.id': 'test-session-id',
|
|
742
|
+
'installation.id': 'test-installation-id',
|
|
743
|
+
'user.email': 'test@example.com',
|
|
437
744
|
memory_type: 'heap_total',
|
|
438
745
|
component: 'api_call',
|
|
439
746
|
});
|
|
440
747
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 2097152, {
|
|
441
748
|
'session.id': 'test-session-id',
|
|
749
|
+
'installation.id': 'test-installation-id',
|
|
750
|
+
'user.email': 'test@example.com',
|
|
442
751
|
memory_type: 'external',
|
|
443
752
|
component: 'tool_execution',
|
|
444
753
|
});
|
|
445
754
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 41943040, {
|
|
446
755
|
'session.id': 'test-session-id',
|
|
756
|
+
'installation.id': 'test-installation-id',
|
|
757
|
+
'user.email': 'test@example.com',
|
|
447
758
|
memory_type: 'rss',
|
|
448
759
|
component: 'memory_monitor',
|
|
449
760
|
});
|
|
@@ -456,6 +767,8 @@ describe('Telemetry Metrics', () => {
|
|
|
456
767
|
});
|
|
457
768
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
|
|
458
769
|
'session.id': 'test-session-id',
|
|
770
|
+
'installation.id': 'test-installation-id',
|
|
771
|
+
'user.email': 'test@example.com',
|
|
459
772
|
memory_type: 'heap_used',
|
|
460
773
|
});
|
|
461
774
|
});
|
|
@@ -469,6 +782,8 @@ describe('Telemetry Metrics', () => {
|
|
|
469
782
|
});
|
|
470
783
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
|
471
784
|
'session.id': 'test-session-id',
|
|
785
|
+
'installation.id': 'test-installation-id',
|
|
786
|
+
'user.email': 'test@example.com',
|
|
472
787
|
component: 'tool_execution',
|
|
473
788
|
});
|
|
474
789
|
});
|
|
@@ -478,6 +793,8 @@ describe('Telemetry Metrics', () => {
|
|
|
478
793
|
recordCpuUsageModule(mockConfig, 42.3, {});
|
|
479
794
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(42.3, {
|
|
480
795
|
'session.id': 'test-session-id',
|
|
796
|
+
'installation.id': 'test-installation-id',
|
|
797
|
+
'user.email': 'test@example.com',
|
|
481
798
|
});
|
|
482
799
|
});
|
|
483
800
|
});
|
|
@@ -488,6 +805,8 @@ describe('Telemetry Metrics', () => {
|
|
|
488
805
|
recordToolQueueDepthModule(mockConfig, 3);
|
|
489
806
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3, {
|
|
490
807
|
'session.id': 'test-session-id',
|
|
808
|
+
'installation.id': 'test-installation-id',
|
|
809
|
+
'user.email': 'test@example.com',
|
|
491
810
|
});
|
|
492
811
|
});
|
|
493
812
|
it('should record zero queue depth', () => {
|
|
@@ -496,6 +815,8 @@ describe('Telemetry Metrics', () => {
|
|
|
496
815
|
recordToolQueueDepthModule(mockConfig, 0);
|
|
497
816
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0, {
|
|
498
817
|
'session.id': 'test-session-id',
|
|
818
|
+
'installation.id': 'test-installation-id',
|
|
819
|
+
'user.email': 'test@example.com',
|
|
499
820
|
});
|
|
500
821
|
});
|
|
501
822
|
});
|
|
@@ -509,6 +830,8 @@ describe('Telemetry Metrics', () => {
|
|
|
509
830
|
});
|
|
510
831
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(25, {
|
|
511
832
|
'session.id': 'test-session-id',
|
|
833
|
+
'installation.id': 'test-installation-id',
|
|
834
|
+
'user.email': 'test@example.com',
|
|
512
835
|
function_name: 'Read',
|
|
513
836
|
phase: 'validation',
|
|
514
837
|
});
|
|
@@ -531,16 +854,22 @@ describe('Telemetry Metrics', () => {
|
|
|
531
854
|
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
532
855
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 50, {
|
|
533
856
|
'session.id': 'test-session-id',
|
|
857
|
+
'installation.id': 'test-installation-id',
|
|
858
|
+
'user.email': 'test@example.com',
|
|
534
859
|
function_name: 'Bash',
|
|
535
860
|
phase: 'preparation',
|
|
536
861
|
});
|
|
537
862
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 1500, {
|
|
538
863
|
'session.id': 'test-session-id',
|
|
864
|
+
'installation.id': 'test-installation-id',
|
|
865
|
+
'user.email': 'test@example.com',
|
|
539
866
|
function_name: 'Bash',
|
|
540
867
|
phase: 'execution',
|
|
541
868
|
});
|
|
542
869
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 75, {
|
|
543
870
|
'session.id': 'test-session-id',
|
|
871
|
+
'installation.id': 'test-installation-id',
|
|
872
|
+
'user.email': 'test@example.com',
|
|
544
873
|
function_name: 'Bash',
|
|
545
874
|
phase: 'result_processing',
|
|
546
875
|
});
|
|
@@ -557,6 +886,8 @@ describe('Telemetry Metrics', () => {
|
|
|
557
886
|
});
|
|
558
887
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.85, {
|
|
559
888
|
'session.id': 'test-session-id',
|
|
889
|
+
'installation.id': 'test-installation-id',
|
|
890
|
+
'user.email': 'test@example.com',
|
|
560
891
|
model: 'gemini-pro',
|
|
561
892
|
metric: 'cache_hit_rate',
|
|
562
893
|
context: 'api_request',
|
|
@@ -571,6 +902,8 @@ describe('Telemetry Metrics', () => {
|
|
|
571
902
|
});
|
|
572
903
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(125.5, {
|
|
573
904
|
'session.id': 'test-session-id',
|
|
905
|
+
'installation.id': 'test-installation-id',
|
|
906
|
+
'user.email': 'test@example.com',
|
|
574
907
|
model: 'gemini-pro',
|
|
575
908
|
metric: 'tokens_per_operation',
|
|
576
909
|
});
|
|
@@ -586,6 +919,8 @@ describe('Telemetry Metrics', () => {
|
|
|
586
919
|
});
|
|
587
920
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15, {
|
|
588
921
|
'session.id': 'test-session-id',
|
|
922
|
+
'installation.id': 'test-installation-id',
|
|
923
|
+
'user.email': 'test@example.com',
|
|
589
924
|
model: 'gemini-pro',
|
|
590
925
|
phase: 'request_preparation',
|
|
591
926
|
});
|
|
@@ -608,16 +943,22 @@ describe('Telemetry Metrics', () => {
|
|
|
608
943
|
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
609
944
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 250, {
|
|
610
945
|
'session.id': 'test-session-id',
|
|
946
|
+
'installation.id': 'test-installation-id',
|
|
947
|
+
'user.email': 'test@example.com',
|
|
611
948
|
model: 'gemini-pro',
|
|
612
949
|
phase: 'network_latency',
|
|
613
950
|
});
|
|
614
951
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 100, {
|
|
615
952
|
'session.id': 'test-session-id',
|
|
953
|
+
'installation.id': 'test-installation-id',
|
|
954
|
+
'user.email': 'test@example.com',
|
|
616
955
|
model: 'gemini-pro',
|
|
617
956
|
phase: 'response_processing',
|
|
618
957
|
});
|
|
619
958
|
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 50, {
|
|
620
959
|
'session.id': 'test-session-id',
|
|
960
|
+
'installation.id': 'test-installation-id',
|
|
961
|
+
'user.email': 'test@example.com',
|
|
621
962
|
model: 'gemini-pro',
|
|
622
963
|
phase: 'token_processing',
|
|
623
964
|
});
|
|
@@ -633,6 +974,8 @@ describe('Telemetry Metrics', () => {
|
|
|
633
974
|
});
|
|
634
975
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
|
635
976
|
'session.id': 'test-session-id',
|
|
977
|
+
'installation.id': 'test-installation-id',
|
|
978
|
+
'user.email': 'test@example.com',
|
|
636
979
|
category: 'memory_efficiency',
|
|
637
980
|
baseline: 80.0,
|
|
638
981
|
});
|
|
@@ -645,6 +988,8 @@ describe('Telemetry Metrics', () => {
|
|
|
645
988
|
});
|
|
646
989
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(92.3, {
|
|
647
990
|
'session.id': 'test-session-id',
|
|
991
|
+
'installation.id': 'test-installation-id',
|
|
992
|
+
'user.email': 'test@example.com',
|
|
648
993
|
category: 'overall_performance',
|
|
649
994
|
});
|
|
650
995
|
});
|
|
@@ -663,6 +1008,8 @@ describe('Telemetry Metrics', () => {
|
|
|
663
1008
|
// Verify regression counter
|
|
664
1009
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
665
1010
|
'session.id': 'test-session-id',
|
|
1011
|
+
'installation.id': 'test-installation-id',
|
|
1012
|
+
'user.email': 'test@example.com',
|
|
666
1013
|
metric: 'startup_time',
|
|
667
1014
|
severity: 'medium',
|
|
668
1015
|
current_value: 1200,
|
|
@@ -671,6 +1018,8 @@ describe('Telemetry Metrics', () => {
|
|
|
671
1018
|
// Verify baseline comparison histogram (20% increase)
|
|
672
1019
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
|
673
1020
|
'session.id': 'test-session-id',
|
|
1021
|
+
'installation.id': 'test-installation-id',
|
|
1022
|
+
'user.email': 'test@example.com',
|
|
674
1023
|
metric: 'startup_time',
|
|
675
1024
|
severity: 'medium',
|
|
676
1025
|
current_value: 1200,
|
|
@@ -690,6 +1039,8 @@ describe('Telemetry Metrics', () => {
|
|
|
690
1039
|
// Verify regression counter still recorded
|
|
691
1040
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
692
1041
|
'session.id': 'test-session-id',
|
|
1042
|
+
'installation.id': 'test-installation-id',
|
|
1043
|
+
'user.email': 'test@example.com',
|
|
693
1044
|
metric: 'memory_usage',
|
|
694
1045
|
severity: 'high',
|
|
695
1046
|
current_value: 100,
|
|
@@ -715,6 +1066,8 @@ describe('Telemetry Metrics', () => {
|
|
|
715
1066
|
});
|
|
716
1067
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
717
1068
|
'session.id': 'test-session-id',
|
|
1069
|
+
'installation.id': 'test-installation-id',
|
|
1070
|
+
'user.email': 'test@example.com',
|
|
718
1071
|
metric: 'api_latency',
|
|
719
1072
|
severity: 'low',
|
|
720
1073
|
current_value: 500,
|
|
@@ -722,6 +1075,8 @@ describe('Telemetry Metrics', () => {
|
|
|
722
1075
|
});
|
|
723
1076
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
724
1077
|
'session.id': 'test-session-id',
|
|
1078
|
+
'installation.id': 'test-installation-id',
|
|
1079
|
+
'user.email': 'test@example.com',
|
|
725
1080
|
metric: 'cpu_usage',
|
|
726
1081
|
severity: 'high',
|
|
727
1082
|
current_value: 90,
|
|
@@ -742,6 +1097,8 @@ describe('Telemetry Metrics', () => {
|
|
|
742
1097
|
// 20% increase: (120 - 100) / 100 * 100 = 20%
|
|
743
1098
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
|
744
1099
|
'session.id': 'test-session-id',
|
|
1100
|
+
'installation.id': 'test-installation-id',
|
|
1101
|
+
'user.email': 'test@example.com',
|
|
745
1102
|
metric: 'memory_usage',
|
|
746
1103
|
category: 'performance_tracking',
|
|
747
1104
|
current_value: 120,
|
|
@@ -760,6 +1117,8 @@ describe('Telemetry Metrics', () => {
|
|
|
760
1117
|
// 20% decrease: (800 - 1000) / 1000 * 100 = -20%
|
|
761
1118
|
expect(mockHistogramRecordFn).toHaveBeenCalledWith(-20, {
|
|
762
1119
|
'session.id': 'test-session-id',
|
|
1120
|
+
'installation.id': 'test-installation-id',
|
|
1121
|
+
'user.email': 'test@example.com',
|
|
763
1122
|
metric: 'startup_time',
|
|
764
1123
|
category: 'optimization',
|
|
765
1124
|
current_value: 800,
|