Skip to content

feat: add dropped_count property to BatchTraceProcessor - #4792

Open
Showmick119 wants to merge 1 commit into
openai:mainfrom
Showmick119:fix/batch-trace-queue-drop
Open

feat: add dropped_count property to BatchTraceProcessor#4792
Showmick119 wants to merge 1 commit into
openai:mainfrom
Showmick119:fix/batch-trace-queue-drop

Conversation

@Showmick119

Copy link
Copy Markdown

This pull request adds a dropped_count property to BatchTraceProcessor to provide visibility into trace data loss.

Previously, when the internal queue of BatchTraceProcessor became full (which can happen under heavy load or if the background export thread falls behind), traces and spans were dropped with only a logger.warning. There was no programmatic way to observe or alert on this data loss.

This PR:

  • Adds a _dropped_count instance variable to track the number of dropped items.
  • Increments _dropped_count whenever queue.Full is caught during on_trace_start and on_span_end.
  • Exposes this metric via a public dropped_count property.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09797974d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

try:
self._queue.put_nowait(trace)
except queue.Full:
self._dropped_count += 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Serialize concurrent dropped-count updates

When multiple application threads finish spans or start traces while the queue is full, both callbacks can read the same _dropped_count value before either stores its increment, causing the public metric to undercount dropped telemetry; this is especially reachable on free-threaded Python builds and other interpreters because += is not an atomic counter operation. Protect both increments and reads with a shared lock or another thread-safe counter, and cover the interleaving with a controlled concurrency test rather than only the sequential test.

AGENTS.md reference: AGENTS.md:L149-L149

Useful? React with 👍 / 👎.

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.

1 participant