Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target framework, runtime identifier counts and treat warnings as errors metrics #6158

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -56,6 +56,9 @@ private readonly Dictionary<RestoreTargetGraph, Dictionary<string, LibraryInclud
private const string HttpSourcesCount = nameof(HttpSourcesCount);
private const string LocalSourcesCount = nameof(LocalSourcesCount);
private const string FallbackFoldersCount = nameof(FallbackFoldersCount);
private const string TargetFrameworksCount = nameof(TargetFrameworksCount);
private const string RuntimeIdentifiersCount = nameof(RuntimeIdentifiersCount);
private const string TreatWarningsAsErrors = nameof(TreatWarningsAsErrors);

// no-op data names
private const string NoOpDuration = nameof(NoOpDuration);
Expand Down Expand Up @@ -170,6 +173,9 @@ public async Task<RestoreResult> ExecuteAsync(CancellationToken token)
telemetry.TelemetryEvent[IsLockFileEnabled] = _isLockFileEnabled;
telemetry.TelemetryEvent[UseLegacyDependencyResolver] = _request.Project.RestoreMetadata.UseLegacyDependencyResolver;
telemetry.TelemetryEvent[UsedLegacyDependencyResolver] = !_enableNewDependencyResolver;
telemetry.TelemetryEvent[TargetFrameworksCount] = _request.Project.RestoreMetadata.TargetFrameworks.Count;
telemetry.TelemetryEvent[RuntimeIdentifiersCount] = _request.Project.RuntimeGraph.Runtimes.Count;
telemetry.TelemetryEvent[TreatWarningsAsErrors] = _request.Project.RestoreMetadata.ProjectWideWarningProperties.AllWarningsAsErrors;

_operationId = telemetry.OperationId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2895,6 +2895,9 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
["Audit.Duration.Total"] = value => value.Should().BeOfType<double>(),
["UseLegacyDependencyResolver"] = value => value.Should().BeOfType<bool>(),
["UsedLegacyDependencyResolver"] = value => value.Should().BeOfType<bool>(),
["TargetFrameworksCount"] = value => value.Should().Be(1),
["RuntimeIdentifiersCount"] = value => value.Should().Be(0),
["TreatWarningsAsErrors"] = value => value.Should().Be(false),
};

HashSet<string> actualProperties = new();
Expand Down Expand Up @@ -2922,6 +2925,7 @@ public async Task ExecuteAsync_WithSinglePackage_WhenNoOping_PopulatesCorrectTel
var projectName = "TestProject";
var projectPath = Path.Combine(pathContext.SolutionRoot, projectName);
PackageSpec packageSpec = ProjectTestHelpers.GetPackageSpec(projectName, pathContext.SolutionRoot, "net472", "a");
packageSpec.RestoreMetadata.ProjectWideWarningProperties.AllWarningsAsErrors = true;

await SimpleTestPackageUtility.CreateFolderFeedV3Async(
pathContext.PackageSource,
Expand Down Expand Up @@ -2966,7 +2970,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(

var projectInformationEvent = telemetryEvents.Single(e => e.Name.Equals("ProjectRestoreInformation"));

projectInformationEvent.Count.Should().Be(25);
projectInformationEvent.Count.Should().Be(28);
projectInformationEvent["RestoreSuccess"].Should().Be(true);
projectInformationEvent["NoOpResult"].Should().Be(true);
projectInformationEvent["IsCentralVersionManagementEnabled"].Should().Be(false);
Expand All @@ -2992,6 +2996,9 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
projectInformationEvent["UseLegacyDependencyResolver"].Should().BeOfType<bool>();
projectInformationEvent["UsedLegacyDependencyResolver"].Should().BeOfType<bool>();
projectInformationEvent["Audit.Enabled"].Should().BeOfType<string>();
projectInformationEvent["TargetFrameworksCount"].Should().Be(1);
projectInformationEvent["RuntimeIdentifiersCount"].Should().Be(0);
projectInformationEvent["TreatWarningsAsErrors"].Should().Be(true);
}

[Fact]
Expand Down Expand Up @@ -3049,7 +3056,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(

var projectInformationEvent = telemetryEvents.Single(e => e.Name.Equals("ProjectRestoreInformation"));

projectInformationEvent.Count.Should().Be(31);
projectInformationEvent.Count.Should().Be(34);
projectInformationEvent["RestoreSuccess"].Should().Be(true);
projectInformationEvent["NoOpResult"].Should().Be(false);
projectInformationEvent["TotalUniquePackagesCount"].Should().Be(2);
Expand Down