feat(fetch): count bytes on the wire as well as decoded - #760
Merged
Merged
Conversation
fetch-stats reported only `bytes`, len(response.content), and that read as the download volume. ESPN gzips every scoreboard, so it overstated real traffic about 14x: a college football Saturday is 865 KB decoded, 63 KB on the wire. Every counter set now carries `wire_bytes`, read from urllib3's count of raw bytes taken off the socket (decoded size when there is no urllib3 response behind it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 12 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
5 tasks done
2 of 3 tasks
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.
Summary
GET /api/v3/plugins/fetch-statsreported one byte count,bytes, which islen(response.content): the decoded body. That number was read as download volume. ledpi's football scoreboard looked like "643 MB in 6 hours". ESPN gzips every scoreboard, though, so the counter overstated real traffic about 14x.FetchService._sendnow also countswire_bytesin every counter set (totals, per plugin, per host). It reads urllib3'sHTTPResponse.tell(), which is the number of raw bytes taken off the socket before decompression.byteskeeps its meaning.test_every_counter_is_in_every_snapshottest covers the new field automatically.Measured against ESPN on 2026-10-04,
college-football/scoreboard?dates=20261003&limit=500(54 events):gzip, deflate, br(what the plugins send)identityESPN never answers with br, and requests/urllib3 decode gzip, so the 13.7x ratio is what a rig actually saves.
Where football's bytes go (investigation for this PR)
show_favorite_teams_only: false). Its journal for 2026-10-03 has 107–121 live polls an hour from 11:00 to 03:00 ET, with 1–18 FBS games live the whole time, at the configuredlive_update_interval: 30. Each poll is the full day's scoreboard: 865 KB decoded, 63 KB on the wire. That gives 104 MB/h decoded (the 643 MB/6 h) and ~7.6 MB/h on the wire.groups=80returns the same 54 events.status,state,live,enableanddisableparameters are ignored.limit>500truncates to 25 events./scoreboard/headerlists only 16 events.Type of change
Test plan
Two new tests in
test_fetch_service.py:HTTPResponsecarrying gzip, throughHTTPAdapter.build_response) countsbytes= decoded andwire_bytes= gzip size.wire_bytes=len(body), the first test fails.Full suite on Windows against an
origin/main(a74b5a2) baseline worktree: the FAILED/ERROR lists are identical (62 failed + 6 errors, all pre-existing Windows failures). The new run has 8,549 passed against the baseline's 8,547: the two new tests.Tested on ledpi, a real Raspberry Pi with hardware. I deployed
fetch_service.pyonly and ran 1.08 h on Sunday 2026-10-04 (17:10–18:15 ET), with four NFL games live and ledpi's normal plugins. Per hour:bytes(decoded)wire_bytesledpi is back on
mainand its service has been restarted.🤖 Generated with Claude Code