Skip to content

Migrate Dashboard product telemetry and add CLI Azure Monitor log export - #20730

Merged
James Newton-King (JamesNK) merged 25 commits into
mainfrom
dashboard-azure-monitor-telemetry
Oct 9, 2026
Merged

James Newton-King (JamesNK) merged 25 commits into
mainfrom
dashboard-azure-monitor-telemetry

Conversation

@JamesNK

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

Copy link
Copy Markdown
Member

Description

Move Dashboard product usage/error reporting from the IDE telemetry transport to direct Azure Monitor export, and add Azure Monitor log export for CLI product events and errors. Both changes are committed and included in this PR.

Dashboard reporting can now work for CLI-launched, standalone, and deployed dashboards without an IDE debug session or an OpenTelemetry Collector. CLI reported events and errors remain remotely deliverable after the shared recorder switches from activity events to structured logs; CLI operation spans continue to use the existing trace exporter.

The Dashboard and CLI use separate built-in Application Insights destinations. The CLI destination is unchanged. No dependency version changes are required.

Implementation

  • Share activity/event/error recording through AspireTelemetryBase and exporter configuration through AspireTelemetryExporter, while retaining product-specific instrumentation, enablement, metadata, and privacy policies.
  • Use AzureMonitorTelemetryProvider to configure and own Azure Monitor trace/log providers and private logging services. Each product manager creates the isolated pipeline after checking consent, attaches its event logger, detaches it before shutdown, and flushes/shuts down traces and logs concurrently.
  • Record product events at Information level through private loggers in Aspire.Cli.Reported.Events or Aspire.Dashboard.Reported.Events, respectively. Ordinary application/framework logs are excluded by logger-factory isolation, not by product-specific category or level filters at the logger-provider or batch-processor boundaries. Scopes are excluded.
  • Record usage events and errors immediately as Information-level structured logs, with the event name as the message and microsoft.operation_name. Azure Monitor stores these exception-free log records in traces / AppTraces. They do not create fallback spans or attach activity events, and use ambient trace/span correlation only when available.
  • Apply Dashboard privacy filtering and scalar string bounds before recording; collection values are excluded. CLI events retain the CLI's existing internally supplied metadata and exception-detail policy. CLI string collections use string.Join(",") for log attributes; activity tags retain typed values.
  • Keep CLI diagnostic/profiling OTLP providers and Dashboard diagnostic OTLP tracing separate from product export. Ordinary CLI file/console logging remains available after product-provider shutdown; its independent OpenTelemetry logging registration does not configure a log exporter.
  • Use aspire-dashboard and aspire-cli as the product resource names for both Azure Monitor traces and logs. Resource versions use AssemblyVersionHelper.GetInformationalVersion, including build metadata when present. Resource names identify logical roles; the connection strings select the destination Application Insights resources.
  • Separate Dashboard configuration, instrumentation, and hosted provider lifecycle into DashboardTelemetryConfiguration, DashboardTelemetryService, and DashboardTelemetryManager. Provider initialization failures produce a local warning and allow Dashboard startup without product export.
  • Keep Dashboard resource commands activity-based, assigning their result and ending the activity before the UI recovery delay.
  • Remove the Dashboard sender interface, HTTP transport/serialization contracts, operation wrappers, and IDE-specific telemetry types. Preserve the VS Code extension's legacy HTTP endpoints for older dashboards.
  • Document the current shared product pipeline, privacy, lifecycle, and agent usage reporting in Aspire product telemetry, separate from application observability.

User-facing usage

Dashboard reporting is independent of IDE telemetry preferences. To opt out for everyone accessing a Dashboard, set this before starting the AppHost or Dashboard process:

$env:ASPIRE_DASHBOARD_TELEMETRY_OPTOUT = 'true'

The value 1 is also supported. Direct and AppHost-forwarded opt-outs are combined so either can disable reporting. The Dashboard settings notice reflects resolved enablement.

