fix(core): skip telemetry logging for AbortError exceptions#19477
fix(core): skip telemetry logging for AbortError exceptions#19477
Conversation
Summary of ChangesHello @yunaseoul, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the error handling within the API client to differentiate between genuine API errors and user-initiated cancellations. By specifically identifying and ignoring Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly prevents logging AbortError when a user cancels a request. The changes in LoggingContentGenerator effectively check for this specific error in both streaming and non-streaming paths and prevent it from being logged, which will improve the accuracy of error telemetry. The accompanying tests are thorough, covering all the modified code paths. I have one suggestion to improve maintainability by refactoring the duplicated AbortError check into a single utility function.
|
Size Change: +205 B (0%) Total Size: 25.8 MB ℹ️ View Unchanged
|
b5dce07 to
377b7d2
Compare
377b7d2 to
1c0fa35
Compare
Avoids logging AbortError instances as API errors during content generation and streaming, as these typically represent user cancellations or expected internal timeouts rather than actual API failures. Added isAbortError utility to support this check.
1c0fa35 to
01b3943
Compare
…emini#19477) Co-authored-by: Yuna Seol <yunaseol@google.com>
…emini#19477) Co-authored-by: Yuna Seol <yunaseol@google.com>
…emini#19477) Co-authored-by: Yuna Seol <yunaseol@google.com>
Summary
Skip logging API errors when a request is aborted by the user or encounters an internal timeout (i.e.,
AbortError).Details
When a user cancels a request or leaves a session, the Gemini API client throws an
AbortError. Previously, this was logged as a generic API error in theLoggingContentGenerator, which skewed telemetry and error reporting for model usage.This PR adds a centralized
isAbortErrorutility topackages/core/src/utils/errors.tsand uses it to add explicit checks forAbortErrorin both streaming and non-streaming request paths inLoggingContentGenerator. This ensures these user-initiated cancellations or timeouts are not tracked as system or API errors.Related Issues
Fixes #17328
How to Validate
logApiErroris NOT triggered in the telemetry/logs.packages/core/src/core/loggingContentGenerator.test.tsandpackages/core/src/utils/errors.test.ts.Pre-Merge Checklist