plesty.server.model.traffic =========================== .. py:module:: plesty.server.model.traffic .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: plesty.server.model.traffic.MARKER Classes ------- .. autoapisummary:: plesty.server.model.traffic.TrafficRecord Functions --------- .. autoapisummary:: plesty.server.model.traffic.parse_traffic plesty.server.model.traffic._float Module Contents --------------- .. py:data:: MARKER :value: '[TRAFFIC]' .. py:class:: TrafficRecord One served request, as the server reported it. :ivar when: The log line's own prefix, verbatim; ``""`` when it had none. :ivar type: Request type — ``call``, ``write``, ``query``, ``connect``… :ivar target: What it acted on: a function or parameter name, or ``""``. :ivar client: Which client asked. :ivar outcome: ``ok`` or ``error``. :ivar ms: How long the server took, in milliseconds. :ivar delivered: Whether the reply reached the client. :ivar error: Exception type when *outcome* is not ``ok``, else ``""``. .. py:attribute:: when :type: str .. py:attribute:: type :type: str .. py:attribute:: target :type: str .. py:attribute:: client :type: str .. py:attribute:: outcome :type: str .. py:attribute:: ms :type: float .. py:attribute:: delivered :type: bool .. py:attribute:: error :type: str .. py:property:: ok :type: bool Whether this exchange both succeeded and arrived. .. py:property:: note :type: str The one thing a reader needs to see about a record that is not plain. .. py:function:: 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. :param text: A slice of a server log. .. py:function:: _float(value: object) -> float *value* as a float, or ``0.0`` — a bad latency must not lose the record.