Skip to content

Fix MAUI OTLP dev tunnel resolution - #19386

Open
Gerald Versluis (jfversluis) wants to merge 2 commits into
microsoft:mainfrom
jfversluis:jfversluis-maui-otlp-tunnels
Open

Fix MAUI OTLP dev tunnel resolution#19386
Gerald Versluis (jfversluis) wants to merge 2 commits into
microsoft:mainfrom
jfversluis:jfversluis-maui-otlp-tunnels

Conversation

@jfversluis

@jfversluis Gerald Versluis (jfversluis) commented Aug 14, 2026

Copy link
Copy Markdown
Member

Description

This extracts the MAUI OTLP dev-tunnel and mobile environment refresh work from #18591 into a focused follow-up to #19383. The launch-queue handoff remains isolated in #19383; this PR only addresses how MAUI resources reach the Aspire Dashboard OTLP listener and refresh mobile launch environments.

MAUI apps running on Android and iOS cannot reliably reach the AppHost's local OTLP listener directly. WithOtlpDevTunnel() now prefers the Dashboard OTLP/HTTP endpoint and configures OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf, falling back to OTLP/gRPC only when HTTP is unavailable. It forwards to the concrete allocated listener port rather than an unrelated DCP proxy port.

The resolver handles configured endpoint URLs, executable target ports, DCP target-port expressions, container/proxy endpoints, localhost TLDs, and wildcard local bindings. Resolution is one-shot for this focused slice and bounded when waiting for DCP snapshots. Dashboard-disabled, terminated, timeout, unresolved, synthetic-stub, and invalid-configuration cases fail with actionable errors instead of hanging.

Android and iOS now rewrite stable per-resource MSBuild environment targets whenever launch arguments are reevaluated, so restarted MAUI resources receive current OTLP URL, protocol, and environment values.

User-facing usage

The existing C# API is unchanged:

var mauiApp = builder.AddMauiProject("mauiapp", "../MauiApp/MauiApp.csproj");

mauiApp.AddiOSSimulator()
    .WithOtlpDevTunnel();

mauiApp.AddAndroidEmulator()
    .WithOtlpDevTunnel();

WithOtlpDevTunnel() remains run-only and does not add tunnel environment values to published manifests.

Scope

Included:

  • Dashboard OTLP/HTTP preference and protocol selection
  • Concrete allocated target-port and runtime-snapshot resolution
  • Bounded startup/protocol waits and clear failure paths
  • Android/iOS environment regeneration after resource restart

Deferred to a separate DevTunnels change:

  • Long-running endpoint watcher reconciliation
  • Post-start listener retargeting and stale-port cleanup
  • Shared port allocation serialization
  • Generic DevTunnel health recovery

No Aspire.Hosting core/DCP lifecycle, Dashboard, Foundry, playground, dependency, generated API, or snapshot files are changed.

Validation

  • ./restore.sh
  • dotnet build src/Aspire.Hosting.Maui/Aspire.Hosting.Maui.csproj --no-restore — succeeded with 0 warnings and 0 errors
  • Focused MTP tests with quarantined and outerloop exclusions — passed
  • Complete Aspire.Hosting.Maui.Tests project with quarantined and outerloop exclusions — 189 passed
  • git diff --check origin/main..HEAD and the eight-file MAUI-only allowlist check passed
  • Final generic code review reported no findings
  • Final Aspire architecture review reported no findings

Related PRs:

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 14, 2026 12:39
@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 -- 19386

Or

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

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.

Pull request overview

Improves MAUI telemetry connectivity through Dev Tunnels and refreshes mobile launch environments after restarts.

Changes:

  • Prefers OTLP/HTTP and resolves concrete dashboard listener ports.
  • Regenerates stable Android/iOS environment targets.
  • Adds regression tests and documentation.
Show a summary per file
File Description
src/Aspire.Hosting.Maui/MauiOtlpExtensions.cs Adds endpoint and protocol resolution.
src/Aspire.Hosting.Maui/Annotations/OtlpDevTunnelConfigurationAnnotation.cs Tracks one-shot endpoint resolution.
src/Aspire.Hosting.Maui/Otlp/OtlpLoopbackResource.cs Clarifies loopback targeting.
src/Aspire.Hosting.Maui/Utilities/MauiAndroidEnvironmentAnnotation.cs Regenerates Android targets.
src/Aspire.Hosting.Maui/Utilities/MauiiOSEnvironmentAnnotation.cs Regenerates iOS targets.
src/Aspire.Hosting.Maui/Utilities/MauiEnvironmentHelper.cs Uses stable target paths.
src/Aspire.Hosting.Maui/README.md Documents protocol selection and restart behavior.
tests/Aspire.Hosting.Maui.Tests/MauiPlatformExtensionsTests.cs Adds endpoint, failure, and restart coverage.

Review details

  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/Aspire.Hosting.Maui/MauiOtlpExtensions.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 14, 2026 13:49

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.

Review details

  • Files reviewed: 8/8 changed files
  • Comments generated: 0 new
  • Review effort level: 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.

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

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants