Skip to content

Add dashboard startup telemetry - #20846

Merged
James Newton-King (JamesNK) merged 4 commits into
mainfrom
feature/dashboard-startup-telemetry
Oct 10, 2026
Merged

James Newton-King (JamesNK) merged 4 commits into
mainfrom
feature/dashboard-startup-telemetry

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Description

Record an aspire/dashboard/startup product telemetry event so dashboard startup reliability and performance can be measured across launch contexts.

The event records the startup result, elapsed duration in milliseconds, and launch context. Failed startup attempts also include error.type: invalid_config for options validation failures, address_in_use for address conflicts, canceled for token-driven startup cancellation, or the exception type for other failures. The first result is recorded once; later shutdown or error handling does not replace it.

Launch context is read from the bound DashboardOptions.LaunchContext value. Configure it with Dashboard:LaunchContext or DASHBOARD__LAUNCHCONTEXT, which uses standard environment-variable binding. AppHost and CLI launchers set apphost and cli, respectively. Container deployments can explicitly set container; the dashboard does not infer container execution. Values are trimmed and matched case-insensitively against the known contexts, with missing or unrecognized values reported as unknown.

The startup timestamp is captured at the start of dashboard construction, before configuration and options validation. Telemetry uses the bound options snapshot rather than resolving validated options through DI, allowing configuration validation failures to retain their launch context. Dashboard execution starts the host separately from waiting for shutdown, so startup failures are recorded before the service provider is disposed. Existing product telemetry opt-out behavior is unchanged.

Configuration example

Container deployments can supply:

DASHBOARD__LAUNCHCONTEXT=container

The equivalent JSON configuration is:

{
  "Dashboard": {
    "LaunchContext": "container"
  }
}

Validation

Commands were run locally on Windows with MSBUILDTERMINALLOGGER=false for test runs. Quarantined and outerloop tests were excluded.

  • .\restore.cmd — passed.
  • Full dashboard suite — 2,199 passed, no failures:
dotnet test --project tests\Aspire.Dashboard.Tests\Aspire.Dashboard.Tests.csproj --no-launch-profile /p:InstallBrowsersForPlaywright=false -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
  • AppHost dashboard environment tests — 7 passed:
dotnet test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-method '*.ConfigureEnvironmentVariables_ConfiguresDashboardApplicationNameAndPersistenceMode' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
  • CLI dashboard environment test — 1 passed:
dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-method '*.DashboardRunCommand_ConfiguresDashboardDebugLogging' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
  • The integration regression test uses the launchers' shared environment-variable key, the real environment configuration provider, options binding, and the emitted startup event for both apphost and cli. Temporarily restoring the old environment-variable name reproduced the issue: both cases failed with unknown; restoring the fix made them pass. The tests also cover launch context on configuration validation failure.
  • Dashboard component suite — incomplete, not passed. The initial run stalled and was stopped. A bounded retry recorded 723 passed tests, no individual test failures, but timed out after five minutes with exit code 7:
dotnet test --project tests\Aspire.Dashboard.Components.Tests\Aspire.Dashboard.Components.Tests.csproj --no-build --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' --hangdump --hangdump-type none --hangdump-timeout 2m --timeout 5m

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

@github-actions

github-actions Bot commented Oct 9, 2026

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 -- 20846

Or

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

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Startup duration is measured too late, arbitrary context values can be exported, and start-time cancellation records the wrong failure type.

3 open findings
What changed in this PR

Adds dashboard startup telemetry for reliability, duration, failure type, and launch context.

Changes:

  • Adds startup telemetry recording and lifecycle handling.
  • Propagates AppHost/CLI launch contexts.
  • Adds focused telemetry and environment tests.
