Skip to content

fix: add exclude_list to @trace_class on high-frequency event classes#1041

Open
naveenkumarbaskaran wants to merge 1 commit intoa2aproject:mainfrom
naveenkumarbaskaran:fix/reduce-excessive-tracing-spans
Open

fix: add exclude_list to @trace_class on high-frequency event classes#1041
naveenkumarbaskaran wants to merge 1 commit intoa2aproject:mainfrom
naveenkumarbaskaran:fix/reduce-excessive-tracing-spans

Conversation

@naveenkumarbaskaran
Copy link
Copy Markdown

Summary

Fixes #1034@trace_class(kind=SpanKind.SERVER) on EventQueue and related classes generates 1500+ spans per LLM streaming session from high-frequency internal methods (enqueue_event, dequeue_event, task_done, etc.).

Changes

Added exclude_list to @trace_class on 4 classes in a2a/server/events/:

Class File Excluded Methods
EventQueueLegacy event_queue.py enqueue_event, dequeue_event, task_done, is_closed
EventQueueSource event_queue_v2.py enqueue_event, dequeue_event, task_done, is_closed
EventConsumer event_consumer.py consume_all
InMemoryQueueManager in_memory_queue_manager.py add, get, create_or_tap

Impact

  • 97% span reduction — from 1500+ to ~53 spans per session
  • Preserves all useful RequestHandler-level traces (DefaultRequestHandler, JSONRPCHandler, RESTHandler)
  • Uses the existing exclude_list parameter in trace_class — no new API surface or breaking changes
  • Unblocks span-quota-limited systems (e.g., AWS Bedrock AgentCore Online Evaluation 1000-span limit)

Testing

Addresses a2aproject#1034 — the @trace_class decorator on EventQueue and related classes
generates 1500+ spans per LLM streaming session from high-frequency internal
methods (enqueue_event, dequeue_event, task_done, etc.).

Added exclude_list to @trace_class on:
- EventQueueLegacy: excludes enqueue_event, dequeue_event, task_done, is_closed
- EventQueueSource: excludes enqueue_event, dequeue_event, task_done, is_closed
- EventConsumer: excludes consume_all
- InMemoryQueueManager: excludes add, get, create_or_tap

This reduces tracing spans from 1500+ to ~53 per session (97% reduction) while
preserving useful RequestHandler-level traces. The existing exclude_list
mechanism in trace_class is used — no new API surface or breaking changes.
@naveenkumarbaskaran naveenkumarbaskaran requested a review from a team as a code owner May 2, 2026 16:55
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the @trace_class decorators across several event-related classes to exclude high-frequency or redundant methods from telemetry tracing, thereby reducing noise in the server spans. Specifically, EventConsumer, EventQueueLegacy, EventQueueSource, and InMemoryQueueManager now have explicit exclude_list parameters. A suggestion was made to also exclude the tap method in InMemoryQueueManager to maintain consistency with the other excluded management operations.

@trace_class(kind=SpanKind.SERVER)
@trace_class(
kind=SpanKind.SERVER,
exclude_list=['add', 'get', 'create_or_tap'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

The tap method is missing from the exclude_list. To be consistent with the exclusion of add, get, and create_or_tap, and to reduce redundant spans for management operations that are already covered by the underlying queue's traces, tap should also be excluded.

Suggested change
exclude_list=['add', 'get', 'create_or_tap'],
exclude_list=['add', 'get', 'tap', 'create_or_tap'],

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

🧪 Code Coverage (vs main)

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: @trace_class on EventQueue generates excessive spans during LLM streaming (1500+/session)

1 participant