Add missing telemetry during failed upgrade steps (#1429)

* Add missing telemetry during failed upgrade steps

* Track exceptions in the apply phase + remove dispose

* Add nullable to telemetry in context

---------

Co-authored-by: Diana Soltani <dianasoltani@microsoft.com>
This commit is contained in:
Diana Soltani 2023-03-17 18:09:17 -07:00 коммит произвёл GitHub
Родитель 1cc53ee678
Коммит 49d6407c68
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 30 добавлений и 5 удалений

Просмотреть файл

@ -274,6 +274,11 @@
</childLayers>
</layer>
<layer Id="421742ad-4313-43e3-bcee-4c01cd3c4c8c" name="Microsoft.DotNet.UpgradeAssistant.Abstractions">
<dependencyToLayers>
<dependencyFromLayerToLayer Id="24b067d3-eca7-42f4-a15e-1b72a148fbe1" direction="Forward">
<layerMoniker Id="df9ce3fc-9390-4adf-a3cd-e94d15fbfc6c" />
</dependencyFromLayerToLayer>
</dependencyToLayers>
<references>
<reference Id="1c270efd-b624-4981-ab59-92abac31ed44" name="Microsoft.DotNet.UpgradeAssistant.Abstractions">
<ArtifactNode Label="Microsoft.DotNet.UpgradeAssistant.Abstractions" Category="CodeSchema_Project" Id="(Assembly=../../src/common/Microsoft.DotNet.UpgradeAssistant.Abstractions/Microsoft.DotNet.UpgradeAssistant.Abstractions.csproj)">

Просмотреть файл

@ -61,7 +61,7 @@
</layerShape>
</nestedChildShapes>
</layerShape>
<dependencyConnector edgePoints="[(27.90625 : 6.25); (27.90625 : 7.75)]" fixedFrom="Algorithm" fixedTo="Algorithm" customColor="113, 111, 110">
<dependencyConnector edgePoints="[(27.90625 : 6.25); (27.90625 : 7.75)]" fixedFrom="NotFixed" fixedTo="NotFixed" customColor="113, 111, 110">
<dependencyFromLayerToLayerMoniker Id="153f1107-fc9d-4101-843e-a911901b91e4" />
<nodes>
<layerShapeMoniker Id="4be49585-80f9-43a6-9897-b31e107d49a0" />
@ -88,7 +88,7 @@
<layerShape Id="936f240c-a956-4a13-a4c1-f7405040ccc5" absoluteBounds="29.5, 2.25, 2, 0.75" customColor="161, 199, 231">
<layerMoniker Id="a9443ba7-6840-4dd8-82e8-ae589e769244" />
</layerShape>
<dependencyConnector edgePoints="[(30.84375 : 3); (30.84375 : 7.75)]" fixedFrom="Algorithm" fixedTo="Algorithm" customColor="113, 111, 110">
<dependencyConnector edgePoints="[(30.84375 : 3); (30.84375 : 7.75)]" fixedFrom="NotFixed" fixedTo="NotFixed" customColor="113, 111, 110">
<dependencyFromLayerToLayerMoniker Id="6ef70d28-03de-4271-98c8-5dcc00559617" />
<nodes>
<layerShapeMoniker Id="936f240c-a956-4a13-a4c1-f7405040ccc5" />
@ -126,7 +126,7 @@
<layerShapeMoniker Id="15cc72cd-c4b3-489b-8e06-1110102a86ec" />
</nodes>
</dependencyConnector>
<dependencyConnector edgePoints="[(23.5 : 3); (23.5 : 7)]" fixedFrom="Algorithm" fixedTo="Algorithm" customColor="113, 111, 110">
<dependencyConnector edgePoints="[(23.5 : 3); (23.5 : 7)]" fixedFrom="NotFixed" fixedTo="NotFixed" customColor="113, 111, 110">
<dependencyFromLayerToLayerMoniker Id="6774b57b-6981-4d0d-93da-1a91ee5db314" />
<nodes>
<layerShapeMoniker Id="291a0e27-c527-4a0a-89a7-4ac0551a6ec2" />
@ -140,12 +140,19 @@
<layerShapeMoniker Id="b76fe73a-a7f7-42bf-aeca-470a23cddcee" />
</nodes>
</dependencyConnector>
<dependencyConnector edgePoints="[(24.6875 : 6.25); (24.6875 : 7)]" fixedFrom="Algorithm" fixedTo="Algorithm" customColor="113, 111, 110">
<dependencyConnector edgePoints="[(24.6875 : 6.25); (24.6875 : 7)]" fixedFrom="NotFixed" fixedTo="NotFixed" customColor="113, 111, 110">
<dependencyFromLayerToLayerMoniker Id="c9747cf9-f7c8-42a1-a265-263d589593bf" />
<nodes>
<layerShapeMoniker Id="4be49585-80f9-43a6-9897-b31e107d49a0" />
<layerShapeMoniker Id="e78c1014-0b86-46de-873d-5d087cf4a0e6" />
</nodes>
</dependencyConnector>
<dependencyConnector edgePoints="[(17.90625 : 7.75); (17.90625 : 5.25)]" fixedFrom="Algorithm" fixedTo="Algorithm" customColor="113, 111, 110">
<dependencyFromLayerToLayerMoniker Id="24b067d3-eca7-42f4-a15e-1b72a148fbe1" />
<nodes>
<layerShapeMoniker Id="b76fe73a-a7f7-42bf-aeca-470a23cddcee" />
<layerShapeMoniker Id="c4f9fc8c-5261-47e9-82fb-401999cdb107" />
</nodes>
</dependencyConnector>
</nestedChildShapes>
</layerDiagram>

Просмотреть файл

@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.UpgradeAssistant.Analysis;
using Microsoft.DotNet.UpgradeAssistant.Telemetry;
namespace Microsoft.DotNet.UpgradeAssistant
{
@ -44,5 +45,7 @@ namespace Microsoft.DotNet.UpgradeAssistant
IUpgradeContextProperties Properties { get; }
ICollector<OutputResultDefinition> Results { get; }
ITelemetry? Telemetry { get; }
}
}

