From dfdf05ff7534f537b3cce0a668b8735bc6d4e63c Mon Sep 17 00:00:00 2001 From: cmanu Date: Mon, 8 Oct 2018 20:32:04 -0700 Subject: [PATCH] Add more telemetry for monitoring. (#575) * Add more telemetry for monitoring. --- src/Validation.Symbols/ITelemetryService.cs | 10 ++++++++++ .../SymbolsValidatorService.cs | 6 ++++++ src/Validation.Symbols/TelemetryService.cs | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/Validation.Symbols/ITelemetryService.cs b/src/Validation.Symbols/ITelemetryService.cs index 0dd380690..cc11e3194 100644 --- a/src/Validation.Symbols/ITelemetryService.cs +++ b/src/Validation.Symbols/ITelemetryService.cs @@ -3,6 +3,7 @@ using System; using NuGet.Services.ServiceBus; +using NuGet.Services.Validation; namespace Validation.Symbols { @@ -29,5 +30,14 @@ public interface ITelemetryService : ISubscriptionProcessorTelemetryService /// The package normalized version. /// The count of symbols validated. IDisposable TrackSymbolValidationDurationEvent(string packageId, string packageNormalizedVersion, int symbolCount); + + /// + /// Tracks the status of the validation. + /// + /// The pacakge id. + /// The package normalized version. + /// The validation result. + /// Information about the issue id failed or empty if passed.. + void TrackSymbolsValidationResultEvent(string packageId, string packageNormalizedVersion, ValidationStatus validationStatus, string issue); } } diff --git a/src/Validation.Symbols/SymbolsValidatorService.cs b/src/Validation.Symbols/SymbolsValidatorService.cs index 14a6b6eb4..b7d2c5043 100644 --- a/src/Validation.Symbols/SymbolsValidatorService.cs +++ b/src/Validation.Symbols/SymbolsValidatorService.cs @@ -76,6 +76,7 @@ public async Task ValidateSymbolsAsync(string packageId, stri { if (!SymbolsHaveMatchingPEFiles(pdbs, pes)) { + _telemetryService.TrackSymbolsValidationResultEvent(packageId, packageNormalizedVersion, ValidationStatus.Failed, nameof(ValidationIssue.SymbolErrorCode_MatchingPortablePDBNotFound)); return ValidationResult.FailedWithIssues(ValidationIssue.SymbolErrorCode_MatchingPortablePDBNotFound); } var targetDirectory = Settings.GetWorkingDirectory(); @@ -165,6 +166,7 @@ public virtual IValidationResult ValidateSymbolMatching(string targetDirectory, if (checksumRecords.Length == 0) { + _telemetryService.TrackSymbolsValidationResultEvent(packageId, packageNormalizedVersion, ValidationStatus.Failed, nameof(ValidationIssue.SymbolErrorCode_ChecksumDoesNotMatch)); return ValidationResult.FailedWithIssues(ValidationIssue.SymbolErrorCode_ChecksumDoesNotMatch); } @@ -195,15 +197,18 @@ public virtual IValidationResult ValidateSymbolMatching(string targetDirectory, if (checksumRecord.Checksum.ToArray().SequenceEqual(hash)) { // found the right checksum + _telemetryService.TrackSymbolsValidationResultEvent(packageId, packageNormalizedVersion, ValidationStatus.Succeeded, ""); return ValidationResult.Succeeded; } } // Not found any checksum record that matches the PDB. + _telemetryService.TrackSymbolsValidationResultEvent(packageId, packageNormalizedVersion, ValidationStatus.Failed, nameof(ValidationIssue.SymbolErrorCode_ChecksumDoesNotMatch)); return ValidationResult.FailedWithIssues(ValidationIssue.SymbolErrorCode_ChecksumDoesNotMatch); } } } + _telemetryService.TrackSymbolsValidationResultEvent(packageId, packageNormalizedVersion, ValidationStatus.Failed, nameof(ValidationIssue.SymbolErrorCode_MatchingPortablePDBNotFound)); return ValidationResult.FailedWithIssues(ValidationIssue.SymbolErrorCode_MatchingPortablePDBNotFound); } } @@ -215,6 +220,7 @@ public virtual IValidationResult ValidateSymbolMatching(string targetDirectory, packageId, packageNormalizedVersion, Directory.GetFiles(targetDirectory, SymbolExtensionPattern, SearchOption.AllDirectories)); + _telemetryService.TrackSymbolsValidationResultEvent(packageId, packageNormalizedVersion, ValidationStatus.Failed, nameof(ValidationIssue.SymbolErrorCode_MatchingPortablePDBNotFound)); return ValidationResult.FailedWithIssues(ValidationIssue.SymbolErrorCode_MatchingPortablePDBNotFound); } diff --git a/src/Validation.Symbols/TelemetryService.cs b/src/Validation.Symbols/TelemetryService.cs index cd3143957..93473d461 100644 --- a/src/Validation.Symbols/TelemetryService.cs +++ b/src/Validation.Symbols/TelemetryService.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using NuGet.Services.Logging; +using NuGet.Services.Validation; namespace Validation.Symbols { @@ -15,11 +16,14 @@ public class TelemetryService : ITelemetryService private const string SymbolValidationDuration = Prefix + "SymbolValidationDurationInSeconds"; private const string MessageDeliveryLag = Prefix + "MessageDeliveryLag"; private const string MessageEnqueueLag = Prefix + "MessageEnqueueLag"; + private const string SymbolValidationResult = Prefix + "SymbolValidationResult"; private const string PackageId = "PackageId"; private const string PackageNormalizedVersion = "PackageNormalizedVersion"; private const string MessageType = "MessageType"; private const string SymbolCount = "SymbolCount"; + private const string ValidationResult = "ValidationResult"; + private const string Issue = "Issue"; private readonly ITelemetryClient _telemetryClient; @@ -64,6 +68,20 @@ public IDisposable TrackSymbolValidationDurationEvent(string packageId, string p }); } + public void TrackSymbolsValidationResultEvent(string packageId, string packageNormalizedVersion, ValidationStatus validationStatus, string issue) + { + _telemetryClient.TrackMetric( + SymbolValidationResult, + 1, + new Dictionary + { + { ValidationResult, validationStatus.ToString() }, + { Issue, issue }, + { PackageId, packageId }, + { PackageNormalizedVersion, packageNormalizedVersion } + }); + } + public void TrackMessageDeliveryLag(TimeSpan deliveryLag) => _telemetryClient.TrackMetric( MessageDeliveryLag,