Skip to content

[Bug]: false positive errors in otelhttptrace for http.receive span #8216

@mitioshi

Description

@mitioshi

Component

Instrumentation: otelhttptrace

Describe the issue you're facing

We use httptrace for our http client. Very frequently we observe traces being marked as "error" due to "http: putIdleConn: too many idle connections for host" in the http.receive span.

This error is a part of an internal mechanism in net/http to pool http connections.
Transport keeps a per-host pool of idle keep-alive sockets.
In tryPutIdleConn, after a request finishes, the connection is returned to that pool. If the pool already holds MaxIdleConnsPerHost entries (default 2 if you don’t override it), the function returns errTooManyIdleHost, and the connection is immediately closed instead of being cached.

Expected behavior

This is not a client issue and not even an error(just a part of the pooling flow) and shouldn't mark traces as erroring

Steps to Reproduce

  1. Start a basic Go program with an http.Client using otelhhtp
	client := http.DefaultClient
	client.Transport = otelhttp.NewTransport(
			http.DefaultTransport,
			otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {
				return otelhttptrace.NewClientTrace(ctx)
			}))
  1. In a loop, make requests to a backend on another socket. Ensure the rate of in-flight requests is >2 (default per-host concurrency of http.Transport)
  2. Observe the exported traces. Many requests should be flagged as "error"

Operating System

Debian Linux

Device Architecture

x86_64

Go Version

1.23.0

Component Version

v0.60.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions