diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
index e88f15d58dd..bbd390269d7 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
@@ -39,6 +39,12 @@
to `null` will now result in an `ArgumentNullException` being thrown.
([#5434](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5434))
+* Introduced experimental support for automatically retrying export to the otlp
+ endpoint when transient network errors occur. Users can enable this feature by
+ setting `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` environment
+ variable to true.
+ ([#5435](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5435))
+
## 1.7.0
Released 2023-Dec-08
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs
index 61f126b1229..a5587bb681b 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs
@@ -16,6 +16,8 @@ internal sealed class ExperimentalOptions
public const string EmitLogEventEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES";
+ public const string EnableInMemoryRetryEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY";
+
public ExperimentalOptions()
: this(new ConfigurationBuilder().AddEnvironmentVariables().Build())
{
@@ -27,10 +29,24 @@ public ExperimentalOptions(IConfiguration configuration)
{
this.EmitLogEventAttributes = emitLogEventAttributes;
}
+
+ if (configuration.TryGetBoolValue(EnableInMemoryRetryEnvVar, out var enableInMemoryRetry))
+ {
+ this.EnableInMemoryRetry = enableInMemoryRetry;
+ }
}
///
- /// Gets or sets a value indicating whether log event attributes should be exported.
+ /// Gets a value indicating whether log event attributes should be exported.
+ ///
+ public bool EmitLogEventAttributes { get; }
+
+ ///
+ /// Gets a value indicating whether or not in-memory retry should be enabled for transient errors.
///
- public bool EmitLogEventAttributes { get; set; } = false;
+ ///
+ /// Specification: .
+ ///
+ public bool EnableInMemoryRetry { get; }
}
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs
index 0523b12d99a..9c912b6b731 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs
@@ -11,6 +11,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetry.Internal;
using OpenTelemetry.Trace;
@@ -225,6 +226,7 @@ public Func HttpClientFactory
internal static void RegisterOtlpExporterOptionsFactory(IServiceCollection services)
{
services.RegisterOptionsFactory(CreateOtlpExporterOptions);
+ services.RegisterOptionsFactory(configuration => new ExperimentalOptions(configuration));
}
internal static OtlpExporterOptions CreateOtlpExporterOptions(
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs
index 0ee3ee06a44..34e5a09d597 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs
@@ -6,6 +6,7 @@
#endif
using System.Reflection;
using Grpc.Core;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
using Grpc.Net.Client;
@@ -88,7 +89,7 @@ public static THeaders GetHeaders(this OtlpExporterOptions options, Ac
return headers;
}
- public static OtlpExporterTransmissionHandler GetTraceExportTransmissionHandler(this OtlpExporterOptions options)
+ public static OtlpExporterTransmissionHandler GetTraceExportTransmissionHandler(this OtlpExporterOptions options, ExperimentalOptions experimentalOptions)
{
var exportClient = GetTraceExportClient(options);
@@ -99,10 +100,12 @@ public static THeaders GetHeaders(this OtlpExporterOptions options, Ac
? httpTraceExportClient.HttpClient.Timeout.TotalMilliseconds
: options.TimeoutMilliseconds;
- return new OtlpExporterTransmissionHandler(exportClient, timeoutMilliseconds);
+ return experimentalOptions.EnableInMemoryRetry
+ ? new OtlpExporterRetryTransmissionHandler(exportClient, timeoutMilliseconds)
+ : new OtlpExporterTransmissionHandler(exportClient, timeoutMilliseconds);
}
- public static OtlpExporterTransmissionHandler GetMetricsExportTransmissionHandler(this OtlpExporterOptions options)
+ public static OtlpExporterTransmissionHandler GetMetricsExportTransmissionHandler(this OtlpExporterOptions options, ExperimentalOptions experimentalOptions)
{
var exportClient = GetMetricsExportClient(options);
@@ -113,21 +116,21 @@ public static THeaders GetHeaders(this OtlpExporterOptions options, Ac
? httpMetricsExportClient.HttpClient.Timeout.TotalMilliseconds
: options.TimeoutMilliseconds;
- return new OtlpExporterTransmissionHandler(exportClient, timeoutMilliseconds);
+ return experimentalOptions.EnableInMemoryRetry
+ ? new OtlpExporterRetryTransmissionHandler(exportClient, timeoutMilliseconds)
+ : new OtlpExporterTransmissionHandler(exportClient, timeoutMilliseconds);
}
- public static OtlpExporterTransmissionHandler GetLogsExportTransmissionHandler(this OtlpExporterOptions options)
+ public static OtlpExporterTransmissionHandler GetLogsExportTransmissionHandler(this OtlpExporterOptions options, ExperimentalOptions experimentalOptions)
{
var exportClient = GetLogExportClient(options);
-
- // `HttpClient.Timeout.TotalMilliseconds` would be populated with the correct timeout value for both the exporter configuration cases:
- // 1. User provides their own HttpClient. This case is straightforward as the user wants to use their `HttpClient` and thereby the same client's timeout value.
- // 2. If the user configures timeout via the exporter options, then the timeout set for the `HttpClient` initialized by the exporter will be set to user provided value.
double timeoutMilliseconds = exportClient is OtlpHttpLogExportClient httpLogExportClient
? httpLogExportClient.HttpClient.Timeout.TotalMilliseconds
: options.TimeoutMilliseconds;
- return new OtlpExporterTransmissionHandler(exportClient, timeoutMilliseconds);
+ return experimentalOptions.EnableInMemoryRetry
+ ? new OtlpExporterRetryTransmissionHandler(exportClient, timeoutMilliseconds)
+ : new OtlpExporterTransmissionHandler(exportClient, timeoutMilliseconds);
}
public static IExportClient GetTraceExportClient(this OtlpExporterOptions options) =>
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs
index 8e5c626d917..8835965e2c1 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs
@@ -62,7 +62,7 @@ internal OtlpLogExporter(
OpenTelemetryProtocolExporterEventSource.Log.InvalidEnvironmentVariable(key, value);
};
- this.transmissionHandler = transmissionHandler ?? exporterOptions.GetLogsExportTransmissionHandler();
+ this.transmissionHandler = transmissionHandler ?? exporterOptions.GetLogsExportTransmissionHandler(experimentalOptions!);
this.otlpLogRecordTransformer = new OtlpLogRecordTransformer(sdkLimitOptions!, experimentalOptions!);
}
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs
index 1f99374c324..dbf156c1a0b 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs
@@ -404,7 +404,6 @@ private static void RegisterOptions(IServiceCollection services)
{
OtlpExporterOptions.RegisterOtlpExporterOptionsFactory(services);
services.RegisterOptionsFactory(configuration => new SdkLimitOptions(configuration));
- services.RegisterOptionsFactory(configuration => new ExperimentalOptions(configuration));
}
private static T GetOptions(
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs
index a0026d1e9f4..6784ce2ed1d 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs
@@ -25,7 +25,7 @@ public class OtlpMetricExporter : BaseExporter
///
/// Configuration options for the exporter.
public OtlpMetricExporter(OtlpExporterOptions options)
- : this(options, transmissionHandler: null)
+ : this(options, experimentalOptions: new(), transmissionHandler: null)
{
}
@@ -33,9 +33,11 @@ public OtlpMetricExporter(OtlpExporterOptions options)
/// Initializes a new instance of the class.
///
/// Configuration options for the export.
+ /// .
/// .
internal OtlpMetricExporter(
OtlpExporterOptions options,
+ ExperimentalOptions experimentalOptions,
OtlpExporterTransmissionHandler transmissionHandler = null)
{
// Each of the Otlp exporters: Traces, Metrics, and Logs set the same value for `OtlpKeyValueTransformer.LogUnsupportedAttributeType`
@@ -50,7 +52,7 @@ internal OtlpMetricExporter(
OpenTelemetryProtocolExporterEventSource.Log.InvalidEnvironmentVariable(key, value);
};
- this.transmissionHandler = transmissionHandler ?? options.GetMetricsExportTransmissionHandler();
+ this.transmissionHandler = transmissionHandler ?? options.GetMetricsExportTransmissionHandler(experimentalOptions);
}
internal OtlpResource.Resource ProcessResource => this.processResource ??= this.ParentProvider.GetResource().ToOtlpResource();
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs
index 37a66dc2f10..38cb1a44a66 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs
@@ -7,6 +7,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OpenTelemetry.Exporter;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetry.Internal;
namespace OpenTelemetry.Metrics;
@@ -98,6 +99,7 @@ public static MeterProviderBuilder AddOtlpExporter(
return BuildOtlpExporterMetricReader(
exporterOptions,
sp.GetRequiredService>().Get(finalOptionsName),
+ sp.GetRequiredService>().Get(finalOptionsName),
sp);
});
}
@@ -169,19 +171,24 @@ public static MeterProviderBuilder AddOtlpExporter(
configureExporterAndMetricReader?.Invoke(exporterOptions, metricReaderOptions);
- return BuildOtlpExporterMetricReader(exporterOptions, metricReaderOptions, sp);
+ return BuildOtlpExporterMetricReader(
+ exporterOptions,
+ metricReaderOptions,
+ sp.GetRequiredService>().Get(finalOptionsName),
+ sp);
});
}
internal static MetricReader BuildOtlpExporterMetricReader(
OtlpExporterOptions exporterOptions,
MetricReaderOptions metricReaderOptions,
+ ExperimentalOptions experimentalOptions,
IServiceProvider serviceProvider,
Func, BaseExporter>? configureExporterInstance = null)
{
exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter");
- BaseExporter metricExporter = new OtlpMetricExporter(exporterOptions);
+ BaseExporter metricExporter = new OtlpMetricExporter(exporterOptions, experimentalOptions);
if (configureExporterInstance != null)
{
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs
index f017d075428..4e2ee7cebcb 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs
@@ -26,7 +26,7 @@ public class OtlpTraceExporter : BaseExporter
///
/// Configuration options for the export.
public OtlpTraceExporter(OtlpExporterOptions options)
- : this(options, sdkLimitOptions: new(), transmissionHandler: null)
+ : this(options, sdkLimitOptions: new(), experimentalOptions: new(), transmissionHandler: null)
{
}
@@ -35,10 +35,12 @@ public OtlpTraceExporter(OtlpExporterOptions options)
///
/// .
/// .
+ /// .
/// .
internal OtlpTraceExporter(
OtlpExporterOptions exporterOptions,
SdkLimitOptions sdkLimitOptions,
+ ExperimentalOptions experimentalOptions,
OtlpExporterTransmissionHandler transmissionHandler = null)
{
Debug.Assert(exporterOptions != null, "exporterOptions was null");
@@ -50,7 +52,7 @@ internal OtlpTraceExporter(
ConfigurationExtensions.LogInvalidEnvironmentVariable = OpenTelemetryProtocolExporterEventSource.Log.InvalidEnvironmentVariable;
- this.transmissionHandler = transmissionHandler ?? exporterOptions.GetTraceExportTransmissionHandler();
+ this.transmissionHandler = transmissionHandler ?? exporterOptions.GetTraceExportTransmissionHandler(experimentalOptions);
}
internal OtlpResource.Resource ProcessResource => this.processResource ??= this.ParentProvider.GetResource().ToOtlpResource();
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs
index 45231f63604..7ccbdd33472 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs
@@ -92,19 +92,24 @@ public static TracerProviderBuilder AddOtlpExporter(
// instance.
var sdkOptionsManager = sp.GetRequiredService>().CurrentValue;
- return BuildOtlpExporterProcessor(exporterOptions, sdkOptionsManager, sp);
+ return BuildOtlpExporterProcessor(
+ exporterOptions,
+ sdkOptionsManager,
+ sp.GetRequiredService>().Get(finalOptionsName),
+ sp);
});
}
internal static BaseProcessor BuildOtlpExporterProcessor(
OtlpExporterOptions exporterOptions,
SdkLimitOptions sdkLimitOptions,
+ ExperimentalOptions experimentalOptions,
IServiceProvider serviceProvider,
Func, BaseExporter>? configureExporterInstance = null)
{
exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpTraceExporter");
- BaseExporter otlpExporter = new OtlpTraceExporter(exporterOptions, sdkLimitOptions);
+ BaseExporter otlpExporter = new OtlpTraceExporter(exporterOptions, sdkLimitOptions, experimentalOptions);
if (configureExporterInstance != null)
{
diff --git a/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs b/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs
index 86f3573e21e..2a9dd7cebbb 100644
--- a/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs
+++ b/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs
@@ -35,6 +35,7 @@ public void GlobalSetup()
this.exporter = new OtlpTraceExporter(
options,
new SdkLimitOptions(),
+ new ExperimentalOptions(),
new OtlpExporterTransmissionHandler(new OtlpGrpcTraceExportClient(options, new TestTraceServiceClient()), options.TimeoutMilliseconds));
this.activity = ActivityHelper.CreateTestActivity();
diff --git a/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs b/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs
index 65259aabd2f..d595eefd9f1 100644
--- a/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs
+++ b/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs
@@ -63,6 +63,7 @@ public void GlobalSetup()
this.exporter = new OtlpTraceExporter(
options,
new SdkLimitOptions(),
+ new ExperimentalOptions(),
new OtlpExporterTransmissionHandler(new OtlpHttpTraceExportClient(options, options.HttpClientFactory()), options.TimeoutMilliseconds));
this.activity = ActivityHelper.CreateTestActivity();
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs
index 11b5b797127..e7bb7822fba 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs
@@ -72,6 +72,7 @@ public void TraceExportResultIsSuccess(OtlpExportProtocol protocol, string endpo
builder.AddProcessor(OtlpTraceExporterHelperExtensions.BuildOtlpExporterProcessor(
exporterOptions,
DefaultSdkLimitOptions,
+ experimentalOptions: new(),
serviceProvider: null,
configureExporterInstance: otlpExporter =>
{
@@ -153,6 +154,7 @@ public void MetricExportResultIsSuccess(OtlpExportProtocol protocol, string endp
builder.AddReader(OtlpMetricExporterExtensions.BuildOtlpExporterMetricReader(
exporterOptions,
readerOptions,
+ experimentalOptions: new(),
serviceProvider: null,
configureExporterInstance: otlpExporter =>
{
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs
index dc2a0aad5f8..3029519eac2 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs
@@ -8,11 +8,11 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
-using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetry.Metrics;
using OpenTelemetry.Proto.Collector.Trace.V1;
using OpenTelemetry.Tests;
@@ -172,23 +172,13 @@ public async Task GrpcRetryTests(bool useRetryTransmissionHandler, ExportResult
var endpoint = new Uri($"http://localhost:{testGrpcPort}");
- var exporterOptions = new OtlpExporterOptions() { Endpoint = endpoint, TimeoutMilliseconds = 20000 };
+ var exporterOptions = new OtlpExporterOptions() { Endpoint = endpoint, TimeoutMilliseconds = 20000, Protocol = OtlpExportProtocol.Grpc };
- var exportClient = new OtlpGrpcTraceExportClient(exporterOptions);
+ var configuration = new ConfigurationBuilder()
+ .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EnableInMemoryRetryEnvVar] = useRetryTransmissionHandler.ToString() })
+ .Build();
- OtlpExporterTransmissionHandler transmissionHandler;
-
- // TODO: update this to configure via experimental environment variable.
- if (useRetryTransmissionHandler)
- {
- transmissionHandler = new OtlpExporterRetryTransmissionHandler(exportClient, exporterOptions.TimeoutMilliseconds);
- }
- else
- {
- transmissionHandler = new OtlpExporterTransmissionHandler(exportClient, exporterOptions.TimeoutMilliseconds);
- }
-
- var otlpExporter = new OtlpTraceExporter(exporterOptions, new(), transmissionHandler);
+ var otlpExporter = new OtlpTraceExporter(exporterOptions, new SdkLimitOptions(), new ExperimentalOptions(configuration));
var activitySourceName = "otel.grpc.retry.test";
using var source = new ActivitySource(activitySourceName);
@@ -266,23 +256,13 @@ public async Task HttpRetryTests(bool useRetryTransmissionHandler, ExportResult
var endpoint = new Uri($"http://localhost:{testHttpPort}/v1/traces");
- var exporterOptions = new OtlpExporterOptions() { Endpoint = endpoint, TimeoutMilliseconds = 20000 };
+ var exporterOptions = new OtlpExporterOptions() { Endpoint = endpoint, TimeoutMilliseconds = 20000, Protocol = OtlpExportProtocol.HttpProtobuf };
- var exportClient = new OtlpHttpTraceExportClient(exporterOptions, new HttpClient());
-
- OtlpExporterTransmissionHandler transmissionHandler;
-
- // TODO: update this to configure via experimental environment variable.
- if (useRetryTransmissionHandler)
- {
- transmissionHandler = new OtlpExporterRetryTransmissionHandler(exportClient, exporterOptions.TimeoutMilliseconds);
- }
- else
- {
- transmissionHandler = new OtlpExporterTransmissionHandler(exportClient, exporterOptions.TimeoutMilliseconds);
- }
+ var configuration = new ConfigurationBuilder()
+ .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EnableInMemoryRetryEnvVar] = useRetryTransmissionHandler.ToString() })
+ .Build();
- var otlpExporter = new OtlpTraceExporter(exporterOptions, new(), transmissionHandler);
+ var otlpExporter = new OtlpTraceExporter(exporterOptions, new SdkLimitOptions(), new ExperimentalOptions(configuration));
var activitySourceName = "otel.http.retry.test";
using var source = new ActivitySource(activitySourceName);
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs
index dd8464d9145..55d9e092bb7 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs
@@ -4,6 +4,7 @@
#if NETFRAMEWORK
using System.Net.Http;
#endif
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
using Xunit;
@@ -185,19 +186,19 @@ public void GetTransmissionHandler_InitializesCorrectExportClientAndTimeoutValue
if (exportClientType == typeof(OtlpGrpcTraceExportClient) || exportClientType == typeof(OtlpHttpTraceExportClient))
{
- var transmissionHandler = exporterOptions.GetTraceExportTransmissionHandler();
+ var transmissionHandler = exporterOptions.GetTraceExportTransmissionHandler(new ExperimentalOptions());
AssertTransmissionHandlerProperties(transmissionHandler, exportClientType, expectedTimeoutMilliseconds);
}
else if (exportClientType == typeof(OtlpGrpcMetricsExportClient) || exportClientType == typeof(OtlpHttpMetricsExportClient))
{
- var transmissionHandler = exporterOptions.GetMetricsExportTransmissionHandler();
+ var transmissionHandler = exporterOptions.GetMetricsExportTransmissionHandler(new ExperimentalOptions());
AssertTransmissionHandlerProperties(transmissionHandler, exportClientType, expectedTimeoutMilliseconds);
}
else
{
- var transmissionHandler = exporterOptions.GetLogsExportTransmissionHandler();
+ var transmissionHandler = exporterOptions.GetLogsExportTransmissionHandler(new ExperimentalOptions());
AssertTransmissionHandlerProperties(transmissionHandler, exportClientType, expectedTimeoutMilliseconds);
}
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs
index 527fb5de72b..1a06d7eca4f 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs
@@ -23,6 +23,8 @@ public class OtlpTraceExporterTests : Http2UnencryptedSupportTests
{
private static readonly SdkLimitOptions DefaultSdkLimitOptions = new();
+ private static readonly ExperimentalOptions DefaultExperimentalOptions = new();
+
static OtlpTraceExporterTests()
{
Activity.DefaultIdFormat = ActivityIdFormat.W3C;
@@ -627,8 +629,7 @@ public void Shutdown_ClientShutdownIsCalled()
var exporterOptions = new OtlpExporterOptions();
var transmissionHandler = new OtlpExporterTransmissionHandler(exportClientMock, exporterOptions.TimeoutMilliseconds);
- var exporter = new OtlpTraceExporter(exporterOptions, DefaultSdkLimitOptions, transmissionHandler);
-
+ var exporter = new OtlpTraceExporter(new OtlpExporterOptions(), DefaultSdkLimitOptions, DefaultExperimentalOptions, transmissionHandler);
exporter.Shutdown();
Assert.True(exportClientMock.ShutdownCalled);