feat(telemetry): add diff stats to tool call metrics (#10819)

This commit is contained in:
Jerop Kipruto
2025-10-09 18:01:35 -04:00
committed by GitHub
parent 5aab793cfd
commit 1f6716f98a
4 changed files with 25 additions and 8 deletions

View File

@@ -345,6 +345,14 @@ Metrics are numerical measurements of behavior over time.
- `success` (boolean)
- `decision` (string: "accept", "reject", or "modify", if applicable)
- `tool_type` (string: "mcp", or "native", if applicable)
- `model_added_lines` (Int, optional): Lines added by model in the proposed
changes, if applicable
- `model_removed_lines` (Int, optional): Lines removed by model in the
proposed changes, if applicable
- `user_added_lines` (Int, optional): Lines added by user edits after model
proposal, if applicable
- `user_removed_lines` (Int, optional): Lines removed by user edits after
model proposal, if applicable
- `gemini_cli.tool.call.latency` (Histogram, ms): Measures tool call latency.
- **Attributes**:
@@ -379,14 +387,6 @@ Metrics are numerical measurements of behavior over time.
- `lines` (Int, if applicable): Number of lines in the file.
- `mimetype` (string, if applicable): Mimetype of the file.
- `extension` (string, if applicable): File extension of the file.
- `model_added_lines` (Int, if applicable): Number of lines added/changed by
the model.
- `model_removed_lines` (Int, if applicable): Number of lines
removed/changed by the model.
- `user_added_lines` (Int, if applicable): Number of lines added/changed by
user in AI proposed changes.
- `user_removed_lines` (Int, if applicable): Number of lines removed/changed
by user in AI proposed changes.
- `programming_language` (string, if applicable): The programming language
of the file.

View File

@@ -694,6 +694,10 @@ describe('loggers', () => {
success: true,
decision: ToolCallDecision.ACCEPT,
tool_type: 'native',
model_added_lines: 1,
model_removed_lines: 2,
user_added_lines: 5,
user_removed_lines: 6,
},
);

View File

@@ -209,6 +209,14 @@ export function logToolCall(config: Config, event: ToolCallEvent): void {
success: event.success,
decision: event.decision,
tool_type: event.tool_type,
...(event.metadata
? {
model_added_lines: event.metadata['model_added_lines'],
model_removed_lines: event.metadata['model_removed_lines'],
user_added_lines: event.metadata['user_added_lines'],
user_removed_lines: event.metadata['user_removed_lines'],
}
: {}),
});
}

View File

@@ -70,6 +70,11 @@ const COUNTER_DEFINITIONS = {
success: boolean;
decision?: 'accept' | 'reject' | 'modify' | 'auto_accept';
tool_type?: 'native' | 'mcp';
// Optional diff statistics for file-modifying tools
model_added_lines?: number;
model_removed_lines?: number;
user_added_lines?: number;
user_removed_lines?: number;
},
},
[API_REQUEST_COUNT]: {