CLI product traces and logs both honor ASPIRE_CLI_TELEMETRY_OPTOUT=true or 1 and command selection. Help/version informational invocations and completion do not enable reported export. Product opt-out does not disable separately configured diagnostic/profiling OTLP export.

Breaking changes

Dashboard product telemetry no longer uses IDE telemetry consent or requires an IDE debug session. Deployments and users that relied on IDE settings to disable Dashboard reporting must use ASPIRE_DASHBOARD_TELEMETRY_OPTOUT instead. Removed Dashboard sender/operation contracts are implementation types, not hosting/client integration APIs. Legacy extension endpoints remain compatible with older dashboards.

For the CLI, reported usage/error details now travel as structured logs rather than activity events. Consumers querying those details should use traces / AppTraces; operation spans remain available.

Security considerations

This introduces direct outbound Dashboard Azure Monitor reporting and adds remote CLI reported-log export to the existing CLI product-telemetry destination. The isolated product pipelines do not forward application telemetry received by the Dashboard, ordinary logs, or ambient log scopes.

Dashboard properties exclude exception messages/stacks, raw browser user agents, resource names, unknown keys, and PII-classified fields. Scalar strings are truncated to at most 1,024 characters, and collection values are excluded before serialization. CLI product logs retain internally supplied tags and exception type/message/stack details; they do not apply the Dashboard allowlist and are not described as wholly anonymous.

Azure SDK storage is rooted in the user's profile, independent of ASPIRE_HOME: .aspire/dashboard/telemetrystorage and .aspire/cli/telemetrystorage. Each product configures its trace and log exporters with the same storage directory; Azure Monitor exporter 1.9 shares a transmitter and storage for exporters using the same connection string. No separate logs child directory is configured. Storage and delivery are best effort; successful SDK flush/shutdown is not proof of ingestion.

A security review has not been performed.

Validation

Latest follow-up: all 702 eligible Dashboard component tests passed on 2026-10-07 against the source pushed in 65b8e37d759a5e85e97ad806e0fd9d2e53537667. The component project rebuilt successfully. The obsolete resource-inventory test was replaced with selected-view tests for Graph and Parameters, covering scalar Resource.View properties, the complete sanitized log attributes, ambient correlation, and suppression of unchanged-property events.

The following command ran the full eligible suite using the freshly built output; it passed with zero failures or skipped tests:

$env:MSBUILDTERMINALLOGGER = 'false'
$env:APPLICATIONINSIGHTS_STATSBEAT_DISABLED = 'true'
$env:ASPIRE_DASHBOARD_TELEMETRY_OPTOUT = 'true'
.\.dotnet\dotnet.exe test --project .\tests\Aspire.Dashboard.Components.Tests\Aspire.Dashboard.Components.Tests.csproj --no-build --no-restore --no-launch-profile -- --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' --timeout 10m

Earlier focused validation on 2026-10-07 at 8ae309a40ea318b78d6c39fdce46a26e68528d33 produced the results below. These runs predate the latest follow-up commits and are not exact-head validation. The commands rebuilt the relevant projects with MSBUILDTERMINALLOGGER=false and excluded quarantined/outerloop tests.

Passed: 52 CLI tests at that earlier revision. Covers reported-log consent, application-logger isolation and emitted category/level, actual Azure Monitor log envelopes, comma-joined collection serialization, resource identity, provider lifecycle, and local logging after product shutdown/disposal.

dotnet test --project .\tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.ReportedLogExportTests' --filter-class '*.TelemetryConfigurationTests' --filter-class '*.AgentTelemetryPersistenceTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed: 105 focused Dashboard tests at that earlier revision. Covers shared recording/export, Dashboard telemetry, resource commands, and health. The updated tests verify that unknown event-result enum values are recorded as strings and that the trace/log resources share the generated instance ID, standard Dashboard name, and full informational version.

dotnet test --project .\tests\Aspire.Dashboard.Tests\Aspire.Dashboard.Tests.csproj --no-launch-profile -- --filter-class 'Aspire.Dashboard.Tests.Telemetry.*' --filter-class '*.DashboardCommandExecutorTests' --filter-class '*.HealthTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed: whitespace validation.

