diff --git a/src/Installer/Microsoft.Dotnet.Installation/DotnetInstallRoot.cs b/src/Installer/Microsoft.Dotnet.Installation/DotnetInstallRoot.cs index 0deeb807808d..c279f4a5d471 100644 --- a/src/Installer/Microsoft.Dotnet.Installation/DotnetInstallRoot.cs +++ b/src/Installer/Microsoft.Dotnet.Installation/DotnetInstallRoot.cs @@ -6,6 +6,7 @@ using System.Text; namespace Microsoft.Dotnet.Installation; + public record DotnetInstallRoot( string Path, InstallArchitecture Architecture); diff --git a/src/Installer/Microsoft.Dotnet.Installation/Internal/ArchiveDotnetExtractor.cs b/src/Installer/Microsoft.Dotnet.Installation/Internal/ArchiveDotnetExtractor.cs index acd883107d69..d5fc21ab6ca4 100644 --- a/src/Installer/Microsoft.Dotnet.Installation/Internal/ArchiveDotnetExtractor.cs +++ b/src/Installer/Microsoft.Dotnet.Installation/Internal/ArchiveDotnetExtractor.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Formats.Tar; using System.IO; using System.IO.Compression; @@ -30,6 +31,8 @@ public ArchiveDotnetExtractor(DotnetInstallRequest request, ReleaseVersion resol public void Prepare() { + using var activity = InstallationActivitySource.ActivitySource.StartActivity("DotnetInstaller.Prepare"); + using var releaseManifest = new ReleaseManifest(); var archiveName = $"dotnet-{Guid.NewGuid()}"; _archivePath = Path.Combine(scratchDownloadDirectory, archiveName + DnupUtilities.GetArchiveFileExtensionForPlatform()); @@ -90,6 +93,8 @@ public void Commit() public void Commit(IEnumerable existingSdkVersions) { + using var activity = InstallationActivitySource.ActivitySource.StartActivity("DotnetInstaller.Commit"); + if (_archivePath == null || !File.Exists(_archivePath)) { throw new InvalidOperationException("Archive not found. Make sure Prepare() was called successfully."); diff --git a/src/Installer/Microsoft.Dotnet.Installation/Internal/DotnetInstaller.cs b/src/Installer/Microsoft.Dotnet.Installation/Internal/DotnetInstaller.cs index 40fd2a48025f..66955c78c10b 100644 --- a/src/Installer/Microsoft.Dotnet.Installation/Internal/DotnetInstaller.cs +++ b/src/Installer/Microsoft.Dotnet.Installation/Internal/DotnetInstaller.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Text; using Microsoft.Deployment.DotNet.Releases; @@ -19,6 +20,12 @@ public DotnetInstaller(IProgressTarget progressTarget) public void Install(DotnetInstallRoot dotnetRoot, InstallComponent component, ReleaseVersion version) { + using var activity = InstallationActivitySource.ActivitySource.StartActivity("DotnetInstaller.Install"); + activity?.SetTag("install.root", dotnetRoot.Path); + activity?.SetTag("install.arch", dotnetRoot.Architecture.ToString()); + activity?.SetTag("install.component", component.ToString()); + activity?.SetTag("install.version", version.ToString()); + var installRequest = new DotnetInstallRequest(dotnetRoot, new UpdateChannel(version.ToString()), component, new InstallRequestOptions()); using ArchiveDotnetExtractor installer = new(installRequest, version, _progressTarget); diff --git a/src/Installer/Microsoft.Dotnet.Installation/Internal/InstallationActivitySource.cs b/src/Installer/Microsoft.Dotnet.Installation/Internal/InstallationActivitySource.cs new file mode 100644 index 000000000000..d66ba0d51bc2 --- /dev/null +++ b/src/Installer/Microsoft.Dotnet.Installation/Internal/InstallationActivitySource.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Reflection; + +namespace Microsoft.Dotnet.Installation.Internal; + +internal static class InstallationActivitySource +{ + private static readonly ActivitySource s_activitySource = new("Microsoft.Dotnet.Installer", + typeof(InstallationActivitySource).Assembly.GetCustomAttribute()?.InformationalVersion ?? "1.0.0"); + + public static ActivitySource ActivitySource => s_activitySource; +} diff --git a/src/Installer/Microsoft.Dotnet.Installation/Internal/ReleaseManifest.cs b/src/Installer/Microsoft.Dotnet.Installation/Internal/ReleaseManifest.cs index 85de5895bc2e..41ba700fa0e6 100644 --- a/src/Installer/Microsoft.Dotnet.Installation/Internal/ReleaseManifest.cs +++ b/src/Installer/Microsoft.Dotnet.Installation/Internal/ReleaseManifest.cs @@ -74,7 +74,7 @@ static IEnumerable GetChannelsForProduct(Product product) .Select(v => $"{v.Major}.{v.Minor}.{(v.Patch / 100)}xx") .Distinct() .ToList() - ]; + ]; } } diff --git a/src/Installer/Microsoft.Dotnet.Installation/Microsoft.Dotnet.Installation.csproj b/src/Installer/Microsoft.Dotnet.Installation/Microsoft.Dotnet.Installation.csproj index c9b2c6d4509f..0de054e6c753 100644 --- a/src/Installer/Microsoft.Dotnet.Installation/Microsoft.Dotnet.Installation.csproj +++ b/src/Installer/Microsoft.Dotnet.Installation/Microsoft.Dotnet.Installation.csproj @@ -19,6 +19,7 @@ +