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 SDKAnalysisLevel and UsingMicrosoftNETSdk to the restore telemetry #6205

Merged
merged 1 commit into from
Jan 6, 2025
Merged
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 @@ -59,6 +59,8 @@ private readonly Dictionary<RestoreTargetGraph, Dictionary<string, LibraryInclud
private const string TargetFrameworksCount = nameof(TargetFrameworksCount);
private const string RuntimeIdentifiersCount = nameof(RuntimeIdentifiersCount);
private const string TreatWarningsAsErrors = nameof(TreatWarningsAsErrors);
private const string SDKAnalysisLevel = nameof(SDKAnalysisLevel);
private const string UsingMicrosoftNETSdk = nameof(UsingMicrosoftNETSdk);
nkolev92 marked this conversation as resolved.
Show resolved Hide resolved

// no-op data names
private const string NoOpDuration = nameof(NoOpDuration);
Expand Down Expand Up @@ -319,6 +321,9 @@ private void InitializeTelemetry(TelemetryActivity telemetry, int httpSourcesCou
telemetry.TelemetryEvent[TargetFrameworksCount] = _request.Project.RestoreMetadata.TargetFrameworks.Count;
telemetry.TelemetryEvent[RuntimeIdentifiersCount] = _request.Project.RuntimeGraph.Runtimes.Count;
telemetry.TelemetryEvent[TreatWarningsAsErrors] = _request.Project.RestoreMetadata.ProjectWideWarningProperties.AllWarningsAsErrors;

telemetry.TelemetryEvent[SDKAnalysisLevel] = _request.Project.RestoreMetadata.SdkAnalysisLevel;
telemetry.TelemetryEvent[UsingMicrosoftNETSdk] = _request.Project.RestoreMetadata.UsingMicrosoftNETSdk;
_operationId = telemetry.OperationId;

var isCpvmEnabled = _request.Project.RestoreMetadata?.CentralPackageVersionsEnabled ?? false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2898,6 +2898,8 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
["TargetFrameworksCount"] = value => value.Should().Be(1),
["RuntimeIdentifiersCount"] = value => value.Should().Be(0),
["TreatWarningsAsErrors"] = value => value.Should().Be(false),
["SDKAnalysisLevel"] = value => value.Should().Be(null),
["UsingMicrosoftNETSdk"] = value => value.Should().Be(false),
};

HashSet<string> actualProperties = new();
Expand Down Expand Up @@ -2926,6 +2928,8 @@ public async Task ExecuteAsync_WithSinglePackage_WhenNoOping_PopulatesCorrectTel
var projectPath = Path.Combine(pathContext.SolutionRoot, projectName);
PackageSpec packageSpec = ProjectTestHelpers.GetPackageSpec(projectName, pathContext.SolutionRoot, "net472", "a");
packageSpec.RestoreMetadata.ProjectWideWarningProperties.AllWarningsAsErrors = true;
packageSpec.RestoreMetadata.UsingMicrosoftNETSdk = true;
packageSpec.RestoreMetadata.SdkAnalysisLevel = NuGetVersion.Parse("9.0.100");

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

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

projectInformationEvent.Count.Should().Be(28);
projectInformationEvent.Count.Should().Be(30);
projectInformationEvent["RestoreSuccess"].Should().Be(true);
projectInformationEvent["NoOpResult"].Should().Be(true);
projectInformationEvent["IsCentralVersionManagementEnabled"].Should().Be(false);
Expand Down Expand Up @@ -2999,6 +3003,8 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
projectInformationEvent["TargetFrameworksCount"].Should().Be(1);
projectInformationEvent["RuntimeIdentifiersCount"].Should().Be(0);
projectInformationEvent["TreatWarningsAsErrors"].Should().Be(true);
projectInformationEvent["SDKAnalysisLevel"].Should().Be(NuGetVersion.Parse("9.0.100"));
projectInformationEvent["UsingMicrosoftNETSdk"].Should().Be(true);
}

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

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

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