git diff --check

An earlier CI run also passed the Dashboard test jobs on Linux and Windows, and the Dashboard component test jobs on Linux and Windows. Those results predate the latest follow-up commits.

That earlier run also reported failures in Hosting.Blazor (Windows) and VS Code extension unit tests (Windows). Those failures were not investigated in the earlier validation-description update. Current-head CI has not yet been validated after the latest push.

Payload tests use in-process HTTP handlers; synthetic records do not reach Azure. Live Azure ingestion, Native AOT publishing, and full suites outside the Dashboard component project were not run in this follow-up.

Related issue: none.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
      • Dashboard component build and tests now pass locally; current-head CI validation and security review are still pending before marking the PR ready to ship.
  • 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 5, 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 -- 20730

Or

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

@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.

Copilot review overview

🔵 Needs a closer look

It introduces default-enabled outbound telemetry without security review and has unresolved metadata filtering and public documentation defects.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Migrates dashboard product telemetry from IDE forwarding to direct Azure Monitor export, while sharing telemetry infrastructure with the CLI.

Changes:

  • Adds shared activity, event, error, and Azure Monitor exporter infrastructure.
  • Introduces dashboard telemetry configuration, instrumentation, lifecycle management, and opt-out behavior.
  • Replaces sender-based tests and component telemetry with activity/log capture.
File Description
tests/​Shared/​TestDashboardTelemetrySender.cs Removes the fake IDE sender.
tests/​Shared/​DashboardTelemetryFixture.cs Adds activity/log capture fixture.
tests/​Aspire.Dashboard.Tests/​Telemetry/​TelemetryLoggerProviderTests.cs Tests circuit-error activities.
tests/​Aspire.Dashboard.Tests/​Telemetry/​DashboardTelemetryServiceTests.cs Expands event, error, privacy, and correlation tests.
tests/​Aspire.Dashboard.Tests/​Telemetry/​DashboardTelemetrySenderTests.cs Removes obsolete sender tests.
tests/​Aspire.Dashboard.Tests/​Telemetry/​DashboardTelemetryManagerTests.cs Tests provider lifecycle.
tests/​Aspire.Dashboard.Tests/​Telemetry/​DashboardTelemetryConfigurationTests.cs Tests opt-out resolution.
tests/​Aspire.Dashboard.Tests/​Telemetry/​ComponentTelemetryContextTests.cs Updates component event tests.
tests/​Aspire.Dashboard.Tests/​Model/​DashboardCommandExecutorTests.cs Tests command activity duration/results.
tests/​Aspire.Dashboard.Tests/​Integration/​StartupTests.cs Verifies hosted telemetry startup/shutdown.
tests/​Aspire.Dashboard.Tests/​Integration/​Playwright/​Infrastructure/​DashboardServerFixture.cs Disables telemetry in browser tests.
tests/​Aspire.Dashboard.Tests/​Integration/​IntegrationTestHelpers.cs Isolates product log filtering in tests.
tests/​Aspire.Dashboard.Tests/​Integration/​HealthTests.cs Verifies product resource isolation.
tests/​Aspire.Dashboard.Tests/​Aspire.Dashboard.Tests.csproj Links the new telemetry fixture.
tests/​Aspire.Dashboard.Components.Tests/​Shared/​FluentUISetupHelpers.cs Configures disabled test telemetry.
tests/​Aspire.Dashboard.Components.Tests/​Layout/​TerminalDockTelemetryTests.cs Captures structured terminal events.
tests/​Aspire.Dashboard.Components.Tests/​Interactions/​InteractionsProviderTests.cs Replaces sender registration.
tests/​Aspire.Dashboard.Components.Tests/​Dialogs/​SettingsDialogTests.cs Tests the telemetry notice.
tests/​Aspire.Dashboard.Components.Tests/​Aspire.Dashboard.Components.Tests.csproj Links the new fixture.
tests/​Aspire.Cli.Tests/​Telemetry/​TelemetryFixture.cs Disposes shared telemetry sources.
tests/​Aspire.Cli.Tests/​Telemetry/​AspireCliTelemetryTests.cs Tests shared structured events/errors.
src/​Shared/​Telemetry/​AspireTelemetryExporter.cs Centralizes Azure Monitor configuration.
src/​Shared/​Telemetry/​AspireTelemetryBase.cs Adds shared telemetry recording.
src/​Aspire.Dashboard/​Telemetry/​VisualStudioTelemetryTypes.cs Removes IDE transport types.
src/​Aspire.Dashboard/​Telemetry/​TelemetryResult.cs Relocates operation results.
src/​Aspire.Dashboard/​Telemetry/​TelemetryResponses.cs Removes HTTP response contracts.
src/​Aspire.Dashboard/​Telemetry/​TelemetryRequests.cs Removes HTTP request contracts.
src/​Aspire.Dashboard/​Telemetry/​TelemetryErrorRecorder.cs Delegates to shared error recording.
src/​Aspire.Dashboard/​Telemetry/​OperationContextProperty.cs Removes sender context properties.
src/​Aspire.Dashboard/​Telemetry/​OperationContext.cs Removes sender operation contexts.
src/​Aspire.Dashboard/​Telemetry/​IDashboardTelemetrySender.cs Removes the sender abstraction.
src/​Aspire.Dashboard/​Telemetry/​DashboardTelemetryService.cs Implements sanitized activity/log instrumentation.
src/​Aspire.Dashboard/​Telemetry/​DashboardTelemetrySender.cs Removes IDE HTTP forwarding.
src/​Aspire.Dashboard/​Telemetry/​DashboardTelemetryManager.cs Manages Azure Monitor providers.
src/​Aspire.Dashboard/​Telemetry/​DashboardTelemetryJsonSerializerContext.cs Removes transport serialization metadata.
src/​Aspire.Dashboard/​Telemetry/​DashboardTelemetryConfiguration.cs Resolves telemetry enablement.
src/​Aspire.Dashboard/​Telemetry/​AspireTelemetryProperty.cs Relocates property classifications.
src/​Aspire.Dashboard/​README.md Documents direct reporting and privacy.
src/​Aspire.Dashboard/​Model/​DebugSessionHelpers.cs Removes IDE telemetry HTTP helpers.
src/​Aspire.Dashboard/​Model/​DashboardCommandExecutor.cs Uses scoped command activities.
src/​Aspire.Dashboard/​DashboardWebApplication.cs Registers hosted telemetry services.
src/​Aspire.Dashboard/​Components/​Pages/​ComponentTelemetryContext.cs Records immediate component events.
src/​Aspire.Dashboard/​Components/​Dialogs/​SettingsDialog.razor Uses resolved enablement for the notice.
src/​Aspire.Dashboard/​Aspire.Dashboard.csproj Adds exporter and shared telemetry sources.
src/​Aspire.Cli/​Telemetry/​TelemetryManager.cs Uses shared exporter configuration.
src/​Aspire.Cli/​Telemetry/​CliTagEnrichmentProcessor.cs Updates shared recorder documentation.
src/​Aspire.Cli/​Telemetry/​AspireCliTelemetry.cs Derives CLI instrumentation from the shared base.
src/​Aspire.Cli/​Commands/​AgentTelemetryCommand.cs Updates shared API references.
src/​Aspire.Cli/​Aspire.Cli.csproj Includes shared telemetry sources.
extension/​src/​dcp/​DashboardTelemetryPassthrough.ts Documents legacy endpoint compatibility.
docs/​open-telemetry-architecture.md Documents product telemetry architecture.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Found two issues: one product-log filtering/privacy issue and one resource-type metadata regression. The resource-type regression is already covered by an existing inline comment, so this review adds only the filtering finding.

@github-actions

github-actions Bot commented Oct 5, 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

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.

Copilot review overview

🔵 Needs a closer look

