Skip to content
Docs Try Aspire

MauiOtlpExtensions Methods

Class Methods 1 member
Provides extension methods for configuring OpenTelemetry endpoints for MAUI platform resources.
WithOtlpDevTunnel(IResourceBuilder<T>) Section titled WithOtlpDevTunnel(IResourceBuilder<T>) extension IResourceBuilder<T>
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 class MauiOtlpExtensions
{
public static IResourceBuilder<T> WithOtlpDevTunnel<T>(
this IResourceBuilder<T> builder)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder.
IResourceBuilder<T> The resource builder.

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:

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();