Repository navigation
Commit 0dbcce3
chore(octopus): log repeated GraphQL responses and slot lists briefly instead of in full (#5428)
* chore(octopus): log a repeated GraphQL query or response briefly instead 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>
* chore(octopus): log the Intelligent slot list only when it changes, and 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>
* fix(octopus): treat a status 200 with no body or no data as a failure when gating GraphQL logs
A 200 whose body could not be read (unreadable JSON, a KT-CT-1199 rate limit, read retries used up)
or carried no data key still ends in "Failed to retrieve data from graphql query", but the gate treated
it as a success: a repeat logged the request and response as brief lines, so the full request was not
beside the failure. Now any response the function will not return data for is logged in full with its
request, as an errors response already was.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(octopus): gate each skipped Weekend Happy Hour by its event id, not only its code
The hourly gate on "Not offering Weekend Happy Hour" used the event code as its text, so every
Happy Hour with no code hashed the same and only the first was logged each hour. Gate on the
event id with the code, so each event is logged hourly as described.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(octopus): say "same as logged in full at", not "unchanged since", on a brief repeat line
The gate keeps several texts per key, so a response or slot list can change and change back
within the hour (A, B, then A again). The brief line for the third was worded "unchanged since
logged in full at" the time A was logged, which is false: it changed in between. "Same as" is true
in every case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(octopus): count a GraphQL body of data null as a failure for the log gate, and correct its comment
A body of data null with no errors key returns None to the caller, which then reports the query
as failed, but the gate treated it as a success and logged a repeat briefly without the request.
Count a missing or null data value as a failure. The comment also claimed every gated failure
returns no data; a partial error returned with data under ignore_errors is logged in full too,
so say so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(octopus): record the full request logged beside a failure in the log gate
The request re-logged in full beside a failure went straight to the log, so the
gate kept the older full-log time. The next brief line named that older time,
and once the hour ran out from it the request was logged in full again, though
it had been logged in full more recently. Route it through the gate with
always_full so the gate's record matches the log.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(octopus): log a first-attempt 401/403 GraphQL response in full
The first-attempt 401/403 branch either returns (an edge/WAF block) or
retries with a fresh token before reaching the response logger, so the
response body was never logged. Read it once there and log it through the
gate with always_full. A second-attempt 401/403 is not logged here: it reaches
async_read_response_retry, which logs its body.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(octopus): share one helper for the GraphQL response log line
The first-attempt 401/403 path and the normal path each built the same gated
response log call. Move it into one local helper so the format and gate key
cannot drift apart.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(octopus): log the full request once when a token retry also fails
A retry only follows a failure, and that failure has just logged the request
in full. The retry's gate rightly logs the request briefly, pointing at that
line, but its own 401/403 then logged the full request a second time. Skip the
beside-failure re-log on a retry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(octopus): use 'refetch' in the re-log test's query name, which cspell knows
CI's cspell rejected 'relog' in test_octopus_logging.py. Renaming the
test query avoids adding a made-up word to the dictionary.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent dcc6017 commit 0dbcce3
10 files changed
Lines changed: 367 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
| 714 | + | |
| 715 | + | |
714 | 716 | | |
715 | 717 | | |
716 | 718 | | |
| |||
1420 | 1422 | | |
1421 | 1423 | | |
1422 | 1424 | | |
1423 | | - | |
| 1425 | + | |
| 1426 | + | |
1424 | 1427 | | |
1425 | 1428 | | |
1426 | 1429 | | |
| |||
1710 | 1713 | | |
1711 | 1714 | | |
1712 | 1715 | | |
1713 | | - | |
1714 | 1716 | | |
1715 | 1717 | | |
1716 | 1718 | | |
| |||
2392 | 2394 | | |
2393 | 2395 | | |
2394 | 2396 | | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
2395 | 2420 | | |
2396 | 2421 | | |
2397 | 2422 | | |
| |||
2402 | 2427 | | |
2403 | 2428 | | |
2404 | 2429 | | |
2405 | | - | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
2406 | 2433 | | |
2407 | 2434 | | |
2408 | 2435 | | |
2409 | 2436 | | |
2410 | 2437 | | |
2411 | 2438 | | |
| 2439 | + | |
| 2440 | + | |
2412 | 2441 | | |
2413 | 2442 | | |
2414 | 2443 | | |
2415 | 2444 | | |
2416 | 2445 | | |
2417 | 2446 | | |
2418 | 2447 | | |
2419 | | - | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
2420 | 2454 | | |
2421 | 2455 | | |
2422 | 2456 | | |
| |||
2442 | 2476 | | |
2443 | 2477 | | |
2444 | 2478 | | |
2445 | | - | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
2446 | 2486 | | |
2447 | 2487 | | |
2448 | 2488 | | |
| |||
2483 | 2523 | | |
2484 | 2524 | | |
2485 | 2525 | | |
| 2526 | + | |
2486 | 2527 | | |
2487 | 2528 | | |
2488 | 2529 | | |
| |||
3903 | 3944 | | |
3904 | 3945 | | |
3905 | 3946 | | |
| 3947 | + | |
3906 | 3948 | | |
3907 | 3949 | | |
3908 | 3950 | | |
| |||
3997 | 4039 | | |
3998 | 4040 | | |
3999 | 4041 | | |
4000 | | - | |
| 4042 | + | |
4001 | 4043 | | |
4002 | 4044 | | |
4003 | 4045 | | |
4004 | 4046 | | |
4005 | 4047 | | |
| 4048 | + | |
| 4049 | + | |
| 4050 | + | |
| 4051 | + | |
4006 | 4052 | | |
4007 | 4053 | | |
4008 | 4054 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
495 | 497 | | |
496 | 498 | | |
497 | 499 | | |
| 500 | + | |
| 501 | + | |
498 | 502 | | |
499 | 503 | | |
500 | 504 | | |
| |||
0 commit comments