Open
Conversation
Contributor
|
@greptile |
| @staticmethod | ||
| async def _process_items(items: list[_SpanQueueItem]) -> None: | ||
| """Process a list of span events concurrently.""" | ||
| """Dispatch a batch of same-event-type items to each processor in one call. |
Contributor
There was a problem hiding this comment.
Is it guaranteed that all these items are the same event-type?
Contributor
There was a problem hiding this comment.
Nevermind, see we dispatch them ourselves
| if not items: | ||
| return | ||
|
|
||
| event_type = items[0].event_type |
Contributor
There was a problem hiding this comment.
Are all the event_types the same?
Author
There was a problem hiding this comment.
I believe they should be but added an assert to check
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.
https://linear.app/scale-epd/issue/AGX1-198/actually-use-sgp-batching-for-spans
Greptile Summary
This PR implements true HTTP batching for SGP span upserts: the queue now groups spans by processor and calls
on_spans_start/on_spans_endonce per drain cycle per processor, replacing the previous N-calls-per-drain approach.SGPAsyncTracingProcessoroverrides the new batched methods to issue a singleupsert_batchHTTP request for all spans in the batch, and the interface provides a safe default fan-out fallback for processors that only implement the single-span methods.Confidence Score: 5/5
Safe to merge; one minor P2 style suggestion about assert vs raise, no blocking issues.
The batching logic is correct and well-tested, the default fallback properly uses return_exceptions=True with per-failure logging, and the prior concern about return_exceptions has been addressed. The only remaining finding is a P2 suggestion to replace assert with an explicit ValueError in _process_items.
No files require special attention.
Important Files Changed
Sequence Diagram
sequenceDiagram participant DL as AsyncSpanQueue._drain_loop participant PI as _process_items participant SGP as SGPAsyncTracingProcessor participant API as SGP HTTP API DL->>PI: _process_items(starts) PI->>PI: group spans by processor PI->>SGP: on_spans_start([span1, span2, ...spanN]) SGP->>SGP: create all SGPSpans, store in _spans SGP->>API: upsert_batch(items=[...N items...]) API-->>SGP: 200 OK DL->>PI: _process_items(ends) PI->>SGP: on_spans_end([span1, span2, ...spanN]) SGP->>SGP: pop from _spans, update fields SGP->>API: upsert_batch(items=[...N items...]) API-->>SGP: 200 OKPrompt To Fix All With AI
Reviews (3): Last reviewed commit: "lint fixes" | Re-trigger Greptile