proxywhirl.retry.metrics¶
Retry metrics collection and aggregation.
- Thread Safety:
RetryMetrics uses threading.Lock for thread-safe operation in synchronous contexts. When used in async contexts (e.g., FastAPI endpoints), methods that acquire locks should be called using asyncio.to_thread() to prevent blocking the event loop.
- Usage:
- Sync context (RetryExecutor, aggregation thread):
metrics.record_attempt(attempt) metrics.aggregate_hourly()
- Async context (FastAPI endpoints):
summary = await asyncio.to_thread(metrics.get_summary) timeseries = await asyncio.to_thread(metrics.get_timeseries, hours=24)
Classes¶
Circuit breaker state change event. |
|
Hourly aggregated metrics. |
|
Record of a single retry attempt. |
|
Aggregated retry metrics collection. |
|
Outcome of a retry attempt. |
Module Contents¶
- class proxywhirl.retry.metrics.CircuitBreakerEvent(/, **data)[source]¶
Bases:
pydantic.BaseModelCircuit breaker state change event.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class proxywhirl.retry.metrics.HourlyAggregate(/, **data)[source]¶
Bases:
pydantic.BaseModelHourly aggregated metrics.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class proxywhirl.retry.metrics.RetryAttempt(/, **data)[source]¶
Bases:
pydantic.BaseModelRecord of a single retry attempt.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class proxywhirl.retry.metrics.RetryMetrics(**data)[source]¶
Bases:
pydantic.BaseModelAggregated retry metrics collection.
Initialize with maxlen-bounded deque.
- record_attempt(attempt)[source]¶
Record a retry attempt.
- Parameters:
attempt (RetryAttempt)
- Return type:
None
- record_circuit_breaker_event(event)[source]¶
Record circuit breaker state change.
- Parameters:
event (CircuitBreakerEvent)
- Return type:
None