diff --git a/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs b/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs index 497f7eb2f3..c54ef4ee9c 100644 --- a/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs +++ b/src/Particular.LicensingComponent/BrokerThroughput/BrokerThroughputCollectorHostedService.cs @@ -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; + } } } } diff --git a/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs b/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs index ca742d146d..e014475abf 100644 --- a/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs +++ b/src/ServiceControl.Transports.SqlServer/SqlServerQuery.cs @@ -60,15 +60,33 @@ public override async IAsyncEnumerable 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) {