Classes
ConnectionOpened
8
▼
A new TCP connection was accepted.
ConnectionOpened
8
▼
A new TCP connection was accepted.
Attributes
| Name | Type | Description |
|---|---|---|
connection_id |
int
|
— |
worker_id |
int
|
— |
client_addr |
str
|
— |
client_port |
int
|
— |
server_addr |
str
|
— |
server_port |
int
|
— |
protocol |
str
|
— |
timestamp_ns |
int
|
— |
RequestStarted
6
▼
An HTTP request head was fully parsed.
RequestStarted
6
▼
An HTTP request head was fully parsed.
Attributes
| Name | Type | Description |
|---|---|---|
connection_id |
int
|
— |
worker_id |
int
|
— |
method |
str
|
— |
path |
str
|
— |
http_version |
str
|
— |
timestamp_ns |
int
|
— |
ResponseCompleted
6
▼
An HTTP response was fully sent.
ResponseCompleted
6
▼
An HTTP response was fully sent.
Attributes
| Name | Type | Description |
|---|---|---|
connection_id |
int
|
— |
worker_id |
int
|
— |
status |
int
|
— |
bytes_sent |
int
|
— |
duration_ms |
float
|
— |
timestamp_ns |
int
|
— |
ClientDisconnected
4
▼
The client closed the connection unexpectedly.
ClientDisconnected
4
▼
The client closed the connection unexpectedly.
Attributes
| Name | Type | Description |
|---|---|---|
connection_id |
int
|
— |
worker_id |
int
|
— |
during_streaming |
bool
|
— |
timestamp_ns |
int
|
— |
ConnectionClosed
7
▼
The TCP connection was closed (by either side).
ConnectionClosed
7
▼
The TCP connection was closed (by either side).
Attributes
| Name | Type | Description |
|---|---|---|
connection_id |
int
|
— |
worker_id |
int
|
— |
requests_served |
int
|
— |
total_bytes_sent |
int
|
— |
duration_ms |
float
|
— |
reason |
str
|
— |
timestamp_ns |
int
|
— |
LifecycleCollector
1
▼
Interface for consuming lifecycle events.
Implementations must be thread-safe — in free-threading …
LifecycleCollector
1
▼
Interface for consuming lifecycle events.
Implementations must be thread-safe — in free-threading mode,
multiple workers (threads) will callrecord()concurrently.
Methods
record
1
▼
Record a lifecycle event.
record
1
▼
def record(self, event: LifecycleEvent) -> None
Parameters
| Name | Type | Description |
|---|---|---|
event |
— |
NoopCollector
1
▼
Default collector — discards all events.
Zero overhead: the ``record()`` method is an empty functi…
NoopCollector
1
▼
Default collector — discards all events.
Zero overhead: therecord()method is an empty function body.
Used when no observability is configured.
Methods
record
1
▼
Discard the event.
record
1
▼
def record(self, event: LifecycleEvent) -> None
Parameters
| Name | Type | Description |
|---|---|---|
event |
— |
BufferedCollector
5
▼
Thread-safe collector that buffers events for batch processing.
Events accumulate in an internal l…
BufferedCollector
5
▼
Thread-safe collector that buffers events for batch processing.
Events accumulate in an internal list. Callflush()to retrieve
and clear the buffer, or register anon_flushcallback for
automatic batch processing.
Thread-safe viathreading.Lock— safe for free-threading mode
where multiple worker threads produce events concurrently.
Methods
record
1
▼
Append an event to the buffer.
If ``max_buffer_size`` is set and reached, the …
record
1
▼
def record(self, event: LifecycleEvent) -> None
Append an event to the buffer.
Ifmax_buffer_sizeis set and reached, the buffer is
automatically flushed.
Parameters
| Name | Type | Description |
|---|---|---|
event |
— |
flush
0
list[LifecycleEvent]
▼
Retrieve and clear the buffered events.
flush
0
list[LifecycleEvent]
▼
def flush(self) -> list[LifecycleEvent]
Returns
list[LifecycleEvent]
List of events accumulated since the last flush.
Internal Methods 3 ▼
__init__
2
▼
__init__
2
▼
def __init__(self, *, max_buffer_size: int = 0, on_flush: Callable[[list[LifecycleEvent]], None] | None = None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
max_buffer_size |
— |
Default:0
|
on_flush |
— |
Default:None
|
_flush_locked
0
list[LifecycleEvent]
▼
Flush the buffer while holding the lock. Returns the batch.
_flush_locked
0
list[LifecycleEvent]
▼
def _flush_locked(self) -> list[LifecycleEvent]
Returns
list[LifecycleEvent]
__len__
0
int
▼
__len__
0
int
▼
def __len__(self) -> int
Returns
int
Functions
next_connection_id
0
int
▼
Return a globally unique, monotonically increasing connection ID.
Thread-safe …
next_connection_id
0
int
▼
def next_connection_id() -> int
Return a globally unique, monotonically increasing connection ID.
Thread-safe — uses a lock for correctness under free-threading.
Returns
int
monotonic_ns
0
int
▼
Return the current monotonic clock value in nanoseconds.
monotonic_ns
0
int
▼
def monotonic_ns() -> int
Returns
int