API: Window¶
이 페이지는 사용 가능한 Window를 문서화합니다. Window는 최근 호출에 대한 Metric을 저장하고 제공하는 역할을 합니다.
Window 선택에 대한 개요는 Windows 컴포넌트 가이드를 참조하십시오.
fluxgate.windows.CountWindow
¶
CountWindow(size: int)
Bases: Window
Count-based sliding window for tracking recent call metrics.
Maintains a fixed-size sliding window that keeps the most recent N calls. When the window is full, the oldest record is evicted when a new one arrives.
Per-threshold slow-call counters are populated from record.slow_at — the
set of thresholds the call exceeded, decided by the producer (typically
the circuit breaker). The window itself does not need to know which
thresholds are active.
Examples:
>>> window = CountWindow(size=100)
>>> window.record(Record(success=True, duration=0.5, slow_at=()))
>>> metric = window.get_metric()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Maximum number of calls to track in the window |
required |
Source code in fluxgate/windows.py
47 48 49 | |
record
¶
record(record: Record) -> None
Source code in fluxgate/windows.py
51 52 53 54 55 56 | |
get_metric
¶
get_metric() -> Metric
Source code in fluxgate/windows.py
58 59 | |
reset
¶
reset() -> None
Source code in fluxgate/windows.py
61 62 63 | |
fluxgate.windows.TimeWindow
¶
TimeWindow(size: int)
Bases: Window
Time-based sliding window for tracking metrics over a time period.
Divides time into fixed buckets (1 second each) and tracks metrics per bucket. When a bucket's time period expires, it is reset and reused for the new time.
Per-threshold slow-call counters are populated from record.slow_at, just
like CountWindow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Number of seconds to track (window size in seconds) |
required |
Note
Time precision is 1 second. All calls within the same second are grouped into the same bucket.
Source code in fluxgate/windows.py
83 84 85 | |
record
¶
record(record: Record) -> None
Source code in fluxgate/windows.py
87 88 89 90 91 92 93 94 95 96 97 98 | |
get_metric
¶
get_metric() -> Metric
Source code in fluxgate/windows.py
100 101 | |
reset
¶
reset() -> None
Source code in fluxgate/windows.py
103 104 105 106 | |