test(debugger): align DI hit-limit test with SDK MaxHits semantics - #782
Conversation
|
Claude finished @liustve's task in 1m 50s —— View job Claude PR Review
Verdict: LGTMThe change correctly aligns the test with the SDK's actual behavior. I verified the SDK at state.hit_count += 1
...
if config and not config.is_permanent and state.hit_count > config.max_hits:
state.is_disabled = True
...
return FalseWith Notes on robustness
No new findings to post inline. |
0dcedb1 to
f5f22ad
Compare
0523b00 to
7fc27f3
Compare
|
Claude finished @liustve's task in 1m 58s —— View job Claude PR Review
Verdict: LGTM — no new findingsCompared to the previously reviewed commit, the only material change in the latest push is bumping Everything else (SDK semantics alignment with Following the dedup guidance, I am not re-posting findings already covered by the earlier review on this PR. |
The SDK's increment_hit_count uses `hit_count > config.max_hits` for the disable check (instrumentation_manager.py:631), so MaxHits=N emits N snapshots and disables on the (N+1)th hit. The DI Flask, FastAPI, and Django hit-limit contract tests expected N-1 snapshots, claiming the check was `>=` in their docstrings and inline comments — neither matched the SDK. The tests were passing on main by accident: BatchLogRecordProcessor's default schedule_delay_millis was 5000ms, so the snapshot emitted on the 3rd hit was still sitting in the batch buffer when the test's 2-second sleep elapsed and read the collector. core 1.41.0 tightened the default to 1000ms (open-telemetry/opentelemetry-python#4998), shrinking the window enough that the 3rd snapshot now lands before the test reads. Fix the tests (and the docstrings on the application's target functions) to match SDK behavior: MaxHits=3 -> 3 snapshots emitted, breakpoint disables on the 4th hit. Send a 4th request to actually probe the disabled state, and widen the disabled-state observation window to 5s so any spurious 4th snapshot has plenty of time to flush before we assert the breakpoint stayed disabled.
7fc27f3 to
d6cb052
Compare
|
Claude finished @liustve's task in 1m 29s —— View job Claude PR Review
Verdict: LGTM — no new findingsThe current head ( For convenience, summary of what's been verified across the prior reviews on this PR:
Per dedup guidance, not re-posting findings already covered by prior reviews. |
Summary
The DI Flask
DIFlaskHitLimitTestand the matching application target function hadMaxHitssemantics flipped relative to the SDK. WithMaxHits=3, the test expected 2 snapshots, claiming the disable check washit_count >= max_hits. The SDK's increment_hit_count actually useshit_count > max_hits, so it emits 3 snapshots and disables on the 4th hit.Why this is surfacing now
The test was passing on main by accident.
BatchLogRecordProcessor's defaultschedule_delay_milliswas 5000ms, so the snapshot emitted on the 3rd hit was still sitting in the batch buffer when the test'stime.sleep(2)elapsed and read the collector. The 3rd snapshot never reached the mock collector within the test's observation window.OpenTelemetry core 1.41.0 tightened that default to 1000ms to comply with the OTel spec, so the upcoming dependency bump to 1.42.1 / 0.63b1 (#762) now sees the 3rd snapshot consistently and the latent off-by-one assertion fails the test.
Changes
MaxHits=3→ 3 snapshots, breakpoint disabled on the 4th hit. Send a 4th request to actually probe the disabled state.limited_functiondocstring in the di-flask sample app to match.Test plan
nightly-dependency-updatesbranch)