From 46f546dc03e7b7b578d1022bfb3132bc0edf22a7 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Mon, 8 Dec 2025 13:49:03 -0800 Subject: [PATCH 1/3] Remove the dep WithPublicEndpoint from otelhttp --- CHANGELOG.md | 5 +++++ instrumentation/net/http/otelhttp/config.go | 12 ------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be57bd589ac..431426a9698 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Removed + +- The deprecated `WithPublicEndpoint` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. + Use `WithPublicEndpointFn` instead. (#TBD) + diff --git a/instrumentation/net/http/otelhttp/config.go b/instrumentation/net/http/otelhttp/config.go index c3be78616b2..30d0d44acb9 100644 --- a/instrumentation/net/http/otelhttp/config.go +++ b/instrumentation/net/http/otelhttp/config.go @@ -92,18 +92,6 @@ func WithMeterProvider(provider metric.MeterProvider) Option { }) } -// WithPublicEndpoint configures the Handler to link the span with an incoming -// span context. If this option is not provided, then the association is a child -// association instead of a link. -// -// Deprecated: Use [WithPublicEndpointFn] instead. -// To migrate, replace WithPublicEndpoint() with: -// -// WithPublicEndpointFn(func(*http.Request) bool { return true }) -func WithPublicEndpoint() Option { - return WithPublicEndpointFn(func(*http.Request) bool { return true }) -} - // WithPublicEndpointFn runs with every request, and allows conditionally // configuring the Handler to link the span with an incoming span context. If // this option is not provided or returns false, then the association is a From 399f5e1b683d67075fc699f06e68b35931638381 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Mon, 8 Dec 2025 13:53:53 -0800 Subject: [PATCH 2/3] Remove TestWithPublicEndpoint --- .../net/http/otelhttp/handler_test.go | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/instrumentation/net/http/otelhttp/handler_test.go b/instrumentation/net/http/otelhttp/handler_test.go index 30d1272d215..bf2937c071d 100644 --- a/instrumentation/net/http/otelhttp/handler_test.go +++ b/instrumentation/net/http/otelhttp/handler_test.go @@ -495,51 +495,6 @@ func TestWithSpanNameFormatter(t *testing.T) { } } -func TestWithPublicEndpoint(t *testing.T) { - spanRecorder := tracetest.NewSpanRecorder() - provider := sdktrace.NewTracerProvider( - sdktrace.WithSpanProcessor(spanRecorder), - ) - remoteSpan := trace.SpanContextConfig{ - TraceID: trace.TraceID{0x01}, - SpanID: trace.SpanID{0x01}, - Remote: true, - } - prop := propagation.TraceContext{} - h := NewHandler( - http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { - s := trace.SpanFromContext(r.Context()) - sc := s.SpanContext() - - // Should be with new root trace. - assert.True(t, sc.IsValid()) - assert.False(t, sc.IsRemote()) - assert.NotEqual(t, remoteSpan.TraceID, sc.TraceID()) - }), "test_handler", - WithPublicEndpoint(), - WithPropagators(prop), - WithTracerProvider(provider), - ) - - r, err := http.NewRequest(http.MethodGet, "http://localhost/", http.NoBody) - require.NoError(t, err) - - sc := trace.NewSpanContext(remoteSpan) - ctx := trace.ContextWithSpanContext(t.Context(), sc) - prop.Inject(ctx, propagation.HeaderCarrier(r.Header)) - - rr := httptest.NewRecorder() - h.ServeHTTP(rr, r) - assert.Equal(t, http.StatusOK, rr.Result().StatusCode) - - // Recorded span should be linked with an incoming span context. - assert.NoError(t, spanRecorder.ForceFlush(ctx)) - done := spanRecorder.Ended() - require.Len(t, done, 1) - require.Len(t, done[0].Links(), 1, "should contain link") - require.True(t, sc.Equal(done[0].Links()[0].SpanContext), "should link incoming span context") -} - func TestWithPublicEndpointFn(t *testing.T) { remoteSpan := trace.SpanContextConfig{ TraceID: trace.TraceID{0x01}, From 3943d129560cb22b716f5cfba4eb4fe2df1d5b0e Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Mon, 8 Dec 2025 14:24:09 -0800 Subject: [PATCH 3/3] Add PR number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 431426a9698..0eefcaca570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Removed - The deprecated `WithPublicEndpoint` in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. - Use `WithPublicEndpointFn` instead. (#TBD) + Use `WithPublicEndpointFn` instead. (#8267)