Просмотреть файл

@ -49,6 +49,9 @@
<Version>5.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\components\Microsoft.DotNet.UpgradeAssistant.Telemetry\Microsoft.DotNet.UpgradeAssistant.Telemetry.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="build\*" Pack="true" PackagePath="" />

Просмотреть файл

@ -147,6 +147,7 @@ namespace Microsoft.DotNet.UpgradeAssistant
{
(Status, StatusDetails) = (UpgradeStepStatus.Failed, "Unexpected error initializing step.");
Logger.LogError(e, "Unexpected error initializing step");
context.Telemetry?.TrackException(e);
}
}
@ -199,6 +200,7 @@ namespace Microsoft.DotNet.UpgradeAssistant
(Status, StatusDetails) = (UpgradeStepStatus.Failed, $"Unexpected error applying upgrade step '{Title}'");
Logger.LogError(e, "Unexpected error applying upgrade step {StepTitle}", Title);
context.AddResultForStep(this, context.CurrentProject?.GetFile()?.FilePath ?? string.Empty, Status, StatusDetails, details: e.ToString(), outputLevel: OutputLevel.Error);
context.Telemetry?.TrackException(e);
return false;
}
}

Просмотреть файл

@ -12,6 +12,7 @@ using Microsoft.Build.Evaluation;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.DotNet.UpgradeAssistant.Analysis;
using Microsoft.DotNet.UpgradeAssistant.Telemetry;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -55,11 +56,14 @@ namespace Microsoft.DotNet.UpgradeAssistant.MSBuild
public UpgradeStep? CurrentStep { get; set; }
public ITelemetry Telemetry { get; }
public MSBuildWorkspaceUpgradeContext(
IOptions<WorkspaceOptions> options,
Factories factories,
Func<MSBuildWorkspaceUpgradeContext, FileInfo, MSBuildProject> projectFactory,
ILogger<MSBuildWorkspaceUpgradeContext> logger)
ILogger<MSBuildWorkspaceUpgradeContext> logger,
ITelemetry telemetry)
{
_projectFactory = projectFactory ?? throw new ArgumentNullException(nameof(projectFactory));
_options = options ?? throw new ArgumentNullException(nameof(options));
@ -67,6 +71,7 @@ namespace Microsoft.DotNet.UpgradeAssistant.MSBuild
_projectCache = new Dictionary<string, IProject>(StringComparer.OrdinalIgnoreCase);
Telemetry = telemetry ?? throw new ArgumentNullException(nameof(telemetry));
Properties = new UpgradeContextProperties();
SolutionInfo = factories.CreateSolutionInfo(InputPath);
GlobalProperties = CreateProperties(options.Value);