Skip to content

Add HTTP span events for network phases breakdownΒ #2827

@surbhiia

Description

@surbhiia

Area(s)

area:http

What's missing?

Currently, OpenTelemetry Client HTTP instrumentations (such as OkHttp3) do not capture granular network phase timing, missing critical timed events like DNS resolution start/end, TLS handshake start/end, and TCP connection establishment start/end timestamps. When captured as span events, this detailed timing data would enable observability backends to identify specific performance bottlenecks (DNS latency, TLS negotiation delays, connection issues) within individual HTTP requests and implement their own metric aggregation strategies (P95 DNS time, TLS success rates etc) tailored to their analytical needs. OpenTelemetry's existing metric signals cannot address these requirements due to their aggregated nature and inability to preserve request-level timing correlation.

Describe the solution you'd like

Capture the relevant events as span events.

Proposing event names (as per naming guidelines) to be captured as span events for client HTTP spans (Span name and timestamp matters the most, no additional attributes needed as span attributes are enough)

Event Name Description Timing Phase Required
http.dns.start DNS resolution begins Network Setup Optional
http.dns.end DNS resolution completes Network Setup Optional
http.connection.start TCP connection establishment begins Connection Phase Optional
http.connection.end TCP connection establishment completes Connection Phase Optional
http.tls.start TLS handshake begins (HTTPS only) Security Phase Optional
http.tls.end TLS handshake completes (HTTPS only) Security Phase Optional
http.request.header.start Request headers transmission begins Request Phase Optional
http.request.header.end Request headers transmission completes Request Phase Optional
http.request.body.start Request body upload begins Request Phase Optional
http.request.body.end Request body upload completes Request Phase Optional
http.response.header.start Response headers reception begins Response Phase Optional
http.response.header.end Response headers reception completes Response Phase Optional
http.response.body.start Response body download begins Response Phase Optional
http.response.body.end Response body download completes Response Phase Optional

Example metrics / granular breakdown per request that these events help observability backends gather:

Metrics Calculation
DNS Resolution Duration http.dns.end.timestamp - http.dns.start.timestamp
TCP Connection Duration http.connection.end.timestamp - http.connection.start.timestamp
TLS Handshake Duration http.tls.end.timestamp - http.tls.start.timestamp
Network Setup Duration http.connection.end.timestamp - http.dns.start.timestamp
Request Header Transmission Duration http.request.header.end.timestamp - http.request.header.start.timestamp
Request Body Upload Duration http.request.body.end.timestamp - http.request.body.start.timestamp
Total Request Transmission Duration http.request.body.end.timestamp - http.request.header.start.timestamp
Response Header Reception Duration http.response.header.end.timestamp - http.response.header.start.timestamp
Response Body Download Duration http.response.body.end.timestamp - http.response.body.start.timestamp
Total Response Reception Duration http.response.body.end.timestamp - http.response.header.start.timestamp
Total Network Transfer Duration http.response.body.end.timestamp - http.request.header.start.timestamp
Time to First Byte (TTFB) / Server Processing Duration http.response.header.start.timestamp - http.request.body.end.timestamp
Time to Last Byte (TTLB) http.response.body.end.timestamp - http.request.body.end.timestamp

Tip

React with πŸ‘ to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Need triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions