mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
add(telemetry): Add missing telemetry for UserPromptEvent (#6885)
Co-authored-by: Shnatu <snatu@google.com> Co-authored-by: Arya Gummadi <aryagummadi@google.com>
This commit is contained in:
@@ -177,9 +177,10 @@ Logs are timestamped records of specific events. The following events are logged
|
|||||||
|
|
||||||
- `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**:
|
||||||
- `prompt_length`
|
- `prompt_length` (int)
|
||||||
- `prompt` (this attribute is excluded if `log_prompts_enabled` is configured to be `false`)
|
- `prompt_id` (string)
|
||||||
- `auth_type`
|
- `prompt` (string, this attribute is excluded if `log_prompts_enabled` is configured to be `false`)
|
||||||
|
- `auth_type` (string)
|
||||||
|
|
||||||
- `gemini_cli.tool_call`: This event occurs for each function call.
|
- `gemini_cli.tool_call`: This event occurs for each function call.
|
||||||
- **Attributes**:
|
- **Attributes**:
|
||||||
|
|||||||
@@ -208,6 +208,8 @@ describe('loggers', () => {
|
|||||||
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
||||||
prompt_length: 11,
|
prompt_length: 11,
|
||||||
prompt: 'test-prompt',
|
prompt: 'test-prompt',
|
||||||
|
prompt_id: 'prompt-id-8',
|
||||||
|
auth_type: 'vertex-ai',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -222,8 +224,9 @@ describe('loggers', () => {
|
|||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
const event = new UserPromptEvent(
|
const event = new UserPromptEvent(
|
||||||
11,
|
11,
|
||||||
'test-prompt',
|
'prompt-id-9',
|
||||||
AuthType.CLOUD_SHELL,
|
AuthType.CLOUD_SHELL,
|
||||||
|
'test-prompt',
|
||||||
);
|
);
|
||||||
|
|
||||||
logUserPrompt(mockConfig, event);
|
logUserPrompt(mockConfig, event);
|
||||||
@@ -236,6 +239,8 @@ describe('loggers', () => {
|
|||||||
'event.name': EVENT_USER_PROMPT,
|
'event.name': EVENT_USER_PROMPT,
|
||||||
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
'event.timestamp': '2025-01-01T00:00:00.000Z',
|
||||||
prompt_length: 11,
|
prompt_length: 11,
|
||||||
|
prompt_id: 'prompt-id-9',
|
||||||
|
auth_type: 'cloud-shell',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -122,8 +122,13 @@ export function logUserPrompt(config: Config, event: UserPromptEvent): void {
|
|||||||
'event.name': EVENT_USER_PROMPT,
|
'event.name': EVENT_USER_PROMPT,
|
||||||
'event.timestamp': new Date().toISOString(),
|
'event.timestamp': new Date().toISOString(),
|
||||||
prompt_length: event.prompt_length,
|
prompt_length: event.prompt_length,
|
||||||
|
prompt_id: event.prompt_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (event.auth_type) {
|
||||||
|
attributes['auth_type'] = event.auth_type;
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldLogUserPrompts(config)) {
|
if (shouldLogUserPrompts(config)) {
|
||||||
attributes['prompt'] = event.prompt;
|
attributes['prompt'] = event.prompt;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user