Skip to content

Commit

Permalink
Account for new span on the operation grpc.client
Browse files Browse the repository at this point in the history
The version bump introduces a new span on the operation `grpc.client` that the
previous implementation of the test did not account for.
  • Loading branch information
nhhagen committed Dec 16, 2024
1 parent 3f18bd7 commit 5bce8dc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions middleware/grpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,26 @@ func TestStreamClientInterceptor(t *testing.T) {

client := testgrpc.NewTestServiceClient(conn)
span, spanCtx := tracer.StartSpanFromContext(context.Background(), "grpc.request", tracer.ResourceName("/helloworld"))
defer span.Finish()
c, err := client.StreamingOutputCall(spanCtx, &testgrpc.StreamingOutputCallRequest{})
require.NoError(t, err)
span.Finish()

c.Recv()

testTracer.Stop()

spans := testTracer.FinishedSpans()
require.Equal(t, 2, len(spans))
assert.Equal(t, strconv.Itoa(int(span.Context().TraceID())), server.ddTraceID)
require.Equal(t, 4, len(spans))
for _, finishedSpan := range spans {
assert.Equal(t, strconv.Itoa(int(finishedSpan.TraceID())), server.ddTraceID)
assert.Equal(t, strconv.Itoa(int(finishedSpan.ParentID())), server.ddParentID)
if finishedSpan.OperationName() == "grpc.request" {
assert.Equal(t, strconv.Itoa(int(finishedSpan.ParentID())), "0")
} else if finishedSpan.OperationName() == "grpc.client" {
assert.Equal(t, strconv.Itoa(int(finishedSpan.ParentID())), strconv.Itoa(int(finishedSpan.TraceID())))
assert.Equal(t, strconv.Itoa(int(finishedSpan.ParentID())), server.ddTraceID)
} else {
assert.Equal(t, "grpc.message", finishedSpan.OperationName())
assert.Equal(t, strconv.Itoa(int(finishedSpan.ParentID())), server.ddParentID)
}
}
}

0 comments on commit 5bce8dc

Please sign in to comment.