mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
feat: add telemetry for output format usage (#8223)
This commit is contained in:
@@ -176,6 +176,7 @@ Logs are timestamped records of specific events. The following events are logged
|
|||||||
- `file_filtering_respect_git_ignore` (boolean)
|
- `file_filtering_respect_git_ignore` (boolean)
|
||||||
- `debug_mode` (boolean)
|
- `debug_mode` (boolean)
|
||||||
- `mcp_servers` (string)
|
- `mcp_servers` (string)
|
||||||
|
- `output_format` (string: "text" or "json")
|
||||||
|
|
||||||
- `gemini_cli.user_prompt`: This event occurs when a user submits a prompt.
|
- `gemini_cli.user_prompt`: This event occurs when a user submits a prompt.
|
||||||
- **Attributes**:
|
- **Attributes**:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
ToolErrorType,
|
ToolErrorType,
|
||||||
ToolRegistry,
|
ToolRegistry,
|
||||||
} from '../index.js';
|
} from '../index.js';
|
||||||
|
import { OutputFormat } from '../output/types.js';
|
||||||
import { logs } from '@opentelemetry/api-logs';
|
import { logs } from '@opentelemetry/api-logs';
|
||||||
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
|
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
|
||||||
import type { Config } from '../config/config.js';
|
import type { Config } from '../config/config.js';
|
||||||
@@ -157,6 +158,7 @@ describe('loggers', () => {
|
|||||||
getQuestion: () => 'test-question',
|
getQuestion: () => 'test-question',
|
||||||
getTargetDir: () => 'target-dir',
|
getTargetDir: () => 'target-dir',
|
||||||
getProxy: () => 'http://test.proxy.com:8080',
|
getProxy: () => 'http://test.proxy.com:8080',
|
||||||
|
getOutputFormat: () => OutputFormat.JSON,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
const startSessionEvent = new StartSessionEvent(mockConfig);
|
const startSessionEvent = new StartSessionEvent(mockConfig);
|
||||||
@@ -183,6 +185,7 @@ describe('loggers', () => {
|
|||||||
mcp_servers_count: 1,
|
mcp_servers_count: 1,
|
||||||
mcp_tools: undefined,
|
mcp_tools: undefined,
|
||||||
mcp_tools_count: undefined,
|
mcp_tools_count: undefined,
|
||||||
|
output_format: 'json',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ export function logCliConfiguration(
|
|||||||
mcp_servers_count: event.mcp_servers_count,
|
mcp_servers_count: event.mcp_servers_count,
|
||||||
mcp_tools: event.mcp_tools,
|
mcp_tools: event.mcp_tools,
|
||||||
mcp_tools_count: event.mcp_tools_count,
|
mcp_tools_count: event.mcp_tools_count,
|
||||||
|
output_format: event.output_format,
|
||||||
};
|
};
|
||||||
|
|
||||||
const logger = logs.getLogger(SERVICE_NAME);
|
const logger = logs.getLogger(SERVICE_NAME);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
import type { FileOperation } from './metrics.js';
|
import type { FileOperation } from './metrics.js';
|
||||||
export { ToolCallDecision };
|
export { ToolCallDecision };
|
||||||
import type { ToolRegistry } from '../tools/tool-registry.js';
|
import type { ToolRegistry } from '../tools/tool-registry.js';
|
||||||
|
import type { OutputFormat } from '../output/types.js';
|
||||||
|
|
||||||
export interface BaseTelemetryEvent {
|
export interface BaseTelemetryEvent {
|
||||||
'event.name': string;
|
'event.name': string;
|
||||||
@@ -45,6 +46,7 @@ export class StartSessionEvent implements BaseTelemetryEvent {
|
|||||||
mcp_servers_count: number;
|
mcp_servers_count: number;
|
||||||
mcp_tools_count?: number;
|
mcp_tools_count?: number;
|
||||||
mcp_tools?: string;
|
mcp_tools?: string;
|
||||||
|
output_format: OutputFormat;
|
||||||
|
|
||||||
constructor(config: Config, toolRegistry?: ToolRegistry) {
|
constructor(config: Config, toolRegistry?: ToolRegistry) {
|
||||||
const generatorConfig = config.getContentGeneratorConfig();
|
const generatorConfig = config.getContentGeneratorConfig();
|
||||||
@@ -74,6 +76,7 @@ export class StartSessionEvent implements BaseTelemetryEvent {
|
|||||||
this.file_filtering_respect_git_ignore =
|
this.file_filtering_respect_git_ignore =
|
||||||
config.getFileFilteringRespectGitIgnore();
|
config.getFileFilteringRespectGitIgnore();
|
||||||
this.mcp_servers_count = mcpServers ? Object.keys(mcpServers).length : 0;
|
this.mcp_servers_count = mcpServers ? Object.keys(mcpServers).length : 0;
|
||||||
|
this.output_format = config.getOutputFormat();
|
||||||
if (toolRegistry) {
|
if (toolRegistry) {
|
||||||
const mcpTools = toolRegistry
|
const mcpTools = toolRegistry
|
||||||
.getAllTools()
|
.getAllTools()
|
||||||
|
|||||||
Reference in New Issue
Block a user