Skip to content

Commit

Permalink
Support no messages available with TimeSpentInQueue & Storage scraper (
Browse files Browse the repository at this point in the history
…#496)

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
  • Loading branch information
tomkerkhove authored Apr 7, 2019
1 parent 8f58edb commit f0d83a8
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ public async Task<double> GetQueueMessageTimeSpentInQueueAsync(string accountNam
{
var queue = await GetQueueReference(accountName, queueName, sasToken);

var msg = await queue.PeekMessageAsync();
var timeSpentInQueue = msg.InsertionTime.HasValue ? DateTime.UtcNow - msg.InsertionTime.Value.UtcDateTime : TimeSpan.Zero;
var message = await queue.PeekMessageAsync();

TimeSpan timeSpentInQueue = TimeSpan.Zero;
if (message?.InsertionTime.HasValue == true)
{
timeSpentInQueue = DateTime.UtcNow - message.InsertionTime.Value.UtcDateTime;
}

return timeSpentInQueue.TotalSeconds;
}
Expand Down

0 comments on commit f0d83a8

Please sign in to comment.