API: Trackers¶
This page documents the available failure tracking strategies. Trackers are responsible for inspecting exceptions to determine if they should be counted as a failure.
For a high-level guide on choosing a tracker, see the Trackers Component Guide.
fluxgate.trackers.All
¶
Bases: TrackerBase
Tracker that matches all exceptions.
Always returns true for any exception, tracking all failures.
Examples:
>>> # Track all exceptions
>>> tracker = All()
>>>
>>> # Track all except ValueError
>>> tracker = All() & ~TypeOf(ValueError)
Note
This is the default behavior when you want to track all exceptions.
__call__
¶
__call__(_exception: Exception) -> bool
Source code in fluxgate/trackers.py
92 93 | |
fluxgate.trackers.TypeOf
¶
TypeOf(*types: type[Exception])
Bases: TrackerBase
Tracker that matches exceptions by type.
Returns true if the exception is an instance of any of the specified types.
Examples:
>>> # Track connection and timeout errors
>>> tracker = TypeOf(ConnectionError, TimeoutError)
>>>
>>> # Combine with OR
>>> tracker = TypeOf(ValueError) | TypeOf(TypeError)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*types
|
type[Exception]
|
Exception types to track as failures |
()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no exception types are provided |
Source code in fluxgate/trackers.py
115 116 117 118 | |
__call__
¶
__call__(exception: Exception) -> bool
Source code in fluxgate/trackers.py
120 121 | |
fluxgate.trackers.Custom
¶
Custom(func: Callable[[Exception], bool])
Bases: TrackerBase
Tracker with custom exception matching logic.
Allows arbitrary logic to determine if an exception should be tracked.
Examples:
>>> # Track only 503 errors from httpx
>>> def is_503(e):
... return isinstance(e, httpx.HTTPStatusError) and e.response.status_code == 503
>>>
>>> tracker = Custom(is_503)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[[Exception], bool]
|
Function that takes an exception and returns bool |
required |
Source code in fluxgate/trackers.py
140 141 | |
__call__
¶
__call__(exception: Exception) -> bool
Source code in fluxgate/trackers.py
143 144 | |