File Description
tests/​Aspire.Hosting.Tests/​Dashboard/​DashboardEventHandlersTests.cs Tests AppHost context propagation.
tests/​Aspire.Dashboard.Tests/​Telemetry/​DashboardStartupTelemetryTests.cs Tests one-time startup events.
tests/​Aspire.Cli.Tests/​Commands/​DashboardRunCommandTests.cs Tests CLI context propagation.
src/​Shared/​KnownDashboardLaunchContexts.cs Defines launch-context values.
src/​Shared/​DashboardConfigNames.cs Defines launch-context configuration.
src/​Aspire.Hosting/​Dashboard/​DashboardEventHandlers.cs Sets AppHost context.
src/​Aspire.Hosting/​Aspire.Hosting.csproj Links shared context constants.
src/​Aspire.Dashboard/​Telemetry/​TelemetryPropertyKeys.cs Defines startup properties.
src/​Aspire.Dashboard/​Telemetry/​TelemetryEventKeys.cs Defines startup event name.
src/​Aspire.Dashboard/​Telemetry/​KnownDashboardStartupFailureReasons.cs Defines stable failure reasons.
src/​Aspire.Dashboard/​Telemetry/​DashboardTelemetryService.cs Allows startup properties.
src/​Aspire.Dashboard/​Telemetry/​DashboardStartupTelemetry.cs Records startup outcomes.
src/​Aspire.Dashboard/​Program.cs Adjusts lifecycle disposal.
src/​Aspire.Dashboard/​DashboardWebApplication.cs Integrates startup telemetry.
src/​Aspire.Dashboard/​Aspire.Dashboard.csproj Links shared context constants.
src/​Aspire.Cli/​Commands/​DashboardRunCommand.cs Sets CLI context.
src/​Aspire.Cli/​Aspire.Cli.csproj Links shared context constants.

🧠 Review effort: Balanced

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Launch contexts currently resolve as unknown, and callback failures can incorrectly retain a successful startup result.

0 open findings

3 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Record startup success only after StartAsync completes

src/​Aspire.Dashboard/​DashboardWebApplication.cs:469

This marks startup successful before the rest of this callback and all other ApplicationStarted callbacks have completed. If a later callback throws, _app.StartAsync fails and RecordStartupFailure becomes a no-op because this telemetry object is one-shot, so the event reports success even though Run returns an error. Record success only after the awaited _app.StartAsync call completes.

Medium severity Read ASPIRE_DASHBOARD_LAUNCH_CONTEXT from the environment key

src/​Aspire.Dashboard/​Telemetry/​DashboardStartupTelemetry.cs:21

AppHost and CLI set ASPIRE_DASHBOARD_LAUNCH_CONTEXT, but this reads only Dashboard:LaunchContext. The environment provider only maps double underscores to configuration separators, so the single-underscore variable remains under its literal key and both launch paths emit unknown. Read EnvVarName first (with ConfigKey as a fallback), and update the normalization test to exercise the environment-variable key.

🧠 Review effort: Balanced

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny Mitch Denny (mitchdenny) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving with one non-blocking correctness finding: the launcher-provided environment alias is not read when resolving startup launch context.

Read startup launch context from bound dashboard options and use DASHBOARD__LAUNCHCONTEXT in launchers. Cover launcher environment binding and configuration-validation failures with regression tests.

Co-authored-by: Copilot <[email protected]>
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The implemented environment-variable name conflicts with the contract advertised in the PR description.

1 open finding

🧠 Review effort: Balanced

Comment thread src/Shared/DashboardConfigNames.cs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

55 / 98 PR test projects · 5 PR jobs, from 20 changed files.

Selected PR test projects (55 / 98)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Dashboard.Components.Tests, Aspire.Dashboard.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Provisioning.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests, Aspire.Templates.Tests, Infrastructure.Tests

Selected PR jobs (5)

cli-starter-validation, extension-e2e, native-dashboard-validation, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 43 of the 55 selected test projects come from a single change — src/Aspire.Hosting/Aspire.Hosting.csproj.

🔧 src/Aspire.Hosting/Aspire.Hosting.csproj (changed source)
→ 1 directly: Infrastructure.Tests
→ 42 via the project graph

