Skip to content

Commit 6be0ad1

Browse files
KonstantinosTsitoumisflc1125pellareddmathieu
authored
otelhttp: Deprecate DefaultClient (#8140)
Co-authored-by: Flc゛ <[email protected]> Co-authored-by: Robert Pająk <[email protected]> Co-authored-by: Damien Mathieu <[email protected]>
1 parent 66175c1 commit 6be0ad1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
3232
- `WithRouteTag` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` is deprecated.
3333
The route is already added automatically for spans.
3434
For metrics, the alternative is to use the `WithMetricAttributesFn` option. (#8117)
35+
- `DefaultClient` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` is deprecated.
36+
Use a custom `*http.Client` with `otelhttp.NewTransport(http.DefaultTransport)` instead. (#8140)
3537

3638
### Removed
3739

instrumentation/net/http/otelhttp/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import (
1414
// DefaultClient is the default Client and is used by Get, Head, Post and PostForm.
1515
// Please be careful of initialization order - for example, if you change
1616
// the global propagator, the DefaultClient might still be using the old one.
17+
//
18+
// Deprecated: [DefaultClient] will be removed in a future release.
19+
// Create your own *http.Client with Transport = otelhttp.NewTransport(http.DefaultTransport)
20+
// instead of relying on this global variable.
1721
var DefaultClient = &http.Client{Transport: NewTransport(http.DefaultTransport)}
1822

1923
// Get is a convenient replacement for http.Get that adds a span around the request.

0 commit comments

Comments
 (0)