@@ -195,27 +195,32 @@ class AwsHttpClientFactory : HttpClientFactory
195195
196196 public override async IAsyncEnumerable < QueueThroughput > GetThroughputPerDay ( IBrokerQueue brokerQueue ,
197197 DateOnly startDate ,
198- [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
198+ [ EnumeratorCancellation ] CancellationToken cancellationToken )
199199 {
200200 var utcNow = timeProvider . GetUtcNow ( ) ;
201201 var endDate = DateOnly . FromDateTime ( utcNow . DateTime ) . AddDays ( - 1 ) ; // Query date up to but not including today
202202
203- if ( endDate < startDate )
203+ var isBeforeStartDate = endDate < startDate ;
204+
205+ if ( isBeforeStartDate )
204206 {
207+ logger . LogTrace ( "Skipping {Start} {End} {UtcNow}, " , startDate , endDate , utcNow ) ;
205208 yield break ;
206209 }
207210
208- var startUtc = startDate . ToDateTime ( TimeOnly . MinValue , DateTimeKind . Utc ) ;
209- var endUtc = endDate . AddDays ( 1 ) . ToDateTime ( TimeOnly . MinValue , DateTimeKind . Utc ) ;
211+ var queryStartUtc = startDate . ToDateTime ( TimeOnly . MinValue , DateTimeKind . Utc ) ;
212+ var queryendUtc = endDate . AddDays ( 1 ) . ToDateTime ( TimeOnly . MinValue , DateTimeKind . Utc ) ;
213+
214+ logger . LogDebug ( "GetThroughputPerDay {QueueName} {UtcNow} {StartDate} {EndDate} {QueryStart} {QueryEnd}" , brokerQueue . QueueName , utcNow , startDate , endDate , queryStartUtc , queryendUtc ) ;
210215
211216 const int SecondsInDay = 24 * 60 * 60 ;
212217
213218 var req = new GetMetricStatisticsRequest
214219 {
215220 Namespace = "AWS/SQS" ,
216221 MetricName = "NumberOfMessagesDeleted" ,
217- StartTime = startUtc ,
218- EndTime = endUtc , // exclusive
222+ StartTime = queryStartUtc ,
223+ EndTime = queryendUtc , // exclusive
219224 Period = SecondsInDay ,
220225 Statistics = [ "Sum" ] ,
221226 Dimensions =
@@ -241,7 +246,7 @@ public override async IAsyncEnumerable<QueueThroughput> GetThroughputPerDay(IBro
241246 // Cloudwatch returns data points per 5 minutes in UTC
242247 foreach ( var datapoint in resp . Datapoints ?? [ ] )
243248 {
244- logger . LogInformation ( " \t Datapoint {Timestamp:O} {Sum} {Unit} ", datapoint . Timestamp , datapoint . Sum , datapoint . Unit ) ;
249+ logger . LogTrace ( "Datapoint {Timestamp:O} {Sum:N0} ", datapoint . Timestamp , datapoint . Sum ) ;
245250 if ( datapoint . Timestamp . HasValue )
246251 {
247252 if ( data . TryGetValue ( DateOnly . FromDateTime ( datapoint . Timestamp . Value ) , out var queueThroughput ) )
0 commit comments