plesty.server.model.traffic
What a device server served, read back out of its log.
The console is a different process from the device server, so it cannot watch the wire directly. plesty-lib writes one record per served request to the server log — what was asked, of what, by whom, how it ended and how long it took — and this reads them back. No new transport and no wire-format change: the log is the one channel the console already tails.
The history therefore reaches back exactly as far as the log does. A server running an older plesty-lib writes no records at all, which is not an error — it is a bench that has not been upgraded, and the pane says so rather than looking broken.
Attributes
Classes
One served request, as the server reported it. |
Functions
|
Every traffic record in text, oldest first. |
|
value as a float, or |
Module Contents
- plesty.server.model.traffic.MARKER = '[TRAFFIC]'
- class plesty.server.model.traffic.TrafficRecord
One served request, as the server reported it.
- Variables:
when – The log line’s own prefix, verbatim;
""when it had none.type – Request type —
call,write,query,connect…target – What it acted on: a function or parameter name, or
"".client – Which client asked.
outcome –
okorerror.ms – How long the server took, in milliseconds.
delivered – Whether the reply reached the client.
error – Exception type when outcome is not
ok, else"".
- when: str
- type: str
- target: str
- client: str
- outcome: str
- ms: float
- delivered: bool
- error: str
- property ok: bool
Whether this exchange both succeeded and arrived.
- Return type:
bool
- property note: str
The one thing a reader needs to see about a record that is not plain.
- Return type:
str
- plesty.server.model.traffic.parse_traffic(text: str) list[TrafficRecord]
Every traffic record in text, oldest first.
Tolerant by design: a log holds ordinary server lines, and a truncated tail can begin mid-line. Anything that is not a well-formed record is skipped rather than raising — a monitor that refuses a damaged log shows nothing exactly when something is wrong.
- Parameters:
text (str) – A slice of a server log.
- Return type:
list[TrafficRecord]
- plesty.server.model.traffic._float(value: object) float
value as a float, or
0.0— a bad latency must not lose the record.- Parameters:
value (object)
- Return type:
float