Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[otelhttp] Data race warning causing test failures in Bitbucket pipelines #5140

Closed
BeautifuLie opened this issue Feb 23, 2024 · 1 comment
Closed
Labels
area: instrumentation Related to an instrumentation package bug Something isn't working instrumentation: otelhttp

Comments

@BeautifuLie
Copy link

Description

During test execution in Bitbucket pipelines, a data race warning occurs when using otelhttp.NewTransport as the transport mechanism in the HTTP client and calling the Do() method from the standard Go "net/http" library. This warning leads to test failures in Bitbucket pipelines.This warning does not always appear, about 7 out of 10 times during test runs.

==================
WARNING: DATA RACE
Write at 0x00c00027e498 by goroutine 64:
  go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.(*bodyWrapper).Read()
      /go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@v0.48.0/wrap.go:40 +0x9c
  io.discard.ReadFrom()
      /usr/local/go/src/io/io.go:666 +0x91
  io.(*discard).ReadFrom()
      <autogenerated>:1 +0x4c
  io.copyBuffer()
      /usr/local/go/src/io/io.go:415 +0x22e
  io.CopyBuffer()
      /usr/local/go/src/io/io.go:402 +0x8f
  net/http.(*transferWriter).doBodyCopy()
      /usr/local/go/src/net/http/transfer.go:416 +0x144
  net/http.(*transferWriter).writeBody()
      /usr/local/go/src/net/http/transfer.go:376 +0x7ac
  net/http.(*Request).write()
      /usr/local/go/src/net/http/request.go:755 +0x1413
  net/http.(*persistConn).writeLoop()
      /usr/local/go/src/net/http/transport.go:2446 +0x379
  net/http.(*Transport).dialConn.gowrap3()
      /usr/local/go/src/net/http/transport.go:1799 +0x33
Previous read at 0x00c00027e498 by goroutine 58:
  go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp.(*Transport).RoundTrip()
      /go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp@v0.48.0/transport.go:185 +0xfa4
  net/http.send()
      /usr/local/go/src/net/http/client.go:259 +0x9a6
  net/http.(*Client).send()
      /usr/local/go/src/net/http/client.go:180 +0x14e
  net/http.(*Client).do()
      /usr/local/go/src/net/http/client.go:724 +0x11c8
  net/http.(*Client).Do()
      /usr/local/go/src/net/http/client.go:590 +0x464
....
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      /usr/local/go/src/testing/testing.go:1742 +0x44
Goroutine 64 (running) created at:
  net/http.(*Transport).dialConn()
      /usr/local/go/src/net/http/transport.go:1799 +0x27fe
  net/http.(*Transport).dialConnFor()
      /usr/local/go/src/net/http/transport.go:1484 +0x124
  net/http.(*Transport).queueForDial.gowrap1()
      /usr/local/go/src/net/http/transport.go:1449 +0x44

Environment

  • OS: [LINUX]
  • Architecture: [amd64]
  • Go Version: [1.21]
  • otelhttp version: [v0.48.0]

Steps To Reproduce

1.Run the tests where otelhttp.NewTransport is used as the transport mechanism in the HTTP client.

httpClient := http.Client{
		Transport: otelhttp.NewTransport(http.DefaultTransport),
	}

2.Observe the data race warning that may occur when calling the Do() method of the HTTP client from the standard Go "net/http" library.
resp, err := httpClient.Do(req)

Note that this warning does not occur consistently but rather approximately 7 out of 10 times during test runs.

Expected behavior

The golang race detector shouldn't give a race report when using otelhttp.

@BeautifuLie BeautifuLie added area: instrumentation Related to an instrumentation package bug Something isn't working instrumentation: otelhttp labels Feb 23, 2024
@dmathieu
Copy link
Member

Duplicate of #4895 that will be fixed with the next release.

@dmathieu dmathieu closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: instrumentation Related to an instrumentation package bug Something isn't working instrumentation: otelhttp
Projects
None yet
Development

No branches or pull requests

2 participants