fix(cli): stop unbounded debug trace retention on the api server - #6916
Open
a2105z wants to merge 1 commit into
Open
fix(cli): stop unbounded debug trace retention on the api server#6916a2105z wants to merge 1 commit into
a2105z wants to merge 1 commit into
Conversation
get_fast_api_app(web=False) still installed ApiServerSpanExporter and InMemoryExporter even though the debug endpoints that read them are only mounted with web=True. Those buffers retain every span (including full llm_request / llm_response) for the life of the process and OOM long-lived Cloud Run / GKE instances. Register the exporters only on DevServer, and FIFO-cap the event dict, span deque, and session index so adk web cannot grow without bound either. Closes google#6915
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
get_fast_api_app(web=False)unconditionally installedApiServerSpanExporterandInMemoryExporteron the process tracer. Those buffers store fullllm_request/llm_responseattributes and every span, with no eviction. The debug endpoints that read them (/dev/apps/.../debug/trace) are only mounted withweb=True, so a production Cloud Run / GKE process pays unbounded memory for buffers nobody reads. Measured ~200 KB/LLM turn and OOM about every 6 days.Solution:
ApiServer(web=False).DevServer(web=True/adk web) still registers them.adk websession cannot retain every span either.Testing Plan
Unit Tests:
Manual End-to-End (E2E) Tests:
adk webstill serves/dev/apps/{app}/debug/trace/{event_id}(covered bytest_debug_trace).Checklist