OtlpConfigurationExtensions Methods
ClassMethods5 members
Provides extension methods for configuring OpenTelemetry in projects using environment variables.
AddOtlpEnvironment(IResource, IConfiguration, IHostEnvironment) Section titled AddOtlpEnvironment(IResource, IConfiguration, IHostEnvironment)static Configures OpenTelemetry in projects using environment variables.
public static class OtlpConfigurationExtensions{ public static void AddOtlpEnvironment( IResource resource, IConfiguration configuration, IHostEnvironment environment) { // ... }}Parameters
resourceIconfigurationIConfiguration The configuration to use for the OTLP exporter endpoint URL.environmentIHostEnvironment The host environment to check if the application is running in development mode.AddOtlpEnvironment(IResource, IConfiguration, IHostEnvironment, OtlpProtocol) Section titled AddOtlpEnvironment(IResource, IConfiguration, IHostEnvironment, OtlpProtocol)static Configures OpenTelemetry in projects using environment variables.
public static class OtlpConfigurationExtensions{ public static void AddOtlpEnvironment( IResource resource, IConfiguration configuration, IHostEnvironment environment, OtlpProtocol protocol) { // ... }}Parameters
resourceIconfigurationIConfiguration The configuration to use for the OTLP exporter endpoint URL.environmentIHostEnvironment The host environment to check if the application is running in development mode.protocolOtlpWithOtlpExporter(IResourceBuilder<T>) Section titled WithOtlpExporter(IResourceBuilder<T>)extensionI Injects the appropriate environment variables to allow the resource to enable sending telemetry to the dashboard.
- It sets the OTLP endpoint to the value of the
ASPIRE_environment variable.DASHBOARD_ OTLP_ ENDPOINT_ URL - It sets the service name and instance id to the resource name and UID. Values are injected by the orchestrator.
- 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.
public static class OtlpConfigurationExtensions{ public static IResourceBuilder<T> WithOtlpExporter<T>( this IResourceBuilder<T> builder) { // ... }}Parameters
builderIReturns
IResourceBuilder<T> The ApplicationModel.IResourceBuilder`1 .WithOtlpExporter(IResourceBuilder<T>, OtlpProtocol) Section titled WithOtlpExporter(IResourceBuilder<T>, OtlpProtocol)extensionI Injects the appropriate environment variables to allow the resource to enable sending telemetry to the dashboard.
- It sets the OTLP endpoint to the value of the
ASPIRE_environment variable.DASHBOARD_ OTLP_ ENDPOINT_ URL - It sets the service name and instance id to the resource name and UID. Values are injected by the orchestrator.
- 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.
public static class OtlpConfigurationExtensions{ public static IResourceBuilder<T> WithOtlpExporter<T>( this IResourceBuilder<T> builder, OtlpProtocol protocol) { // ... }}Parameters
builderIprotocolOtlpReturns
IResourceBuilder<T> The ApplicationModel.IResourceBuilder`1 .WithOtlpExporterIfEndpointAvailable(IResourceBuilder<T>, OtlpProtocol) Section titled WithOtlpExporterIfEndpointAvailable(IResourceBuilder<T>, OtlpProtocol)extensionI Configures OTLP export only when the required collector endpoint is available.
public static class OtlpConfigurationExtensions{ public static IResourceBuilder<T> WithOtlpExporterIfEndpointAvailable<T>( this IResourceBuilder<T> builder, OtlpProtocol protocol) { // ... }}Parameters
builderIprotocolOtlpReturns
IResourceBuilder<T> The ApplicationModel.IResourceBuilder`1 .Remarks
The exporter annotation is retained when no endpoint is available, but OTLP environment variables are omitted so workloads that can operate without telemetry remain runnable.