Skip to content

Add profiling spans for aspire add#17347

Merged
davidfowl merged 2 commits into
mainfrom
add-command-profiling-telemetry
May 21, 2026
Merged

Add profiling spans for aspire add#17347
davidfowl merged 2 commits into
mainfrom
add-command-profiling-telemetry

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

@davidfowl davidfowl commented May 21, 2026

Description

Instruments aspire add with profiling spans so that --capture-profile captures where add time is spent — package search, package selection, and installation — alongside the existing run/ls profiling.

What changed

  • New profiling spans in ProfilingTelemetry:

    • aspire/cli/add — root span for the whole add command
    • aspire/cli/add.find_apphost — AppHost project discovery
    • aspire/cli/add.get_configured_channel — NuGet channel lookup via msbuild
    • aspire/cli/add.search_packagesdotnet package search for Aspire integrations
    • aspire/cli/add.select_package — records match count/kind and selected package (dispatch only, no user think time)
    • aspire/cli/add.select_package.prompt — wraps interactive package/version prompts so user think time is filterable
    • aspire/cli/add.stop_existing_instance — stopping any running AppHost before add
    • aspire/cli/add.packagedotnet package add installation
  • New tags: aspire.cli.add.integration.name, version_specified, source_specified, configured_channel, package.search_result_count, package.match_count, package.match_kind (exact/fuzzy/none), package.id, package.version, package.channel, package.success

  • Root aspire/cli/add span is marked with error status and exit code on all graceful failure paths (not just thrown exceptions).

User-facing usage

aspire add redis --version 9.5.0 --capture-profile --capture-profile-output add-redis.zip

Sample profile output (from SimplePipelines.AppHost playground):

aspire/cli/add               4.1s   package.id=Aspire.Hosting.Redis; package.version=9.5.0; search_result_count=120
  aspire/cli/add.find_apphost  453ms
  aspire/cli/add.search_packages  289ms  search_result_count=120
  aspire/cli/add.select_package     0.1ms  match_count=1; match_kind=exact
  aspire/cli/add.stop_existing_instance  3ms
  aspire/cli/add.package       3.0s   success=true
    process dotnet package add ...  3.0s

dotnet package search and dotnet package add each appear as child process dotnet spans so it's easy to see which subprocess dominates add time.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

Instrument the add command with profiling spans for AppHost discovery, package search and selection, running instance cleanup, and package installation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidfowl davidfowl requested a review from mitchdenny as a code owner May 21, 2026 05:39
Copilot AI review requested due to automatic review settings May 21, 2026 05:39
@davidfowl davidfowl requested a review from JamesNK as a code owner May 21, 2026 05:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17347

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17347"

Copy link
Copy Markdown
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

Adds profiling-only Activity spans to the Aspire CLI’s aspire add flow so --capture-profile exports clearly show where time is spent while discovering an AppHost, resolving channels/packages, stopping running instances, and installing the selected integration.

Changes:

  • Introduced aspire/cli/add* profiling span names and add-specific tags in ProfilingTelemetry.
  • Instrumented AddCommand to emit spans for AppHost discovery, configured channel lookup, package search/selection, stopping running instances, and package installation (with relevant tags).
  • Added a unit test validating the add-specific spans/tags are created and carry the profiling session context.
Show a summary per file
File Description
src/Aspire.Cli/Telemetry/ProfilingTelemetry.cs Adds add-command span names/tags and helper APIs to create/annotate add-specific profiling activities.
src/Aspire.Cli/Commands/AddCommand.cs Wraps key aspire add stages in profiling spans and emits add-specific tags (selection, counts, language, install result).
tests/Aspire.Cli.Tests/Telemetry/ProfilingTelemetryTests.cs Adds coverage ensuring add-specific spans are created with expected operation names, tags, and session propagation.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

Comment thread src/Aspire.Cli/Telemetry/ProfilingTelemetry.cs
Copy link
Copy Markdown
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

Reviewed the new aspire add profiling spans. Instrumentation is mostly clean and the unit tests cover each new scope and tag. Flagging three observability concerns — one moderate (1), two minor (2, 3).

Comment thread src/Aspire.Cli/Commands/AddCommand.cs
Comment thread src/Aspire.Cli/Commands/AddCommand.cs
Comment thread src/Aspire.Cli/Commands/AddCommand.cs Outdated
Separate interactive package selection prompts from the select-package span, record package match kind, and mark the root add profiling span on graceful failure paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidfowl davidfowl merged commit b8ab1cd into main May 21, 2026
903 of 909 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

