Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
Add more telemetry for monitoring. (#575)
Browse files Browse the repository at this point in the history
* Add more telemetry for monitoring.
  • Loading branch information
cristinamanum authored Oct 9, 2018
1 parent 6b49855 commit dfdf05f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Validation.Symbols/ITelemetryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using NuGet.Services.ServiceBus;
using NuGet.Services.Validation;

namespace Validation.Symbols
{
Expand All @@ -29,5 +30,14 @@ public interface ITelemetryService : ISubscriptionProcessorTelemetryService
/// <param name="packageNormalizedVersion">The package normalized version.</param>
/// <param name="symbolCount">The count of symbols validated.</param>
IDisposable TrackSymbolValidationDurationEvent(string packageId, string packageNormalizedVersion, int symbolCount);

/// <summary>
/// Tracks the status of the validation.
/// </summary>
/// <param name="packageId">The pacakge id.</param>
/// <param name="packageNormalizedVersion">The package normalized version.</param>
/// <param name="validationStatus">The validation result.</param>
/// <param name="issue">Information about the issue id failed or empty if passed..</param>
void TrackSymbolsValidationResultEvent(string packageId, string packageNormalizedVersion, ValidationStatus validationStatus, string issue);
}
}
6 changes: 6 additions & 0 deletions src/Validation.Symbols/SymbolsValidatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public async Task<IValidationResult> 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();
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}

Expand Down
18 changes: 18 additions & 0 deletions src/Validation.Symbols/TelemetryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using NuGet.Services.Logging;
using NuGet.Services.Validation;

namespace Validation.Symbols
{
Expand All @@ -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;

Expand Down Expand Up @@ -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<string, string>
{
{ ValidationResult, validationStatus.ToString() },
{ Issue, issue },
{ PackageId, packageId },
{ PackageNormalizedVersion, packageNormalizedVersion }
});
}

public void TrackMessageDeliveryLag<TMessage>(TimeSpan deliveryLag)
=> _telemetryClient.TrackMetric(
MessageDeliveryLag,
Expand Down

0 comments on commit dfdf05f

Please sign in to comment.