From f6ba8012500030d5c6f96fd668771a006828bb46 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2026 16:43:17 +0000 Subject: [PATCH 1/3] Add test for shutdownTracingProviderWithTimeout error path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/cmd/tracing_helpers_test.go | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/internal/cmd/tracing_helpers_test.go b/internal/cmd/tracing_helpers_test.go index b0836693d..444fc6183 100644 --- a/internal/cmd/tracing_helpers_test.go +++ b/internal/cmd/tracing_helpers_test.go @@ -2,6 +2,9 @@ package cmd import ( "context" + "fmt" + "net/http" + "net/http/httptest" "testing" "github.com/spf13/cobra" @@ -187,6 +190,37 @@ func TestShutdownTracingProviderWithTimeout(t *testing.T) { }) assert.False(t, warnCalled, "SDK provider with no pending spans should shut down without error") }) + + t.Run("warns when shutdown times out flushing to a hanging collector", func(t *testing.T) { + if testing.Short() { + t.Skip("waits for the 5s shutdown timeout") + } + t.Cleanup(func() { otel.SetTracerProvider(noop.NewTracerProvider()) }) + + release := make(chan struct{}) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + select { + case <-release: + case <-r.Context().Done(): + } + })) + t.Cleanup(srv.Close) + t.Cleanup(func() { close(release) }) + + provider, err := tracing.InitProvider(context.Background(), &config.TracingConfig{Endpoint: srv.URL}) + require.NoError(t, err) + require.True(t, provider.IsEnabled()) + + _, span := provider.Tracer().Start(context.Background(), "pending-span") + span.End() + + var warnings []string + shutdownTracingProviderWithTimeout(provider, func(format string, args ...any) { + warnings = append(warnings, fmt.Sprintf(format, args...)) + }) + require.Len(t, warnings, 1, "timed-out flush should surface exactly one warning") + assert.Contains(t, warnings[0], "tracing provider shutdown error") + }) } func TestSetupCommandTracing(t *testing.T) { From aad682ba2036bc06bec95fcf66fd3b711b14f533 Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Wed, 7 Oct 2026 10:16:26 -0700 Subject: [PATCH 2/3] Set environment variable for tracing provider test Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- internal/cmd/tracing_helpers_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/cmd/tracing_helpers_test.go b/internal/cmd/tracing_helpers_test.go index 444fc6183..213aad070 100644 --- a/internal/cmd/tracing_helpers_test.go +++ b/internal/cmd/tracing_helpers_test.go @@ -207,6 +207,7 @@ func TestShutdownTracingProviderWithTimeout(t *testing.T) { t.Cleanup(srv.Close) t.Cleanup(func() { close(release) }) +t.Setenv("GH_AW_OTLP_ENDPOINTS", "") provider, err := tracing.InitProvider(context.Background(), &config.TracingConfig{Endpoint: srv.URL}) require.NoError(t, err) require.True(t, provider.IsEnabled()) From fcdb2dad13c2d3f3dac23d8903f5fc76151f180e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Oct 2026 17:55:20 +0000 Subject: [PATCH 3/3] Fix tracing test formatting Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --- internal/cmd/tracing_helpers_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/tracing_helpers_test.go b/internal/cmd/tracing_helpers_test.go index 213aad070..91f83cc11 100644 --- a/internal/cmd/tracing_helpers_test.go +++ b/internal/cmd/tracing_helpers_test.go @@ -207,7 +207,7 @@ func TestShutdownTracingProviderWithTimeout(t *testing.T) { t.Cleanup(srv.Close) t.Cleanup(func() { close(release) }) -t.Setenv("GH_AW_OTLP_ENDPOINTS", "") + t.Setenv("GH_AW_OTLP_ENDPOINTS", "") provider, err := tracing.InitProvider(context.Background(), &config.TracingConfig{Endpoint: srv.URL}) require.NoError(t, err) require.True(t, provider.IsEnabled())