This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into merge-master
- Loading branch information
Showing
48 changed files
with
1,234 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/NuGet.Services.Validation.Orchestrator/Telemetry/ITelemetryService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using NuGetGallery; | ||
|
||
namespace NuGet.Services.Validation.Orchestrator.Telemetry | ||
{ | ||
/// <summary> | ||
/// The interface used for emitting telemetry from the validation orchestrator. | ||
/// </summary> | ||
public interface ITelemetryService | ||
{ | ||
/// <summary> | ||
/// The duration from when the package was created to when the first validation set was created. This metric | ||
/// is not emitted for revalidation requests. | ||
/// </summary> | ||
void TrackDurationToValidationSetCreation(TimeSpan duration); | ||
|
||
/// <summary> | ||
/// A counter metric emitted when a package changes package status. This metric is not emitted if package status | ||
/// does not change. This metric is emitted for revalidation if the terminal state changes. | ||
/// </summary> | ||
/// <param name="fromStatus">The status that the package moved from.</param> | ||
/// <param name="toStatus">The status that the package moved tp.</param> | ||
void TrackPackageStatusChange(PackageStatus fromStatus, PackageStatus toStatus); | ||
|
||
/// <summary> | ||
/// The total duration of all validators. This is the time that the validation set is first created until all of | ||
/// the validators have completed. This metric is also emitted for revalidations. | ||
/// </summary> | ||
/// <param name="duration">The duration.</param> | ||
/// <param name="isSuccess">Whether or not all of the validations succeeded.</param> | ||
void TrackTotalValidationDuration(TimeSpan duration, bool isSuccess); | ||
|
||
/// <summary> | ||
/// A counter metric emitted when a validator fails due to the <see cref="ValidationConfigurationItem.FailAfter"/> | ||
/// configuration. | ||
/// </summary> | ||
/// <param name="validatorType">The validator type (name).</param> | ||
void TrackValidatorTimeout(string validatorType); | ||
|
||
/// <summary> | ||
/// The total duration of a single validator. This is the time from when the validation is first started until | ||
/// when the validation either completes or times out. | ||
/// </summary> | ||
/// <param name="duration">The duration.</param> | ||
/// <param name="validatorType">The validator type (name).</param> | ||
/// <param name="isSuccess">Whether or not the validation succeeded.</param> | ||
void TrackValidatorDuration(TimeSpan duration, string validatorType, bool isSuccess); | ||
|
||
/// <summary> | ||
/// A counter metric emitted when a validator is started. | ||
/// </summary> | ||
/// <param name="validatorType">The validator type (name).</param> | ||
void TrackValidatorStarted(string validatorType); | ||
|
||
/// <summary> | ||
/// A counter metric emmitted when a validator reaches a terminal state and potentially persists validation | ||
/// issues. A count of zero is emitted if the validator does not produce any issues. This metric is not emitted | ||
/// if the validation is still at a non-terminal state. | ||
/// </summary> | ||
/// <param name="count">The number of issues.</param> | ||
/// <param name="validatorType">The validator type (name) that returned the issue list.</param> | ||
/// <param name="isSuccess">Whether or not the validation succeeded.</param> | ||
void TrackValidationIssueCount(int count, string validatorType, bool isSuccess); | ||
|
||
/// <summary> | ||
/// A counter metric emitted when a validation issue is created. | ||
/// </summary> | ||
/// <param name="validatorType">The validator type (name) the produced the issue.</param> | ||
/// <param name="code">The issue code.</param> | ||
void TrackValidationIssue(string validatorType, ValidationIssueCode code); | ||
|
||
/// <summary> | ||
/// A counter metric emitted when a client-mastered validation issue is emitted. | ||
/// </summary> | ||
/// <param name="validatorType">The validator type (name) the produced the issue.</param> | ||
/// <param name="clientCode">The client code.</param> | ||
void TrackClientValidationIssue(string validatorType, string clientCode); | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
src/NuGet.Services.Validation.Orchestrator/Telemetry/TelemetryService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.ApplicationInsights; | ||
using NuGetGallery; | ||
|
||
namespace NuGet.Services.Validation.Orchestrator.Telemetry | ||
{ | ||
public class TelemetryService : ITelemetryService | ||
{ | ||
private const string Prefix = "Orchestrator."; | ||
|
||
private const string DurationToValidationSetCreationSeconds = Prefix + "DurationToValidationSetCreationSeconds"; | ||
private const string PackageStatusChange = Prefix + "PackageStatusChange"; | ||
private const string TotalValidationDurationSeconds = Prefix + "TotalValidationDurationSeconds"; | ||
private const string ValidationIssue = Prefix + "ValidationIssue"; | ||
private const string ValidationIssueCount = Prefix + "ValidationIssueCount"; | ||
private const string ValidatorTimeout = Prefix + "ValidatorTimeout"; | ||
private const string ValidatorDurationSeconds = Prefix + "ValidatorDurationSeconds"; | ||
private const string ValidatorStarted = Prefix + "ValidatorStarted"; | ||
private const string ClientValidationIssue = Prefix + "ClientValidationIssue"; | ||
|
||
private const string FromStatus = "FromStatus"; | ||
private const string ToStatus = "ToStatus"; | ||
private const string IsSuccess = "IsSuccess"; | ||
private const string ValidatorType = "ValidatorType"; | ||
private const string IssueCode = "IssueCode"; | ||
private const string ClientCode = "ClientCode"; | ||
|
||
private readonly TelemetryClient _telemetryClient; | ||
|
||
public TelemetryService(TelemetryClient telemetryClient) | ||
{ | ||
_telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); | ||
} | ||
|
||
public void TrackDurationToValidationSetCreation(TimeSpan duration) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
DurationToValidationSetCreationSeconds, | ||
duration.TotalSeconds); | ||
} | ||
|
||
public void TrackPackageStatusChange(PackageStatus fromStatus, PackageStatus toStatus) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
PackageStatusChange, | ||
1, | ||
new Dictionary<string, string> | ||
{ | ||
{ FromStatus, fromStatus.ToString() }, | ||
{ ToStatus, toStatus.ToString() }, | ||
}); | ||
} | ||
|
||
public void TrackTotalValidationDuration(TimeSpan duration, bool isSuccess) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
TotalValidationDurationSeconds, | ||
duration.TotalSeconds, | ||
new Dictionary<string, string> | ||
{ | ||
{ IsSuccess, isSuccess.ToString() }, | ||
}); | ||
} | ||
|
||
public void TrackValidationIssue(string validatorType, ValidationIssueCode code) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
ValidationIssue, | ||
1, | ||
new Dictionary<string, string> | ||
{ | ||
{ ValidatorType, validatorType }, | ||
{ IssueCode, code.ToString() }, | ||
}); | ||
} | ||
|
||
public void TrackValidationIssueCount(int count, string validatorType, bool isSuccess) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
ValidationIssueCount, | ||
count, | ||
new Dictionary<string, string> | ||
{ | ||
{ ValidatorType, validatorType }, | ||
{ IsSuccess, isSuccess.ToString() }, | ||
}); | ||
} | ||
|
||
public void TrackValidatorTimeout(string validatorType) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
ValidatorTimeout, | ||
1, | ||
new Dictionary<string, string> | ||
{ | ||
{ ValidatorType, validatorType }, | ||
}); | ||
} | ||
|
||
public void TrackValidatorDuration(TimeSpan duration, string validatorType, bool isSuccess) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
ValidatorDurationSeconds, | ||
duration.TotalSeconds, | ||
new Dictionary<string, string> | ||
{ | ||
{ ValidatorType, validatorType }, | ||
{ IsSuccess, isSuccess.ToString() }, | ||
}); | ||
} | ||
|
||
public void TrackValidatorStarted(string validatorType) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
ValidatorStarted, | ||
1, | ||
new Dictionary<string, string> | ||
{ | ||
{ ValidatorType, validatorType }, | ||
}); | ||
} | ||
|
||
public void TrackClientValidationIssue(string validatorType, string clientCode) | ||
{ | ||
_telemetryClient.TrackMetric( | ||
ClientValidationIssue, | ||
1, | ||
new Dictionary<string, string> | ||
{ | ||
{ ValidatorType, validatorType }, | ||
{ ClientCode, clientCode }, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.