Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ async Task Exec(IBrokerQueue queueName, string postfix)

await foreach (var queueThroughput in brokerThroughputQuery.GetThroughputPerDay(queueName, startDate, stoppingToken))
{
await dataStore.RecordEndpointThroughput(queueName.QueueName, ThroughputSource.Broker, queueThroughput.DateUTC, queueThroughput.TotalThroughput, stoppingToken);
try
{
await dataStore.RecordEndpointThroughput(queueName.QueueName, ThroughputSource.Broker, queueThroughput.DateUTC, queueThroughput.TotalThroughput, stoppingToken);
}
catch (Exception e)
{
logger.LogError(e, "Failed to record throughput for {QueueName}", queueName.QueueName);
Console.WriteLine(e);
throw;
}
}
}
}
Expand Down
26 changes: 22 additions & 4 deletions src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,33 @@ public override async IAsyncEnumerable<QueueThroughput> GetThroughputPerDay(IBro
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var queueTableName = (BrokerQueueTable)brokerQueue;
var startData =
await queueTableName.DatabaseDetails.GetSnapshot(queueTableName, cancellationToken);

BrokerQueueTableSnapshot startData;
try
{
startData = await queueTableName.DatabaseDetails.GetSnapshot(queueTableName, cancellationToken);
}
catch (Exception e)
{
logger.LogError(e, "Failed to query throughput starting snapshot for {QueueName}", queueTableName.QueueName);
throw;
}

// looping for 24 hours
for (var i = 0; i < 24; i++)
{
await Task.Delay(TimeSpan.FromHours(1), timeProvider, cancellationToken);
var endData =
await queueTableName.DatabaseDetails.GetSnapshot(queueTableName, cancellationToken);

BrokerQueueTableSnapshot? endData;
try
{
endData = await queueTableName.DatabaseDetails.GetSnapshot(queueTableName, cancellationToken);
}
catch (Exception e)
{
logger.LogError(e, "Failed to query throughput hour {hour} for {QueueName}", i, queueTableName.QueueName);
throw;
}

if (endData.RowVersion.HasValue && startData.RowVersion.HasValue)
{
Expand Down
Loading