Skip to content

Conversation

@baronfel
Copy link
Member

This PR continues the slicing off of the sub-parts of #49409 because it's so big.

This part builds on the previous PR, which introduced the ActivitySource for the CLI and the System.Diagnostics.DiagnosticsSource PackageReference. It adds activity usage to dotnet new invocation, and many parts of dotnet tool usage (including dnx and package downloading).

None of these actually light up in the current main branch because there are no listeners for the activities created.

@baronfel baronfel requested review from MiYanni and Copilot August 11, 2025 02:12
@baronfel baronfel requested a review from a team as a code owner August 11, 2025 02:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds activity spans for observability to template creation and tool operations in the .NET CLI. It builds on previous work by adding diagnostic activity tracking to dotnet new template instantiation and various dotnet tool commands including installation, execution, and package downloading.

Key changes include:

  • Adding activity spans to tool package downloading and extraction operations
  • Instrumenting template creation workflow with diagnostic activities
  • Adding activity tracking to tool installation and execution commands
  • Adding new localization strings for improved error messaging

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ToolPackageDownloaderBase.cs Adds activity spans for moving global tool content and updating runtime config
ToolPackageDownloader.cs Instruments package download and extraction operations with activities
ToolRunCommand.cs Adds activity span for local tool execution and removes nullable disable directive
ToolInstallGlobalOrToolPathCommand.cs Comprehensive refactoring with nullable reference types and activity instrumentation for tool installation
ToolExecuteCommand.cs Adds activity spans for tool location and execution operations
TemplateInvoker.cs Instruments template invocation and creation processes with activities
TemplateCommand.cs Adds activity spans for template constraint validation and invocation
InstantiateCommand.cs Instruments template group creation and command parsing with activities
Activities.cs Adds constants for trace parent environment variables
Various .xlf files Adds new localization entries for tool installation error message
CliCommandStrings.resx Adds new error message for missing package ID in tool installation

return await templateListCoordinator.DisplayCommandDescriptionAsync(instantiateArgs, cancellationToken).ConfigureAwait(false);
}
using var createActivity = Activities.Source.StartActivity("instantiate-command");
createActivity?.DisplayName = $"Invoke '{instantiateArgs.ShortName}'";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is instantiateArgs.ShortName already part of the telemetry?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenTelemetry.Exporter.OpenTelemetryProtocol exports Activity.DisplayName, not Activity.OperationName; so DisplayName is what matters for privacy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With regards to privacy - our overall plan for these spans is to not actually send them to the .NET SDK's telemetry collection. We plan to only ever collect the single 'main' activity at Program start, and that mostly because we need an Activity active in order for ActivityEvents to be sent, which is what our Telemetry data points become in an OTel world.

All other Activities we will conditionally disable with a Sampler when we do the full OTel integration - so they'll only be visible when local users are using the OTLP exporter, and at that point you as a user/operator are opting in to all of that data on your system so I believe the privacy constraints are satisfied.

@baronfel baronfel force-pushed the activity-usage-on-interesting-pathways branch from 4847bba to b8ecc9a Compare September 4, 2025 03:06
@baronfel baronfel merged commit 75826cc into dotnet:main Sep 5, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants