Skip to content

Commit

Permalink
otelgrpc: Refine tests to use a net socket instead of a buffer (#4503)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Pająk <pellared@hotmail.com>
  • Loading branch information
MadVikingGod and pellared authored Nov 6, 2023
1 parent 4c540e0 commit 2a5fe23
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/test/bufconn"

"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/otel/attribute"
Expand All @@ -46,14 +47,18 @@ func TestStatsHandler(t *testing.T) {
serverMetricReader := metric.NewManualReader()
serverMP := metric.NewMeterProvider(metric.WithReader(serverMetricReader))

assert.NoError(t, doCalls(
listener := bufconn.Listen(bufSize)
defer listener.Close()
err := newGrpcTest(
listener,
[]grpc.DialOption{
grpc.WithStatsHandler(otelgrpc.NewClientHandler(otelgrpc.WithTracerProvider(clientTP), otelgrpc.WithMeterProvider(clientMP))),
},
[]grpc.ServerOption{
grpc.StatsHandler(otelgrpc.NewServerHandler(otelgrpc.WithTracerProvider(serverTP), otelgrpc.WithMeterProvider(serverMP))),
},
))
)
require.NoError(t, err)

t.Run("ClientSpans", func(t *testing.T) {
checkClientSpans(t, clientSR.Ended())
Expand Down
Loading

0 comments on commit 2a5fe23

Please sign in to comment.