mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Handle telemetry in non-interactive mode (#1002)
Changes: - Ensure proper shutdown in non-interactive mode - Ensures the initial user prompt is logged in non-interactive mode - Improve telemetry for streaming - handle chunks and input token count is now alongside other token counts in response To test: - Follow instructions in https://github.com/google-gemini/gemini-cli/blob/main/docs/core/telemetry.md#google-cloud - Run CLI in non-interactive mode and observe logs/metrics in GCP Logs Explorer and Metrics Explorer #750
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
WebSearchTool,
|
||||
WriteFileTool,
|
||||
sessionId,
|
||||
logUserPrompt,
|
||||
} from '@gemini-cli/core';
|
||||
|
||||
export async function main() {
|
||||
@@ -120,6 +121,11 @@ export async function main() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
logUserPrompt(config, {
|
||||
prompt: input,
|
||||
prompt_length: input.length,
|
||||
});
|
||||
|
||||
// Non-interactive mode handled by runNonInteractive
|
||||
const nonInteractiveConfig = await loadNonInteractiveConfig(
|
||||
config,
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
ToolCallRequestInfo,
|
||||
executeToolCall,
|
||||
ToolRegistry,
|
||||
shutdownTelemetry,
|
||||
isTelemetrySdkInitialized,
|
||||
} from '@gemini-cli/core';
|
||||
import {
|
||||
Content,
|
||||
@@ -119,5 +121,9 @@ export async function runNonInteractive(
|
||||
} catch (error) {
|
||||
console.error('Error processing input:', error);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
if (isTelemetrySdkInitialized()) {
|
||||
await shutdownTelemetry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user