Skip to content

Commit

Permalink
Record benchmark request errors as requests (#1260)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK authored Apr 8, 2021
1 parent 2844af7 commit 85883a2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions perf/benchmarkapps/GrpcClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,16 @@ private static async Task PingPongStreaming(CancellationTokenSource cts, int con
break;
}

var start = DateTime.UtcNow;
try
{
var start = DateTime.UtcNow;
await call.RequestStream.WriteAsync(request);
if (!await call.ResponseStream.MoveNext())
{
throw new Exception("Unexpected end of stream.");
}
var end = DateTime.UtcNow;

var end = DateTime.UtcNow;
ReceivedDateTime(start, end, connectionId);
}
catch (RpcException ex) when (ex.StatusCode == StatusCode.Cancelled && cts.IsCancellationRequested)
Expand All @@ -565,6 +565,9 @@ private static async Task PingPongStreaming(CancellationTokenSource cts, int con
}
catch (Exception ex)
{
var end = DateTime.UtcNow;
ReceivedDateTime(start, end, connectionId);

HandleError(connectionId);

Log(connectionId, streamId, $"Error message: {ex}");
Expand Down Expand Up @@ -593,15 +596,15 @@ private static async Task ServerStreamingCall(CancellationTokenSource cts, int c
break;
}

var start = DateTime.UtcNow;
try
{
var start = DateTime.UtcNow;
if (!await call.ResponseStream.MoveNext())
{
throw new Exception("Unexpected end of stream.");
}
var end = DateTime.UtcNow;

var end = DateTime.UtcNow;
ReceivedDateTime(start, end, connectionId);
}
catch (RpcException ex) when (ex.StatusCode == StatusCode.Cancelled && cts.IsCancellationRequested)
Expand All @@ -611,6 +614,9 @@ private static async Task ServerStreamingCall(CancellationTokenSource cts, int c
}
catch (Exception ex)
{
var end = DateTime.UtcNow;
ReceivedDateTime(start, end, connectionId);

HandleError(connectionId);

Log(connectionId, streamId, $"Error message: {ex}");
Expand All @@ -633,16 +639,19 @@ private static async Task UnaryCall(CancellationTokenSource cts, int connectionI
break;
}

var start = DateTime.UtcNow;
try
{
var start = DateTime.UtcNow;
var response = await client.UnaryCallAsync(CreateSimpleRequest(), CreateCallOptions());
var end = DateTime.UtcNow;

var end = DateTime.UtcNow;
ReceivedDateTime(start, end, connectionId);
}
catch (Exception ex)
{
var end = DateTime.UtcNow;
ReceivedDateTime(start, end, connectionId);

HandleError(connectionId);

Log(connectionId, streamId, $"Error message: {ex}");
Expand Down

0 comments on commit 85883a2

Please sign in to comment.