A walkthrough of building httptrace-rs, a Rust crate that provides per-phase HTTP timing (DNS, TCP, TLS, server processing) similar to Go's net/http/httptrace. Since Rust lacks a context propagation mechanism equivalent to Go's context.Context, the crate takes an explicit ClientTrace argument. Two entry points are provided: trace_request for single-request lifecycle ownership with precise per-phase timing, and TracedConnector, a Tower Service for use with hyper_util's legacy client that instruments the connector layer but loses visibility into connection reuse. The post details the design tradeoffs, including how connection pooling in hyper_util means TracedConnector callbacks only fire on fresh connections, unlike Go's GotConnInfo.Reused flag.

7m read timeFrom blainsmith.com
Post cover image
Table of contents
No Context to Piggyback OnBuilding trace_requestBuilding TracedConnectorWhat Pooling Costs YouUsing It
31.6K Impressions1 Comment