Skip to content
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
6 changes: 6 additions & 0 deletions src/Cli/dotnet/Commands/MSBuild/MSBuildLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed class MSBuildLogger : INodeLogger
// These two events are aggregated and sent at the end of the build.
internal const string TaskFactoryTelemetryAggregatedEventName = "build/tasks/taskfactory";
internal const string TasksTelemetryAggregatedEventName = "build/tasks";
internal const string TasksDetailsTelemetryEventName = "build/tasks/details";

internal const string SdkTaskBaseCatchExceptionTelemetryEventName = "taskBaseCatchException";
internal const string PublishPropertiesTelemetryEventName = "PublishProperties";
Expand Down Expand Up @@ -206,6 +207,11 @@ internal static void FormatAndSend(ITelemetryClient? telemetry, TelemetryEventAr
toBeHashed: ["RuleId", "CheckFriendlyName"]
);
break;
case TasksDetailsTelemetryEventName:
TrackEvent(telemetry, $"msbuild/{TasksDetailsTelemetryEventName}", args.Properties,
toBeHashed: []
);
break;
// Pass through events that don't need special handling
case SdkTaskBaseCatchExceptionTelemetryEventName:
case PublishPropertiesTelemetryEventName:
Expand Down
25 changes: 25 additions & 0 deletions test/dotnet.Tests/CommandTests/MSBuild/GivenMSBuildLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,30 @@ public void ItIgnoresNonIntegerPropertiesDuringAggregation()
fakeTelemetry.LogEntry.Properties.Should().NotContainKey("InvalidProperty");
fakeTelemetry.LogEntry.Properties.Should().NotContainKey("InvalidProperty2");
}

[TestMethod]
public void ItForwardsTaskDetailsEvent()
{
var fakeTelemetry = new FakeTelemetry();
var telemetryEventArgs = new TelemetryEventArgs
{
EventName = MSBuildLogger.TasksDetailsTelemetryEventName,
Properties = new Dictionary<string, string>
{
{ "Tasks", "[{\"Name\":\"Copy\",\"ExecutionsCount\":10}]" },
{ "TaskCount", "1" },
{ "TotalTaskCount", "1" }
}
};

MSBuildLogger.FormatAndSend(fakeTelemetry, telemetryEventArgs);

fakeTelemetry.LogEntry.Should().NotBeNull();
fakeTelemetry.LogEntry.EventName.Should().Be($"msbuild/{MSBuildLogger.TasksDetailsTelemetryEventName}");
fakeTelemetry.LogEntry.Properties.Keys.Count.Should().Be(3);
fakeTelemetry.LogEntry.Properties["Tasks"].Should().Be("[{\"Name\":\"Copy\",\"ExecutionsCount\":10}]");
fakeTelemetry.LogEntry.Properties["TaskCount"].Should().Be("1");
fakeTelemetry.LogEntry.Properties["TotalTaskCount"].Should().Be("1");
}
}
}
Loading