diff --git a/CHANGELOG.md b/CHANGELOG.md index 605d7dba8f6..e726ca298ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,8 +32,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` is deprecated. - Use a custom `*http.Client` with `otelhttp.NewTransport(http.DefaultTransport)` instead. (#8140) +- `DefaultClient`, `Get`, `Head`, `Post`, and `PostForm` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` are deprecated. + Use a custom `*http.Client` with `otelhttp.NewTransport(http.DefaultTransport)` instead. (#8140, #8201) ### Removed diff --git a/instrumentation/net/http/otelhttp/client.go b/instrumentation/net/http/otelhttp/client.go index afca01afd99..e980ab62b85 100644 --- a/instrumentation/net/http/otelhttp/client.go +++ b/instrumentation/net/http/otelhttp/client.go @@ -16,11 +16,13 @@ import ( // 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. +// Create your own [http.Client] based on the [Transport] example: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#example-NewTransport var DefaultClient = &http.Client{Transport: NewTransport(http.DefaultTransport)} // Get is a convenient replacement for http.Get that adds a span around the request. +// +// Deprecated: [Get] will be removed in a future release. +// Create your own [http.Client] based on the [Transport] example: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#example-NewTransport func Get(ctx context.Context, targetURL string) (resp *http.Response, err error) { req, err := http.NewRequestWithContext(ctx, http.MethodGet, targetURL, http.NoBody) if err != nil { @@ -30,6 +32,9 @@ func Get(ctx context.Context, targetURL string) (resp *http.Response, err error) } // Head is a convenient replacement for http.Head that adds a span around the request. +// +// Deprecated: [Head] will be removed in a future release. +// Create your own [http.Client] based on the [Transport] example: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#example-NewTransport func Head(ctx context.Context, targetURL string) (resp *http.Response, err error) { req, err := http.NewRequestWithContext(ctx, http.MethodHead, targetURL, http.NoBody) if err != nil { @@ -39,6 +44,9 @@ func Head(ctx context.Context, targetURL string) (resp *http.Response, err error } // Post is a convenient replacement for http.Post that adds a span around the request. +// +// Deprecated: [Post] will be removed in a future release. +// Create your own [http.Client] based on the [Transport] example: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#example-NewTransport func Post(ctx context.Context, targetURL, contentType string, body io.Reader) (resp *http.Response, err error) { req, err := http.NewRequestWithContext(ctx, http.MethodPost, targetURL, body) if err != nil { @@ -49,6 +57,9 @@ func Post(ctx context.Context, targetURL, contentType string, body io.Reader) (r } // PostForm is a convenient replacement for http.PostForm that adds a span around the request. +// +// Deprecated: [PostForm] will be removed in a future release. +// Create your own [http.Client] based on the [Transport] example: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#example-NewTransport func PostForm(ctx context.Context, targetURL string, data url.Values) (resp *http.Response, err error) { return Post(ctx, targetURL, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) }