Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/AppCommon/Commands/SqsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ protected override async Task<QueueDetails> GetData(CancellationToken cancellati

return new QueueDetails
{
StartTime = new DateTimeOffset(aws.StartTimeUtc, TimeSpan.Zero),
EndTime = new DateTimeOffset(aws.EndTimeUtc, TimeSpan.Zero),
Queues = data.OrderBy(q => q.QueueName).ToArray(),
StartTime = new DateTimeOffset(aws.StartDate.ToDateTime(TimeOnly.MinValue), TimeSpan.Zero),
EndTime = new DateTimeOffset(aws.EndDate.ToDateTime(TimeOnly.MaxValue), TimeSpan.Zero),
Queues = [.. data.OrderBy(q => q.QueueName)],
TimeOfObservation = TimeSpan.FromDays(1)
};
}
Expand Down
14 changes: 7 additions & 7 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="AWSSDK.CloudWatch" Version="3.7.402.88" />
<PackageVersion Include="AWSSDK.SecurityToken" Version="3.7.401.89" />
<PackageVersion Include="AWSSDK.SQS" Version="3.7.400.140" />
<PackageVersion Include="Azure.Identity" Version="1.13.2" />
<PackageVersion Include="Azure.Messaging.ServiceBus" Version="7.19.0" />
<PackageVersion Include="AWSSDK.CloudWatch" Version="4.0.1.4" />
<PackageVersion Include="AWSSDK.SecurityToken" Version="4.0.0.8" />
<PackageVersion Include="AWSSDK.SQS" Version="4.0.0.9" />
<PackageVersion Include="Azure.Identity" Version="1.14.0" />
<PackageVersion Include="Azure.Messaging.ServiceBus" Version="7.20.1" />
<PackageVersion Include="Azure.Monitor.Query" Version="1.6.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="ICSharpCode.Decompiler" Version="8.2.0.7535" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Mindscape.Raygun4Net.AspNetCore" Version="11.2.3" />
<PackageVersion Include="Npgsql" Version="9.0.3" />
<PackageVersion Include="NuGet.Versioning" Version="6.13.2" />
<PackageVersion Include="NuGet.Versioning" Version="6.14.0" />
<PackageVersion Include="NUnit" Version="4.3.2" />
<PackageVersion Include="NUnit.Analyzers" Version="4.7.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
Expand Down
27 changes: 15 additions & 12 deletions src/Query/AmazonSQS/AwsQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class AwsQuery
readonly AmazonSQSClient sqs;
readonly FixedWindowRateLimiter rateLimiter;

public DateTime EndTimeUtc { get; set; }
public DateTime StartTimeUtc { get; set; }
public DateOnly EndDate { get; set; }
public DateOnly StartDate { get; set; }

public string CloudWatchRegion => cloudWatch.Config.RegionEndpoint.SystemName;
public string SQSRegion => sqs.Config.RegionEndpoint.SystemName;
Expand All @@ -34,8 +34,8 @@ public AwsQuery()
// Otherwise AcquireAsync() will return a lease immediately with IsAcquired = false
QueueLimit = int.MaxValue
});
EndTimeUtc = DateTime.UtcNow.Date.AddDays(1);
StartTimeUtc = EndTimeUtc.AddDays(-30);
EndDate = DateOnly.FromDateTime(DateTime.UtcNow).AddDays(1);
StartDate = EndDate.AddDays(-30);

sqs = new AmazonSQSClient();
cloudWatch = new AmazonCloudWatchClient();
Expand All @@ -58,7 +58,10 @@ public async Task<List<string>> GetQueueNames(Action<int> onProgress, Cancellati

var response = await sqs.ListQueuesAsync(request, cancellationToken).ConfigureAwait(false);

queueNames.AddRange(response.QueueUrls.Select(url => url.Split('/')[4]).ToArray());
if (response.QueueUrls is { Count: > 0 })
{
queueNames.AddRange(response.QueueUrls.Select(url => url.Split('/')[4]).ToArray());
}

onProgress(queueNames.Count);

Expand Down Expand Up @@ -86,19 +89,19 @@ public async Task<long> GetMaxThroughput(string queueName, CancellationToken can
{
Namespace = "AWS/SQS",
MetricName = "NumberOfMessagesDeleted",
StartTimeUtc = StartTimeUtc,
EndTimeUtc = EndTimeUtc,
Period = 86400, // 1 day
StartTime = StartDate.ToDateTime(TimeOnly.MinValue),
EndTime = EndDate.ToDateTime(TimeOnly.MaxValue),
Period = 24 * 60 * 60, // 1 day
Statistics = ["Sum"],
Dimensions = [new Dimension { Name = "QueueName", Value = queueName }]
Dimensions = [
new Dimension { Name = "QueueName", Value = queueName }]
};

using var lease = await rateLimiter.AcquireAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
var resp = await cloudWatch.GetMetricStatisticsAsync(req, cancellationToken).ConfigureAwait(false);

var maxThroughput = resp.Datapoints.MaxBy(d => d.Sum)?.Sum ?? 0;

return (long)maxThroughput;
return resp.Datapoints is { Count: > 0 } ?
(long)resp.Datapoints.Select(d => d.Sum.GetValueOrDefault(0)).Max() : 0L;
}
}
}
2 changes: 2 additions & 0 deletions src/Query/AzureServiceBus/AzureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ IEnumerable<TokenCredential> CreateCredentials()
yield return new EnvironmentCredential();
yield return new SharedTokenCacheCredential();
yield return new VisualStudioCredential();
#pragma warning disable CS0618 // Type or member is obsolete
yield return new VisualStudioCodeCredential();
#pragma warning restore CS0618 // Type or member is obsolete

// Don't really need this one to take 100s * 4 tries to finally time out
var opts = new TokenCredentialOptions();
Expand Down