@@ -65,7 +65,7 @@ def __init__(
65
65
max_client_errors : int ,
66
66
max_memory_size : ByteSize ,
67
67
) -> None :
68
- """A default constructor .
68
+ """Initialize a new instance .
69
69
70
70
In most cases, you should use the `from_config` constructor to create a new instance based on
71
71
the provided configuration.
@@ -102,7 +102,7 @@ def __init__(
102
102
103
103
@classmethod
104
104
def from_config (cls , config : Configuration | None = None ) -> Snapshotter :
105
- """Create a new instance based on the provided `Configuration`.
105
+ """Initialize a new instance based on the provided `Configuration`.
106
106
107
107
Args:
108
108
config: The `Configuration` instance. Uses the global (default) one if not provided.
@@ -136,7 +136,7 @@ def active(self) -> bool:
136
136
return self ._active
137
137
138
138
async def __aenter__ (self ) -> Snapshotter :
139
- """Starts capturing snapshots at configured intervals.
139
+ """Start capturing snapshots at configured intervals.
140
140
141
141
Raises:
142
142
RuntimeError: If the context manager is already active.
@@ -158,7 +158,7 @@ async def __aexit__(
158
158
exc_value : BaseException | None ,
159
159
exc_traceback : TracebackType | None ,
160
160
) -> None :
161
- """Stops all resource capturing.
161
+ """Stop all resource capturing.
162
162
163
163
This method stops capturing snapshots of system resources (CPU, memory, event loop, and client information).
164
164
It should be called to terminate resource capturing when it is no longer needed.
@@ -241,7 +241,7 @@ def _get_sample(snapshots: list[Snapshot], duration: timedelta | None = None) ->
241
241
return [snapshot for snapshot in snapshots if latest_time - snapshot .created_at <= duration ]
242
242
243
243
def _snapshot_cpu (self , event_data : EventSystemInfoData ) -> None :
244
- """Captures a snapshot of the current CPU usage.
244
+ """Capture a snapshot of the current CPU usage.
245
245
246
246
This method does not perform CPU usage measurement. Instead, it just reads the data received through
247
247
the `event_data` parameter, which is expected to be supplied by the event manager.
@@ -260,7 +260,7 @@ def _snapshot_cpu(self, event_data: EventSystemInfoData) -> None:
260
260
self ._cpu_snapshots .add (snapshot )
261
261
262
262
def _snapshot_memory (self , event_data : EventSystemInfoData ) -> None :
263
- """Captures a snapshot of the current memory usage.
263
+ """Capture a snapshot of the current memory usage.
264
264
265
265
This method does not perform memory usage measurement. Instead, it just reads the data received through
266
266
the `event_data` parameter, which is expected to be supplied by the event manager.
@@ -281,7 +281,7 @@ def _snapshot_memory(self, event_data: EventSystemInfoData) -> None:
281
281
self ._evaluate_memory_load (event_data .memory_info .current_size , event_data .memory_info .created_at )
282
282
283
283
def _snapshot_event_loop (self ) -> None :
284
- """Captures a snapshot of the current event loop usage.
284
+ """Capture a snapshot of the current event loop usage.
285
285
286
286
This method evaluates the event loop's latency by comparing the expected time between snapshots to the actual
287
287
time elapsed since the last snapshot. The delay in the snapshot reflects the time deviation due to event loop
@@ -300,7 +300,7 @@ def _snapshot_event_loop(self) -> None:
300
300
self ._event_loop_snapshots .add (snapshot )
301
301
302
302
def _snapshot_client (self ) -> None :
303
- """Captures a snapshot of the current API state by checking for rate limit errors (HTTP 429).
303
+ """Capture a snapshot of the current API state by checking for rate limit errors (HTTP 429).
304
304
305
305
Only errors produced by a 2nd retry of the API call are considered for snapshotting since earlier errors may
306
306
just be caused by a random spike in the number of requests and do not necessarily signify API overloading.
@@ -317,7 +317,7 @@ def _snapshot_client(self) -> None:
317
317
self ._client_snapshots .add (snapshot )
318
318
319
319
def _prune_snapshots (self , snapshots : list [Snapshot ], now : datetime ) -> None :
320
- """Removes snapshots that are older than the `self._snapshot_history`.
320
+ """Remove snapshots that are older than the `self._snapshot_history`.
321
321
322
322
This method modifies the list of snapshots in place, removing all snapshots that are older than the defined
323
323
snapshot history relative to the `now` parameter.
@@ -342,7 +342,7 @@ def _prune_snapshots(self, snapshots: list[Snapshot], now: datetime) -> None:
342
342
snapshots .clear ()
343
343
344
344
def _evaluate_memory_load (self , current_memory_usage_size : ByteSize , snapshot_timestamp : datetime ) -> None :
345
- """Evaluates and logs critical memory load conditions based on the system information.
345
+ """Evaluate and logs critical memory load conditions based on the system information.
346
346
347
347
Args:
348
348
current_memory_usage_size: The current memory usage.
0 commit comments