Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit afe77ed

Browse files
authored
Added reporting the package download speed along with the download time as its own metric. (#413)
1 parent b6f183c commit afe77ed

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Validation.Common.Job/CommonTelemetryService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ namespace NuGet.Jobs.Validation
1010
public class CommonTelemetryService : ICommonTelemetryService
1111
{
1212
private const string PackageDownloadedSeconds = "PackageDownloadedSeconds";
13+
private const string PackageDownloadSpeed = "PackageDownloadSpeedBytesPerSec";
1314
private const string PackageUri = "PackageUri";
1415
private const string PackageSize = "PackageSize";
16+
private const double DefaultDownloadSpeed = 1;
1517

1618
private readonly ITelemetryClient _telemetryClient;
1719

@@ -35,6 +37,14 @@ public void TrackPackageDownloaded(Uri packageUri, TimeSpan duration, long size)
3537
{ PackageUri, absoluteUri },
3638
{ PackageSize, size.ToString() },
3739
});
40+
_telemetryClient.TrackMetric(
41+
PackageDownloadSpeed,
42+
duration.TotalSeconds > 0 ? size / duration.TotalSeconds : DefaultDownloadSpeed,
43+
new Dictionary<string, string>
44+
{
45+
{ PackageUri, absoluteUri },
46+
{ PackageSize, size.ToString() },
47+
});
3848
}
3949
}
4050
}

0 commit comments

Comments
 (0)