-
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
Changes from all commits
1a2426b
5804b1c
e72fa0e
b8ecc9a
33b5b56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,13 +51,13 @@ internal InstantiateCommand( | |
| Arity = new ArgumentArity(0, 999) | ||
| }; | ||
|
|
||
| internal IReadOnlyList<Option> PassByOptions { get; } = new Option[] | ||
| { | ||
| internal IReadOnlyList<Option> PassByOptions { get; } = | ||
| [ | ||
| SharedOptions.ForceOption, | ||
| SharedOptions.NameOption, | ||
| SharedOptions.DryRunOption, | ||
| SharedOptions.NoUpdateCheckOption | ||
| }; | ||
| ]; | ||
|
|
||
| internal static Task<NewCommandStatus> ExecuteAsync( | ||
| NewCommandArgs newCommandArgs, | ||
|
|
@@ -74,6 +74,7 @@ internal static async Task<IEnumerable<TemplateGroup>> GetTemplateGroupsAsync( | |
| HostSpecificDataLoader hostSpecificDataLoader, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| using var createTemplateGroupsActivity = Activities.Source.StartActivity("create-template-groups"); | ||
| IReadOnlyList<ITemplateInfo> templates = await templatePackageManager.GetTemplatesAsync(cancellationToken).ConfigureAwait(false); | ||
| return TemplateGroup.FromTemplateList(CliTemplateInfo.FromTemplateInfo(templates, hostSpecificDataLoader)); | ||
| } | ||
|
|
@@ -84,6 +85,7 @@ internal static HashSet<TemplateCommand> GetTemplateCommand( | |
| TemplatePackageManager templatePackageManager, | ||
| TemplateGroup templateGroup) | ||
| { | ||
| using var getTemplateActivity = Activities.Source.StartActivity("get-template-command"); | ||
| //groups templates in the group by precedence | ||
| foreach (IGrouping<int, CliTemplateInfo> templateGrouping in templateGroup.Templates.GroupBy(g => g.Precedence).OrderByDescending(g => g.Key)) | ||
| { | ||
|
|
@@ -114,7 +116,7 @@ internal static HashSet<TemplateCommand> GetTemplateCommand( | |
| templateGroup, | ||
| candidates); | ||
| } | ||
| return new HashSet<TemplateCommand>(); | ||
| return []; | ||
| } | ||
|
|
||
| internal static void HandleNoMatchingTemplateGroup(InstantiateCommandArgs instantiateArgs, IEnumerable<TemplateGroup> templateGroups, IReporter reporter) | ||
|
|
@@ -204,6 +206,8 @@ private static async Task<NewCommandStatus> ExecuteIntAsync( | |
|
|
||
| return await templateListCoordinator.DisplayCommandDescriptionAsync(instantiateArgs, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| using var createActivity = Activities.Source.StartActivity("instantiate-command"); | ||
| createActivity?.DisplayName = $"Invoke '{instantiateArgs.ShortName}'"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| IEnumerable<TemplateGroup> allTemplateGroups = await GetTemplateGroupsAsync( | ||
| templatePackageManager, | ||
|
|
@@ -273,10 +277,11 @@ private static async Task<NewCommandStatus> HandleTemplateInstantiationAsync( | |
| { | ||
| TemplateCommand templateCommandToRun = candidates.Single(); | ||
| args.Command.Subcommands.Add(templateCommandToRun); | ||
|
|
||
| var templateParseActivity = Activities.Source.StartActivity("reparse-for-template"); | ||
| ParseResult updatedParseResult = args.ParseResult.RootCommandResult.Command.Parse( | ||
| args.ParseResult.Tokens.Select(t => t.Value).ToArray(), | ||
| args.ParseResult.Configuration); | ||
| templateParseActivity?.Stop(); | ||
| return await candidates.Single().InvokeAsync(updatedParseResult, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| else if (candidates.Any()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.