CLI E2E Tests unknown — 95 passed, 0 failed, 5 unknown (commit f52b601)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View recording
AddPackageWhileAppHostRunningDetached ▶️ View recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View recording
AgentInitCommand_DefaultSelection_InstallsDefaultSkills ▶️ View recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View recording
AgentMcpListStructuredLogsFromStarterAppCore ▶️ View recording
AllPublishMethodsBuildDockerImages ▶️ View recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View recording
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles ▶️ View recording
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive ▶️ View recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View recording
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent ▶️ View recording
Banner_DisplayedOnFirstRun ▶️ View recording
Banner_DisplayedWithExplicitFlag ▶️ View recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View recording
CertificatesClean_RemovesCertificates ▶️ View recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View recording
CreateAndRunAspireStarterProject ▶️ View recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View recording
CreateAndRunEmptyAppHostProject ▶️ View recording
CreateAndRunJavaEmptyAppHostProject ▶️ View recording
CreateAndRunJsReactProject ▶️ View recording
CreateAndRunPythonReactProject ▶️ View recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View recording
CreateAndRunTypeScriptStarterProject ▶️ View recording
CreateJavaAppHostWithViteApp ▶️ View recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View recording
DashboardRunWithAgentMcpCore ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTracesCore ▶️ View recording
DeployK8sBasicApiService ▶️ View recording
DeployK8sWithExternalHelmChart ▶️ View recording
DeployK8sWithGarnet ▶️ View recording
DeployK8sWithMongoDB ▶️ View recording
DeployK8sWithMySql ▶️ View recording
DeployK8sWithPostgres ▶️ View recording
DeployK8sWithRabbitMQ ▶️ View recording
DeployK8sWithRedis ▶️ View recording
DeployK8sWithSqlServer ▶️ View recording
DeployK8sWithValkey ▶️ View recording
DeployTypeScriptAppToKubernetes ▶️ View recording
DescribeCommandResolvesReplicaNames ▶️ View recording
DescribeCommandShowsRunningResources ▶️ View recording
DetachFormatJsonProducesValidJson ▶️ View recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View recording
DoListStepsShowsPipelineSteps ▶️ View recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View recording
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain ▶️ View recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View recording
GlobalMigration_PreservesAllValueTypes ▶️ View recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View recording
JavaScriptHostingApisRunFromTypeScriptAppHost ▶️ View recording
LatestCliCanStartStableChannelAppHost ▶️ View recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View recording
LogLevelTrace_ProducesTraceEntriesInCliLogFile ▶️ View recording
LogsCommandShowsResourceLogs ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterAppIsolated ▶️ View recording
PsCommandListsRunningAppHost ▶️ View recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View recording
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts ▶️ View recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View recording
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries ▶️ View recording
ResourceCommand_FailsWhenInteractionServiceIsRequired ▶️ View recording
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput ▶️ View recording
RestoreGeneratesSdkFiles ▶️ View recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View recording
RunPublishFailureScenarioAsync ▶️ View recording
RunReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
RunReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
SecretCrudOnDotNetAppHost ▶️ View recording
SecretCrudOnTypeScriptAppHost ▶️ View recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View recording
StartReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
StartReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
StopAllAppHostsFromAppHostDirectory ▶️ View recording
StopJavaPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopNonInteractiveSingleAppHost ▶️ View recording
StopTypeScriptPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View recording
UpdateProjectChannelToStable_TypeScript_PicksUpStablePackages ▶️ View recording

📹 Recordings uploaded automatically from CI run #26237621259

aspire-repo-bot Bot added a commit to microsoft/aspire.dev that referenced this pull request May 21, 2026
Documents the --capture-profile and --capture-profile-output options
for aspire add, and the new profiling spans and tags introduced by
microsoft/aspire#17347.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot
Copy link
Copy Markdown
Contributor

Pull request created: #1037

Generated by PR Documentation Check

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1037 targeting release/13.4.

Updated src/frontend/src/content/docs/reference/cli/commands/aspire-add.mdx to document the new --capture-profile and --capture-profile-output options, a Profiling spans reference table covering all 8 new aspire/cli/add* span names, a tags table with all 11 add-specific OpenTelemetry tags, and an example showing aspire add redis --capture-profile --capture-profile-output add-redis.zip.

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants