Skip to content

Commit a902e0e

Browse files
Copilotbaronfel
andcommitted
Add System.Diagnostics.Activities for early data collection
- Added System.Diagnostics.DiagnosticSource package reference - Created ActivitySource for Microsoft.Dotnet.Installer library - Added Activity for DotnetInstaller.Install with tags for install root, arch, component, and version - Added sub-activities for Prepare and Commit stages in ArchiveDotnetExtractor Co-authored-by: baronfel <[email protected]>
1 parent f2d5d13 commit a902e0e

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

src/Installer/Microsoft.Dotnet.Installation/DotnetInstallRoot.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text;
77

88
namespace Microsoft.Dotnet.Installation;
9+
910
public record DotnetInstallRoot(
1011
string Path,
1112
InstallArchitecture Architecture);

src/Installer/Microsoft.Dotnet.Installation/Internal/ArchiveDotnetExtractor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Diagnostics;
67
using System.Formats.Tar;
78
using System.IO;
89
using System.IO.Compression;
@@ -30,6 +31,8 @@ public ArchiveDotnetExtractor(DotnetInstallRequest request, ReleaseVersion resol
3031

3132
public void Prepare()
3233
{
34+
using var activity = InstallationActivitySource.ActivitySource.StartActivity("DotnetInstaller.Prepare");
35+
3336
using var releaseManifest = new ReleaseManifest();
3437
var archiveName = $"dotnet-{Guid.NewGuid()}";
3538
_archivePath = Path.Combine(scratchDownloadDirectory, archiveName + DnupUtilities.GetArchiveFileExtensionForPlatform());
@@ -90,6 +93,8 @@ public void Commit()
9093

9194
public void Commit(IEnumerable<ReleaseVersion> existingSdkVersions)
9295
{
96+
using var activity = InstallationActivitySource.ActivitySource.StartActivity("DotnetInstaller.Commit");
97+
9398
if (_archivePath == null || !File.Exists(_archivePath))
9499
{
95100
throw new InvalidOperationException("Archive not found. Make sure Prepare() was called successfully.");

src/Installer/Microsoft.Dotnet.Installation/Internal/DotnetInstaller.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Diagnostics;
67
using System.Text;
78
using Microsoft.Deployment.DotNet.Releases;
89

@@ -19,6 +20,12 @@ public DotnetInstaller(IProgressTarget progressTarget)
1920

2021
public void Install(DotnetInstallRoot dotnetRoot, InstallComponent component, ReleaseVersion version)
2122
{
23+
using var activity = InstallationActivitySource.ActivitySource.StartActivity("DotnetInstaller.Install");
24+
activity?.SetTag("install.root", dotnetRoot.Path);
25+
activity?.SetTag("install.arch", dotnetRoot.Architecture.ToString());
26+
activity?.SetTag("install.component", component.ToString());
27+
activity?.SetTag("install.version", version.ToString());
28+
2229
var installRequest = new DotnetInstallRequest(dotnetRoot, new UpdateChannel(version.ToString()), component, new InstallRequestOptions());
2330

2431
using ArchiveDotnetExtractor installer = new(installRequest, version, _progressTarget);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics;
5+
6+
namespace Microsoft.Dotnet.Installation.Internal;
7+
8+
internal static class InstallationActivitySource
9+
{
10+
private static readonly ActivitySource s_activitySource = new("Microsoft.Dotnet.Installer", "1.0.0");
11+
12+
public static ActivitySource ActivitySource => s_activitySource;
13+
}

src/Installer/Microsoft.Dotnet.Installation/Internal/ReleaseManifest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static IEnumerable<string> GetChannelsForProduct(Product product)
7474
.Select(v => $"{v.Major}.{v.Minor}.{(v.Patch / 100)}xx")
7575
.Distinct()
7676
.ToList()
77-
];
77+
];
7878
}
7979

8080
}

src/Installer/Microsoft.Dotnet.Installation/Microsoft.Dotnet.Installation.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<ItemGroup>
2121
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" />
22+
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
2223
</ItemGroup>
2324

2425
</Project>

0 commit comments

Comments
 (0)