# OpenTelemetry

[OpenTelemetry](https://opentelemetry.io/) has become the industry standard for tracing and metrics. Ucommerce comes with support for OpenTelemetry out of the box, and includes tracing for all pipelines.

To enable OpenTelemetry, see the [OpenTelemetry documentation](https://opentelemetry.io/docs/languages/dotnet/). To add the Ucommerce pipeline tracing, add `ucommerce.web.infrastructure.pipelines`  as a source. See example below:

{% code overflow="wrap" %}

```csharp
public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
{
    builder.Logging.AddOpenTelemetry(logging =>
    {
        logging.IncludeFormattedMessage = true;
        logging.IncludeScopes = true;
    });

    builder.Services.AddOpenTelemetry()
        .WithMetrics(metrics =>
        {
            metrics.AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation()
                .AddRuntimeInstrumentation();
        })
        .WithTracing(tracing =>
        {
            tracing.AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation()
                .AddSqlClientInstrumentation()
                .AddSource("ucommerce.web.infrastructure.pipelines");
        });

    builder.AddOpenTelemetryExporters();

    return builder;
}
```

{% endcode %}

Leveraging OpenTelemetry when developing locally is easy using [.NET Aspire](https://learn.microsoft.com/en-us/dotnet/aspire/get-started/aspire-overview) as it gives you a nice UI to monitor all ressources. For production, use Azure Application Insights or similar.
