Skip to content

Add OTEL telemetry analysis commands#17362

Draft
davidfowl wants to merge 1 commit into
mainfrom
davidfowl/aspire-otel-perf
Draft

Add OTEL telemetry analysis commands#17362
davidfowl wants to merge 1 commit into
mainfrom
davidfowl/aspire-otel-perf

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

@davidfowl davidfowl commented May 21, 2026

Description

Aspire already exposes raw OpenTelemetry logs, spans, and traces through the CLI, but quick performance investigations still require users to manually inspect telemetry or export data into another tool. This adds first-pass aspire otel analysis commands that answer common latency questions directly from either a live dashboard or a saved Aspire export/profile archive.

The new commands are:

aspire otel summary [resource] [--file telemetry.zip] [--format json]
aspire otel top-traces [resource] [--file telemetry.zip] [--top 20] [--format json]
aspire otel wall-time [resource] [--file telemetry.zip] [--top 20] [--format json]
aspire otel span-stats [resource] [--file telemetry.zip] [--group-by name|resource] [--top 20] [--format json]

They default to analyzing the live dashboard telemetry API and use --file to analyze exported telemetry offline. Archive analysis merges all traces/*.json entries before grouping by trace ID so traces that cross resources are analyzed as complete traces. wall-time reports trace wall-clock duration plus span interval coverage, gaps, overlap, and span-sum ratio without implying CPU utilization.

Command help:

Commands:
  logs <resource>        View structured logs from the Dashboard telemetry API
  spans <resource>       View spans from the Dashboard telemetry API
  traces <resource>      View traces from the Dashboard telemetry API
  summary <resource>     Summarize trace latency, span counts, and errors
  top-traces <resource>  Show top traces by wall-clock duration
  wall-time <resource>   Analyze trace wall-clock time, span coverage, gaps, and overlap
  span-stats <resource>  Aggregate span duration statistics

Sample output from an archive:

$ aspire otel summary --file telemetry.zip
┌──────────────────┬───────┐
│ Metric           │ Value │
├──────────────────┼───────┤
│ Resources        │ 2     │
│ Traces           │ 3     │
│ Spans            │ 4     │
│ Error traces     │ 1     │
│ Error spans      │ 1     │
│ Average duration │ 0.15s │
│ P50 duration     │ 0.15s │
│ P95 duration     │ 0.2s  │
│ P99 duration     │ 0.2s  │
│ Max duration     │ 0.2s  │
└──────────────────┴───────┘
$ aspire otel top-traces --file telemetry.zip --top 3
┌──────────┬───────┬────────┬──────────┬────────────────┬──────────┐
│ Duration │ Spans │ Status │ Resource │ Name           │ Trace ID │
├──────────┼───────┼────────┼──────────┼────────────────┼──────────┤
│ 0.2s     │ 2     │ OK     │ frontend │ GET /checkout  │ aaaaaaa  │
│ 0.15s    │ 1     │ ERR    │ backend  │ GET /inventory │ ccccccc  │
│ 0.1s     │ 1     │ OK     │ frontend │ GET /products  │ bbbbbbb  │
└──────────┴───────┴────────┴──────────┴────────────────┴──────────┘
$ aspire otel wall-time --file telemetry.zip --top 3
┌───────┬──────────┬─────────┬─────┬─────────┬───────┬───────┬────────┬──────────┬────────────────┬──────────┐
│ Wall  │ Span sum │ Covered │ Gap │ Overlap │ Ratio │ Spans │ Status │ Resource │ Name           │ Trace ID │
├───────┼──────────┼─────────┼─────┼─────────┼───────┼───────┼────────┼──────────┼────────────────┼──────────┤
│ 0.2s  │ 0.32s    │ 0.2s    │ 0μs │ 0.12s   │ 1.6x  │ 2     │ OK     │ frontend │ GET /checkout  │ aaaaaaa  │
│ 0.15s │ 0.15s    │ 0.15s   │ 0μs │ 0μs     │ 1x    │ 1     │ ERR    │ backend  │ GET /inventory │ ccccccc  │
│ 0.1s  │ 0.1s     │ 0.1s    │ 0μs │ 0μs     │ 1x    │ 1     │ OK     │ frontend │ GET /products  │ bbbbbbb  │
└───────┴──────────┴─────────┴─────┴─────────┴───────┴───────┴────────┴──────────┴────────────────┴──────────┘
$ aspire otel span-stats --file telemetry.zip --group-by resource --top 3
┌──────────┬───────┬────────┬───────┬───────┬───────┬───────┐
│ Group    │ Count │ Errors │ Avg   │ P95   │ Max   │ Total │
├──────────┼───────┼────────┼───────┼───────┼───────┼───────┤
│ frontend │ 2     │ 0      │ 0.15s │ 0.2s  │ 0.2s  │ 0.3s  │
│ backend  │ 2     │ 1      │ 0.14s │ 0.15s │ 0.15s │ 0.27s │
└──────────┴───────┴────────┴───────┴───────┴───────┴───────┘

Validation:

  • dotnet build src/Aspire.Cli/Aspire.Cli.csproj /p:SkipNativeBuild=true --no-restore
  • dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.TelemetryCommandTests" --filter-class "*.TelemetryAnalysisCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
  • Generated otel --help output for the new command names.

Fixes # (issue)

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Add Aspire CLI OTEL analysis commands for summarizing trace latency, listing top traces, aggregating span duration statistics, and analyzing wall-clock span coverage from either a live dashboard or an exported telemetry archive.

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

🚀 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 -- 17362

Or

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

@github-actions
Copy link
Copy Markdown
Contributor

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

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 #26244449803

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.

1 participant