Share via


MauiOtlpExtensions.WithOtlpDevTunnel<T> Method

Definition

Configures the MAUI platform resource to send OpenTelemetry data through an automatically created dev tunnel. This is the easiest option for most scenarios, as it handles tunnel creation, configuration, and endpoint injection automatically.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithOtlpDevTunnel<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder) where T : Aspire.Hosting.Maui.IMauiPlatformResource, Aspire.Hosting.ApplicationModel.IResourceWithEnvironment;
static member WithOtlpDevTunnel : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.Maui.IMauiPlatformResource and 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.Maui.IMauiPlatformResource and 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> (requires 'T :> Aspire.Hosting.Maui.IMauiPlatformResource and 'T :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)
<Extension()>
Public Function WithOtlpDevTunnel(Of T As {IMauiPlatformResource, IResourceWithEnvironment}) (builder As IResourceBuilder(Of T)) As IResourceBuilder(Of T)

Type Parameters

T

The MAUI platform resource type.

Parameters

builder
IResourceBuilder<T>

The resource builder.

Returns

The resource builder.

Examples

Configure a MAUI Android device to automatically use a dev tunnel for telemetry:

var builder = DistributedApplication.CreateBuilder(args);

var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
maui.AddAndroidDevice()
    .WithOtlpDevTunnel(); // That's it - everything is configured automatically!

builder.Build().Run();

Remarks

This method creates a dev tunnel automatically and configures the MAUI platform resource to route OTLP traffic through it. This is the recommended approach for most scenarios as it requires minimal configuration and works reliably across all mobile platforms.

Prerequisites:

Applies to