The direct outbound telemetry path lacks security review and has unresolved opt-out, startup-reliability, and public-documentation issues.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (3)
Previously missed (1)

In code that hasn't changed since last review

Medium severity AppHost opt-out fails to parse numeric boolean 1

src/​Aspire.Dashboard/​Telemetry/​DashboardTelemetryConfiguration.cs:31

The documented 1 opt-out only works when this key is read inside the dashboard process. When it is set before starting an AppHost, src/Aspire.Hosting/Dashboard/DashboardOptions.cs:52 still uses bool.TryParse, so 1 becomes null and DashboardEventHandlers.cs:575-577 does not forward the opt-out. Update the AppHost-side parser to accept numeric booleans and add coverage for forwarding 1; otherwise the advertised AppHost opt-out can silently leave telemetry enabled.

@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.

Copilot review overview

🟡 Changes recommended

The shared public recorder bypasses dashboard privacy sanitization, and AppHost forwarding does not honor the documented 1 opt-out value.

Review effort: Balanced
Findings: 2 High severity · 1 Medium severity

Open (3)

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.

Copilot review overview

🔵 Needs a closer look

The public shared recorder bypasses the dashboard’s telemetry privacy validation, and newly moved public telemetry types lack required documentation.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (1)

@github-actions

This comment has been minimized.

@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.

Copilot review overview

🟡 Changes recommended

The resource telemetry test references a deleted key and producer, preventing the component test project from compiling.

Review effort: Balanced
Findings: 2 High severity · 1 Low severity

Open (3)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Telemetry provider and batch processor lack claimed isolation filters

src/​Shared/​Telemetry/​AzureMonitorTelemetryProvider.cs:108

The PR description says exact product-category and Information-through-Critical filtering is enforced at both logger-provider and batch-processor boundaries, but this isolated factory registers the OpenTelemetry provider without either filter, and AddAspireAzureMonitorExporter installs an unfiltered batch processor. The new product-telemetry spec instead documents isolation as the only boundary. Please either implement the claimed defense-in-depth filters or correct the PR description/security and validation claims to match the code.

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.

Copilot review overview

🔵 Needs a closer look

It introduces direct outbound telemetry and privacy-sensitive persistence without a completed security review or current-head CI validation.

Review effort: Balanced
Findings: None

Resolved since last review (3)

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Oct 7, 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

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.

Copilot review overview

🔵 Needs a closer look

It introduces direct outbound telemetry and remains pending current-head CI, Native AOT validation, and security review.

Review effort: Balanced
Findings: None

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Tests selector

Selects the full PR test matrix + all PR-gated jobs (ALL) — run-all fallback: 'tests/Shared/TestDashboardTelemetrySender.cs' is neither Layer-1-owned nor matched by a Layer 2 rule


Selection computed for commit 553dcbb.

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

Normal CLI shutdown leaves profiling and diagnostic providers undisposed, and a telemetry compatibility comment is inaccurate.

0 open findings

Previously missed (2)

In code that hasn't changed since last review

Medium severity Dispose profiling and diagnostic providers after shutdown

src/​Aspire.Cli/​Telemetry/​TelemetryManager.cs:403

The normal shutdown path calls Shutdown on the profiling and diagnostic providers but never disposes them. After TryShutdownAsync sets the state to ShuttingDown, the later Dispose() call returns through its non-Initialized branch, so these providers and their processors/exporters remain undisposed. Dispose both captured providers in a finally block after the concurrent shutdown operations.

Low severity Update Dashboard documentation for structured logs and command activities

extension/​src/​dcp/​DashboardTelemetryPassthrough.ts:19

This describes the current Dashboard as activity-based, but this PR moves usage and error events to structured logs and retains activities only for commands. That stale wording can mislead future compatibility maintenance; describe it as the current direct Azure Monitor implementation instead.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@github-actions

github-actions Bot commented Oct 8, 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.

@JamesNK
James Newton-King (JamesNK) merged commit 4ace576 into main Oct 9, 2026
832 of 837 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 9, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-dashboard breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants