Skip to content
Merged
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 @@ -66,6 +66,24 @@ public async Task<Stream> DownloadPackageArtifact(string repoName, string buildI
private async Task<HttpResponseMessage> GetFromDevopsAsync(string request)
{
var downloadResp = await _devopsClient.GetAsync(request);


if (!downloadResp.IsSuccessStatusCode)
{
var retryAfter = downloadResp.Headers.GetValues("Retry-After");
var rateLimitResource = downloadResp.Headers.GetValues("X-RateLimit-Resource");
var rateLimitDelay = downloadResp.Headers.GetValues("X-RateLimit-Delay");
var rateLimitLimit = downloadResp.Headers .GetValues("X-RateLimit-Limit");
var rateLimitRemaining = downloadResp.Headers.GetValues("X-RateLimit-Remaining");
var rateLimitReset = downloadResp.Headers.GetValues("X-RateLimit-Reset");

var traceMessage = $"request: {request} failed with statusCode: {downloadResp.StatusCode}," +
$"retryAfter: {retryAfter}, rateLimitResource: {rateLimitResource}, rateLimitDelay: {rateLimitDelay}," +
$"rateLimitLimit: {rateLimitLimit}, rateLimitRemaining: {rateLimitRemaining}, rateLimitReset: {rateLimitReset}";

_telemetryClient.TrackTrace(traceMessage);
}

int count = 0;
int[] waitTimes = new int[] { 0, 1, 2, 4, 8, 16, 32, 64, 128, 256 };
while ((downloadResp.StatusCode == HttpStatusCode.TooManyRequests || downloadResp.StatusCode == HttpStatusCode.BadRequest) && count < waitTimes.Length)
Expand Down