@@ -74,15 +74,39 @@ protected override async Task<QueueDetails> GetData(CancellationToken cancellati
74
74
75
75
var tasks = queueNames . Select ( async queueName =>
76
76
{
77
- var maxThroughput = await aws . GetMaxThroughput ( queueName , cancellationToken ) . ConfigureAwait ( false ) ;
77
+ var datapoints = await aws . GetMMetricsData ( queueName , cancellationToken ) . ConfigureAwait ( false ) ;
78
78
79
- // Since we get 30 days of data, if there's no throughput in that amount of time, hard to legitimately call it an endpoint
79
+ var maxThroughput = datapoints is { Count : > 0 } ?
80
+ ( long ) datapoints . Select ( d => d . Sum . GetValueOrDefault ( 0 ) ) . Max ( ) : 0L ;
81
+ // Since we get 365 days of data, if there's no throughput in that amount of time, hard to legitimately call it an endpoint
80
82
if ( maxThroughput > 0 )
81
83
{
84
+ DateOnly currentDate = aws . StartDate ;
85
+ var dailyData = new Dictionary < DateOnly , DailyThroughput > ( ) ;
86
+ while ( currentDate <= aws . EndDate )
87
+ {
88
+ dailyData . Add ( currentDate , new DailyThroughput { MessageCount = 0 , DateUTC = currentDate } ) ;
89
+
90
+ currentDate = currentDate . AddDays ( 1 ) ;
91
+ }
92
+
93
+ foreach ( var datapoint in datapoints )
94
+ {
95
+ // There is a bug in the AWS SDK. The timestamp is actually UTC time, eventhough the DateTime returned type says Local
96
+ // See https://github.com/aws/aws-sdk-net/issues/167
97
+ // So do not convert the timestamp to UTC time!
98
+ if ( datapoint . Timestamp . HasValue )
99
+ {
100
+ currentDate = DateOnly . FromDateTime ( datapoint . Timestamp . Value ) ;
101
+ dailyData [ currentDate ] = new DailyThroughput { MessageCount = ( long ) datapoint . Sum . GetValueOrDefault ( 0 ) , DateUTC = currentDate } ;
102
+ }
103
+ }
104
+
82
105
data . Add ( new QueueThroughput
83
106
{
84
107
QueueName = queueName ,
85
- Throughput = maxThroughput
108
+ Throughput = maxThroughput ,
109
+ DailyThroughputFromBroker = [ .. dailyData . Values ]
86
110
} ) ;
87
111
}
88
112
0 commit comments