Repository navigation
chore(octopus): log repeated GraphQL responses and slot lists briefly instead of in full - #5428
Open
chalfontchubby wants to merge 2 commits into
Open
chalfontchubby wants to merge 2 commits into
chalfontchubby wants to merge 2 commits into
Conversation
…ead of in full The Octopus GraphQL logging was about 30% of a typical log: every request logged its fixed query text and every response its full body, poll after poll, and the saving sessions response (about 22 KB) was then logged a second time as "Fetched saving sessions data". Now a request or response already logged in full within the hour is logged as one line saying when it was last logged in full, and is logged in full again at least hourly so the full text is never only in a rotated-out log file. The duplicate saving sessions line is dropped. The decision is a new RepeatLogGate (utils.py): it keeps only a hash of each text per key, so several queries sharing one request context (one per Intelligent device) each keep their own entry, and drops entries older than the interval so its memory stays bounded. An error response is always logged in full, with the request that caused it. The JWT stays redacted on every line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd each Happy Hour skip hourly The slot list (about 16 lines) was logged on every plan though it rarely changes; it now goes through the same RepeatLogGate, logged in full when it changes and at least hourly, and as one line saying when it was last logged in full otherwise. Tariff comparison runs, whose slot prices differ, keep their own entries rather than forcing the live list to be logged again. An empty list is not logged, as before. The "Not offering Weekend Happy Hour" line is logged once an hour per event code rather than on every poll of the event list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
On a live system with an Octopus account, about 40% of
predbat.logwas the same text logged again and again. The biggest single item was the saving sessions GraphQL response, about 22 KB, logged in full on every poll and then a second time as "Fetched saving sessions data". This logs a repeat as one short line instead, without losing anything.The decision is one small class,
RepeatLogGate(utils.py). For each key it keeps a hash of each text logged in full, not the text itself, so:The JWT stays redacted on every line.
Not changed
write_and_poll ... No write needed, which shows the control is being checked.Changes
apps/predbat/utils.py:RepeatLogGate.apps/predbat/const.py:REPEAT_FULL_LOG_SECONDS(3600).apps/predbat/octopus.py: the GraphQL logging, the slot list and the Happy Hour line go through the gate.apps/predbat/predbat.py: the slot-list gate inreset().docs/components.md: theget_logexample line no longer quotes the dropped line.test_octopus_logging(repeat, change, hourly re-log, two queries per context, errors, the gate itself, token redaction),test_rate_add_io_slots(slot list),test_octopus_saving_event_type(Happy Hour, including an event with no code), andtest_web_mcp(fixture line).Test plan
🤖 Generated with Claude Code