show 42

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Provisioning.Tests (3 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🔧 src/Aspire.Dashboard/Aspire.Dashboard.csproj (changed source)
→ 1 directly: Infrastructure.Tests
→ 4 via the project graph: Aspire.Dashboard.Components.Tests, Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Testing.Tests

🧪 tests/Aspire.Hosting.Tests/Dashboard/DashboardEventHandlersTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests
→ 3 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Radius.Tests

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

📦 affected project Aspire.Dashboard
→ 1 test: Aspire.Templates.Tests

🔧 src/Aspire.Cli/Aspire.Cli.csproj (changed source)
→ 1 directly: Infrastructure.Tests

🧪 tests/Aspire.Cli.Tests/Commands/DashboardRunCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Dashboard.Tests/Integration/StartupTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Dashboard.Tests/Telemetry/DashboardStartupTelemetryTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Tests

🧪 tests/Aspire.Hosting.Tests/Dashboard/DashboardResourceTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Aspire.Cli.csproj, src/Aspire.Cli/Commands/DashboardRunCommand.cs, src/Aspire.Dashboard/Aspire.Dashboard.csproj, src/Aspire.Dashboard/Configuration/DashboardOptions.cs, src/Aspire.Dashboard/DashboardWebApplication.cs, src/Aspire.Dashboard/Program.cs, src/Aspire.Dashboard/Telemetry/DashboardStartupTelemetry.cs, src/Aspire.Dashboard/Telemetry/DashboardTelemetryService.cs, src/Aspire.Dashboard/Telemetry/KnownDashboardStartupFailureReasons.cs, src/Aspire.Dashboard/Telemetry/TelemetryEventKeys.cs, src/Aspire.Dashboard/Telemetry/TelemetryPropertyKeys.cs, src/Aspire.Hosting/Aspire.Hosting.csproj, src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs
• affected project Aspire.Cli
native-dashboard-validation affected project Aspire.Dashboard
polyglot • affected project Aspire.Cli
• affected project Aspire.Hosting.Azure.Provisioning.AppService
typescript-api-compat affected project Aspire.Cli

Selection computed for commit 5ed464a.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Startup can be reported as successful before callback completion, and constructor failures remain unrecorded.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Report construction and configuration failures in startup telemetry

src/​Aspire.Dashboard/​DashboardWebApplication.cs:155

Construction failures are still omitted from the startup event even though the telemetry contract says other startup failures report their exception type. For example, AddKeyPerFile can throw for a missing configured directory (already covered by Configuration_FileConfigDirectoryDoesntExist_Error), and this occurs before telemetry services are registered; Program also constructs DashboardWebApplication outside its try, so no failure event is emitted. Either add a bootstrap path that records constructor/configuration failures while honoring opt-out, or narrow the documented reliability contract to the failures that can actually be observed.

This issue also appears on line 473 of the same file.

🧠 Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@JamesNK
James Newton-King (JamesNK) merged commit 844cba8 into main Oct 10, 2026
662 of 665 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 10, 2026
aspire-repo-bot Bot added a commit to microsoft/aspire.dev that referenced this pull request Oct 10, 2026
Document the aspire/dashboard/startup product telemetry event added in
microsoft/aspire#20846: startup result, duration, launch context, and
failure error type. Add the Dashboard:LaunchContext configuration
option to the dashboard configuration reference.

Co-authored-by: Copilot <[email protected]>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1867

Generated by PR Documentation Check · copilot · auto · 77.2 AIC · ⌖ 13.7 AIC · ⊞ 20.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1867 targeting release/17.0.

Documented the new aspire/dashboard/startup telemetry event and Dashboard:LaunchContext option, triggered by signals cli_command_file_changed (evidence: DashboardRunCommand.cs sets DashboardConfigNames.DashboardLaunchContextName.EnvVarName to cli) and pr_body_has_cli_flag_mention. Updated dashboard/microsoft-collected-dashboard-telemetry.mdx with a new "Startup telemetry" section (result, duration, launch context, error types, opt-out) and dashboard/configuration.mdx with a Dashboard:LaunchContext row in the Other options table.

Note

This draft PR needs human review before merging.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants