Repository navigation
Tags: Stephenson-Software/trace-client-python
Tags
Make close() send what is queued, bounded by the timeout close() discarded anything still queued and only waited for a request in flight. A program that reports and then exits within milliseconds -- a CLI, a short script -- lost its one event to the race between queueing it and the sender thread picking it up: measured at 7 of 30 runs by the first consumer to hit it (reeve). The bound the client promises still holds: an unreachable server delays exit by at most the timeout, never a hang. close() now enqueues its stop sentinel BEHIND whatever is queued and joins the sender for up to the timeout, so queued reports are sent first. If the queue is full (256 waiting), the oldest is dropped to make room for the sentinel. Two tests: 30 back-to-back report()+close() pairs all deliver (fails 30 != 0 against 0.1.0), and close() against a server that never answers still returns within the timeout. 0.1.1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYoD9SsaRz8PjakTSHhmn6
Add the trace client for Python: one call, one file, no dependencies,… … 3.8+ The Python counterpart of trace-client-java, speaking the same wire format and making the same promises. One class: TraceClient(base_url, application, key=, enabled=) and report(name, value=None, tags=None). Every report returns immediately -- the HTTP call runs on one daemon thread the client owns -- never raises, and the queue in front of that thread is bounded at 256 so an unreachable server cannot grow the host's memory. No key, or enabled=False, yields a no-op client: the opt-out a program running on someone else's machine has to be able to offer. Standard library only (urllib, queue, threading, json) so the file can be vendored as is. Tests drive the client against ThreadingHTTPServer on a loopback port: request shape, value and tag encoding, return-before-answer against a server that never replies, no exception when nothing listens or the key is rejected, the disabled paths, the queue bound measured by counting drops after a 3x-capacity flood, and prompt idempotent close(). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYoD9SsaRz8PjakTSHhmn6