Skip to content

Commit

Permalink
Report whether audit is enabled during no-op restores (#6150)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolev92 authored Nov 20, 2024
1 parent 6e6c475 commit 46b470c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ public async Task<RestoreResult> ExecuteAsync(CancellationToken token)
telemetry.TelemetryEvent[IsCentralPackageTransitivePinningEnabled] = isCentralPackageTransitivePinningEnabled;
}

bool auditEnabled = AuditUtility.ParseEnableValue(
_request.Project.RestoreMetadata?.RestoreAuditProperties,
_request.Project.FilePath,
_logger);
telemetry.TelemetryEvent[AuditEnabled] = auditEnabled ? "enabled" : "disabled";

var restoreTime = Stopwatch.StartNew();

// Local package folders (non-sources)
Expand Down Expand Up @@ -340,11 +346,6 @@ await _logger.LogAsync(RestoreLogMessage.CreateWarning(NuGetLogCode.NU1803,
});
}

bool auditEnabled = AuditUtility.ParseEnableValue(
_request.Project.RestoreMetadata?.RestoreAuditProperties,
_request.Project.FilePath,
_logger);
telemetry.TelemetryEvent[AuditEnabled] = auditEnabled ? "enabled" : "disabled";
bool auditRan = false;
if (auditEnabled)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2966,7 +2966,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(

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

projectInformationEvent.Count.Should().Be(24);
projectInformationEvent.Count.Should().Be(25);
projectInformationEvent["RestoreSuccess"].Should().Be(true);
projectInformationEvent["NoOpResult"].Should().Be(true);
projectInformationEvent["IsCentralVersionManagementEnabled"].Should().Be(false);
Expand All @@ -2991,6 +2991,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
projectInformationEvent["NoOpCacheFileAgeDays"].Should().NotBeNull();
projectInformationEvent["UseLegacyDependencyResolver"].Should().BeOfType<bool>();
projectInformationEvent["UsedLegacyDependencyResolver"].Should().BeOfType<bool>();
projectInformationEvent["Audit.Enabled"].Should().BeOfType<string>();
}

[Fact]
Expand Down

0 comments on commit 46b470c

Please sign in to comment.