From 3b4d67d7fdf58a823a28fadfc5fd1506283972b5 Mon Sep 17 00:00:00 2001 From: KonstantinosTsitoumis Date: Fri, 7 Nov 2025 23:53:35 +0200 Subject: [PATCH 1/4] deprecate otelhttp DefaultClient --- instrumentation/net/http/otelhttp/client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/instrumentation/net/http/otelhttp/client.go b/instrumentation/net/http/otelhttp/client.go index 521daa25dbf..c0604ff792b 100644 --- a/instrumentation/net/http/otelhttp/client.go +++ b/instrumentation/net/http/otelhttp/client.go @@ -11,6 +11,8 @@ import ( "strings" ) +// Deprecated: This will be deleted in the future. +// // DefaultClient is the default Client and is used by Get, Head, Post and PostForm. // Please be careful of initialization order - for example, if you change // the global propagator, the DefaultClient might still be using the old one. From 1e816d80f5f4beb664e3fb5f9bb2c9109d5a0615 Mon Sep 17 00:00:00 2001 From: KonstantinosTsitoumis Date: Sat, 8 Nov 2025 18:46:45 +0200 Subject: [PATCH 2/4] resolve code review comments --- CHANGELOG.md | 2 ++ instrumentation/net/http/otelhttp/client.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d56c0b70e..325866498f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `WithRouteTag` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` is deprecated. The route is already added automatically for spans. For metrics, the alternative is to use the `WithMetricAttributesFn` option. (#8117) +- `DefaultClient` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/client.go` is deprecated. + Use a custom `*http.Client` with `otelhttp.NewTransport(http.DefaultTransport)` instead. (#8140) ### Removed diff --git a/instrumentation/net/http/otelhttp/client.go b/instrumentation/net/http/otelhttp/client.go index c0604ff792b..1648c266e6a 100644 --- a/instrumentation/net/http/otelhttp/client.go +++ b/instrumentation/net/http/otelhttp/client.go @@ -11,11 +11,13 @@ import ( "strings" ) -// Deprecated: This will be deleted in the future. -// // DefaultClient is the default Client and is used by Get, Head, Post and PostForm. // Please be careful of initialization order - for example, if you change // the global propagator, the DefaultClient might still be using the old one. +// +// Deprecated: DefaultClient will be removed in a future release. +// Create your own *http.Client with Transport = otelhttp.NewTransport(http.DefaultTransport) +// instead of relying on this global variable. var DefaultClient = &http.Client{Transport: NewTransport(http.DefaultTransport)} // Get is a convenient replacement for http.Get that adds a span around the request. From 1a68aff8a4d94457a1b6ade6fac7f7d7e241e2fe Mon Sep 17 00:00:00 2001 From: Konstantinos Tsitoumis <127196125+KonstantinosTsitoumis@users.noreply.github.com> Date: Wed, 12 Nov 2025 19:23:32 +0200 Subject: [PATCH 3/4] Update instrumentation/net/http/otelhttp/client.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Flc゛ --- instrumentation/net/http/otelhttp/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/net/http/otelhttp/client.go b/instrumentation/net/http/otelhttp/client.go index 1648c266e6a..afca01afd99 100644 --- a/instrumentation/net/http/otelhttp/client.go +++ b/instrumentation/net/http/otelhttp/client.go @@ -15,7 +15,7 @@ import ( // Please be careful of initialization order - for example, if you change // the global propagator, the DefaultClient might still be using the old one. // -// Deprecated: DefaultClient will be removed in a future release. +// Deprecated: [DefaultClient] will be removed in a future release. // Create your own *http.Client with Transport = otelhttp.NewTransport(http.DefaultTransport) // instead of relying on this global variable. var DefaultClient = &http.Client{Transport: NewTransport(http.DefaultTransport)} From 29b866996679bd5c5470144f56d934f60c4783ad Mon Sep 17 00:00:00 2001 From: Konstantinos Tsitoumis <127196125+KonstantinosTsitoumis@users.noreply.github.com> Date: Fri, 14 Nov 2025 01:56:16 +0200 Subject: [PATCH 4/4] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Pająk --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 325866498f1..7df3c4292e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `WithRouteTag` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` is deprecated. The route is already added automatically for spans. For metrics, the alternative is to use the `WithMetricAttributesFn` option. (#8117) -- `DefaultClient` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/client.go` is deprecated. +- `DefaultClient` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` is deprecated. Use a custom `*http.Client` with `otelhttp.NewTransport(http.DefaultTransport)` instead. (#8140) ### Removed