Skip to content

Commit

Permalink
Add SDKAnalysisLevel and UsingMicrosoftNETSdk to the restore telemetry (
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolev92 authored Jan 6, 2025
1 parent 89781a2 commit 4c634cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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);

// no-op data names
private const string NoOpDuration = nameof(NoOpDuration);
Expand Down Expand Up @@ -327,6 +329,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 @@ -2905,6 +2905,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 @@ -2933,6 +2935,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 @@ -2977,7 +2981,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 @@ -3006,6 +3010,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 @@ -3063,7 +3069,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

0 comments on commit 4c634cc

Please sign in to comment.