Add more elasticity goodput tests - #4846
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the goodput monitoring and recording logic to safely resolve and fall back to base monitors and recorders when elastic features are disabled or fail to load. It also introduces hasattr checks in elastic_utils.py to prevent errors when interacting with recorders that lack elastic APIs, accompanied by comprehensive unit tests. The reviewer suggested ensuring that both record_elastic_wait_end_time and record_elastic_reinit_start_time are checked before invocation to prevent potential AttributeErrors.
| if recorder and hasattr(recorder, "record_elastic_wait_end_time"): | ||
| recorder.record_elastic_wait_end_time(event_type=event_type) | ||
| recorder.record_elastic_reinit_start_time() | ||
| record_slice_state(recorder) |
There was a problem hiding this comment.
To ensure robust defensive programming, we should verify that the recorder implements both record_elastic_wait_end_time and record_elastic_reinit_start_time before calling them. Currently, we only check for the presence of record_elastic_wait_end_time, which could lead to an AttributeError if a custom or mock recorder only implements one of the methods.
| if recorder and hasattr(recorder, "record_elastic_wait_end_time"): | |
| recorder.record_elastic_wait_end_time(event_type=event_type) | |
| recorder.record_elastic_reinit_start_time() | |
| record_slice_state(recorder) | |
| if ( | |
| recorder | |
| and hasattr(recorder, "record_elastic_wait_end_time") | |
| and hasattr(recorder, "record_elastic_reinit_start_time") | |
| ): | |
| recorder.record_elastic_wait_end_time(event_type=event_type) | |
| recorder.record_elastic_reinit_start_time() | |
| record_slice_state(recorder) |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
This PR adds:
Tests
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.