fix(snapshots): Add instrumentation logging to snapshot download stream#116079
Merged
Conversation
Adds per-batch and lifecycle logging to diagnose HTTP/2 stream errors on large (40K image) snapshot downloads. Tracks batch progress, fetch latency percentiles, gaps between yields, memory usage, and how the stream terminates (complete, client disconnect, or exception). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b79a120. Configure here.
- Use sys.platform to choose correct ru_maxrss divisor (KB on Linux, bytes on macOS) - Move stream_finally logging after zf.close() and final buf.drain() so bytes_yielded includes the ZIP central directory Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mtopo27
approved these changes
May 26, 2026
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.

Add per-batch and lifecycle logging to the streaming ZIP download endpoint
to diagnose why 40K-image snapshot downloads fail with HTTP/2 stream errors
after ~20-25 seconds.
The streaming generator currently has zero observability — the Django span
closes in ~1s (before the generator runs), and when the stream dies
externally, nothing is logged. We need to see:
Log points added:
stream_start— confirms generator is running, PID, memory baselinebatch_complete— per batch: duration, cumulative progress, max yield gap, fetch latency p50/p99/max, RSSstream_complete— successful finish with totalsstream_error— unhandled exception with tracebackstream_finally— always fires with exit reason and final statsThis is temporary instrumentation to be removed once the root cause is found.