-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add activity spans for template creation and most tool usage #50163
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
Add activity spans for template creation and most tool usage #50163
Conversation
There was a problem hiding this 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 |
src/Cli/dotnet/Commands/Tool/Install/ToolInstallGlobalOrToolPathCommand.cs
Show resolved
Hide resolved
| return await templateListCoordinator.DisplayCommandDescriptionAsync(instantiateArgs, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| using var createActivity = Activities.Source.StartActivity("instantiate-command"); | ||
| createActivity?.DisplayName = $"Invoke '{instantiateArgs.ShortName}'"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/TemplateCommand.cs
Outdated
Show resolved
Hide resolved
4847bba to
b8ecc9a
Compare
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 newinvocation, and many parts ofdotnet toolusage (includingdnxand package downloading).None of these actually light up in the current
mainbranch because there are no listeners for the activities created.