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

Fix exception due to duplicate keys #9596

Merged
merged 2 commits into from
Nov 20, 2024
Merged
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 @@ -142,16 +142,19 @@ void ILogger.Shutdown()
void SendTelemetry()
{
// Filter out very fast targets (to reduce the cost of ordering) then take the top ten by elapsed time.
var durationByTarget = _targetRecordById.Values
// Note that targets can run multiple times, so the same target may appear more than once in the results.
object[][] targetDurations = _targetRecordById.Values
.Where(static record => record.Elapsed > new TimeSpan(ticks: 5 * TimeSpan.TicksPerMillisecond))
.OrderByDescending(record => record.Elapsed)
.ToDictionary(GetHashedTargetName, record => record.Elapsed.Milliseconds, StringComparers.TargetNames);
.Take(10)
.Select(record => new object[] { GetHashedTargetName(record), record.Elapsed.Milliseconds })
.ToArray();

telemetryService.PostProperties(
TelemetryEventName.DesignTimeBuildComplete,
[
(TelemetryPropertyName.DesignTimeBuildComplete.Succeeded, _succeeded),
(TelemetryPropertyName.DesignTimeBuildComplete.Targets, new ComplexPropertyValue(durationByTarget)),
(TelemetryPropertyName.DesignTimeBuildComplete.Targets, new ComplexPropertyValue(targetDurations)),
(TelemetryPropertyName.DesignTimeBuildComplete.ErrorCount, _errorCount),
(TelemetryPropertyName.DesignTimeBuildComplete.ErrorTargets, _errorTargets),
]);
Expand Down Expand Up @@ -179,11 +182,11 @@ void ReportBuildErrors()
/// <remarks>
/// If the target is shipped by Microsoft (or the user is internal), the target's name is returned unchanged.
/// </remarks>
private string GetHashedTargetName(TargetRecord target)
private string GetHashedTargetName(TargetRecord record)
{
return ImmutableInterlocked.GetOrAdd(
ref s_hashByTargetName,
(target.TargetName, target.IsMicrosoft),
(record.TargetName, record.IsMicrosoft),
GetHashedTargetName,
telemetryService);

Expand Down
Loading