From f6aeb0d909e933a7e8bf416aab1c9f0277c8aed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 8 Nov 2023 15:56:30 +0100 Subject: [PATCH] otelgrpc: Stablize TestInterceptors (#4535) --- .../google.golang.org/grpc/otelgrpc/test/grpc_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go b/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go index 6d8a82676ba..d1837ee0bf1 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/test/grpc_test.go @@ -19,6 +19,7 @@ import ( "net" "strconv" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -136,6 +137,12 @@ func TestInterceptors(t *testing.T) { }) t.Run("StreamClientSpans", func(t *testing.T) { + // StreamClientInterceptor ends the spans asynchronously. + // We need to wait for all spans before asserting them. + require.EventuallyWithT(t, func(c *assert.CollectT) { + assert.Len(c, clientStreamSR.Ended(), 3) + }, 5*time.Second, 100*time.Millisecond) + checkStreamClientSpans(t, clientStreamSR.Ended(), listener.Addr().String()) })