# MauiOtlpExtensions Methods

- Package: [Aspire.Hosting.Maui](/reference/api/csharp/aspire.hosting.maui.md)
- Type: [MauiOtlpExtensions](/reference/api/csharp/aspire.hosting.maui/mauiotlpextensions.md)
- Kind: `Methods`
- Members: `1`

Provides extension methods for configuring OpenTelemetry endpoints for MAUI platform resources.

## WithOtlpDevTunnel(IResourceBuilder<T>)

- Name: `WithOtlpDevTunnel(IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Maui/MauiOtlpExtensions.cs#L57-L75)

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.

```csharp
public static class MauiOtlpExtensions
{
    public static IResourceBuilder<T> WithOtlpDevTunnel<T>(
        this IResourceBuilder<T> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.

## Returns

`IResourceBuilder<T>` -- The resource builder.

## 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:

- Aspire.Hosting.DevTunnels package must be referenced
- Dev tunnel CLI must be installed (automatic prompt if missing)
- User must be logged in to dev tunnel service (automatic prompt if needed)

## Examples

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

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

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
