# OtlpConfigurationExtensions

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/OtlpConfigurationExtensions.cs)

Provides extension methods for configuring OpenTelemetry in projects using environment variables.

## Definition

```csharp
namespace Aspire.Hosting;

public static class OtlpConfigurationExtensions
{
    // ...
}
```

## Methods

- [AddOtlpEnvironment(IResource, IConfiguration, IHostEnvironment)](/reference/api/csharp/aspire.hosting/otlpconfigurationextensions/methods.md#addotlpenvironment-iresource-iconfiguration-ihostenvironment) `static` -- Configures OpenTelemetry in projects using environment variables.
- [AddOtlpEnvironment(IResource, IConfiguration, IHostEnvironment, OtlpProtocol)](/reference/api/csharp/aspire.hosting/otlpconfigurationextensions/methods.md#addotlpenvironment-iresource-iconfiguration-ihostenvironment-otlpprotocol) `static` -- Configures OpenTelemetry in projects using environment variables.
- [WithOtlpExporter(IResourceBuilder<T>)](/reference/api/csharp/aspire.hosting/otlpconfigurationextensions/methods.md#withotlpexporter-iresourcebuilder-t) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Injects the appropriate environment variables to allow the resource to enable sending telemetry to the dashboard. 1. It sets the OTLP endpoint to the value of the `ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL` environment variable. 2. It sets the service name and instance id to the resource name and UID. Values are injected by the orchestrator. 3. It sets a small batch schedule delay in development. This reduces the delay that OTLP exporter waits to sends telemetry and makes the dashboard telemetry pages responsive.
- [WithOtlpExporter(IResourceBuilder<T>, OtlpProtocol)](/reference/api/csharp/aspire.hosting/otlpconfigurationextensions/methods.md#withotlpexporter-iresourcebuilder-t-otlpprotocol) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) `extension` `ats ignored` -- Injects the appropriate environment variables to allow the resource to enable sending telemetry to the dashboard. 1. It sets the OTLP endpoint to the value of the `ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL` environment variable. 2. It sets the service name and instance id to the resource name and UID. Values are injected by the orchestrator. 3. It sets a small batch schedule delay in development. This reduces the delay that OTLP exporter waits to sends telemetry and makes the dashboard telemetry pages responsive.
