diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpHttpExportClient.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpHttpExportClient.cs
index 56f0118aa87..4aad820b1e2 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpHttpExportClient.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpHttpExportClient.cs
@@ -38,6 +38,9 @@ protected BaseOtlpHttpExportClient(OtlpExporterOptions options, HttpClient httpC
///
public ExportClientResponse SendExportRequest(TRequest request, CancellationToken cancellationToken = default)
{
+ // `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.
DateTime deadline = DateTime.UtcNow.AddMilliseconds(this.HttpClient.Timeout.TotalMilliseconds);
try
{
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OpenTelemetryProtocolExporterEventSource.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OpenTelemetryProtocolExporterEventSource.cs
index 31ed2a749f4..97fe4dcb80b 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OpenTelemetryProtocolExporterEventSource.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OpenTelemetryProtocolExporterEventSource.cs
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#if NET6_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using System.Diagnostics.Tracing;
using OpenTelemetry.Internal;
@@ -33,6 +30,15 @@ public void ExportMethodException(Exception ex, bool isRetry = false)
}
}
+ [NonEvent]
+ public void TrySubmitRequestException(Exception ex)
+ {
+ if (Log.IsEnabled(EventLevel.Error, EventKeywords.All))
+ {
+ this.TrySubmitRequestException(ex.ToInvariantString());
+ }
+ }
+
[Event(2, Message = "Exporter failed send data to collector to {0} endpoint. Data will not be sent. Exception: {1}", Level = EventLevel.Error)]
public void FailedToReachCollector(string rawCollectorUri, string ex)
{
@@ -45,9 +51,6 @@ public void CouldNotTranslateActivity(string className, string methodName)
this.WriteEvent(3, className, methodName);
}
-#if NET6_0_OR_GREATER
- [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Parameters to this method are primitive and are trimmer safe.")]
-#endif
[Event(4, Message = "Unknown error in export method. Message: '{0}'. IsRetry: {1}", Level = EventLevel.Error)]
public void ExportMethodException(string ex, bool isRetry)
{
@@ -83,4 +86,10 @@ public void InvalidEnvironmentVariable(string key, string value)
{
this.WriteEvent(11, key, value);
}
+
+ [Event(12, Message = "Unknown error in TrySubmitRequest method. Message: '{0}'", Level = EventLevel.Error)]
+ public void TrySubmitRequestException(string ex)
+ {
+ this.WriteEvent(12, ex);
+ }
}
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Transmission/OtlpExporterTransmissionHandler.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Transmission/OtlpExporterTransmissionHandler.cs
new file mode 100644
index 00000000000..71f4d5ebac1
--- /dev/null
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Transmission/OtlpExporterTransmissionHandler.cs
@@ -0,0 +1,120 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+#nullable enable
+
+using System.Diagnostics;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
+using OpenTelemetry.Internal;
+
+namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
+
+internal class OtlpExporterTransmissionHandler
+{
+ public OtlpExporterTransmissionHandler(IExportClient exportClient)
+ {
+ Guard.ThrowIfNull(exportClient);
+
+ this.ExportClient = exportClient;
+ }
+
+ protected IExportClient ExportClient { get; }
+
+ ///
+ /// Attempts to send an export request to the server.
+ ///
+ /// The request to send to the server.
+ /// if the request is sent successfully; otherwise, .
+ ///
+ public bool TrySubmitRequest(TRequest request)
+ {
+ try
+ {
+ var response = this.ExportClient.SendExportRequest(request);
+ if (response.Success)
+ {
+ return true;
+ }
+
+ return this.OnSubmitRequestFailure(request, response);
+ }
+ catch (Exception ex)
+ {
+ OpenTelemetryProtocolExporterEventSource.Log.TrySubmitRequestException(ex);
+ return false;
+ }
+ }
+
+ ///
+ /// Attempts to shutdown the transmission handler, blocks the current thread
+ /// until shutdown completed or timed out.
+ ///
+ ///
+ /// The number (non-negative) of milliseconds to wait, or
+ /// Timeout.Infinite to wait indefinitely.
+ ///
+ ///
+ /// Returns if shutdown succeeded; otherwise, .
+ ///
+ public bool Shutdown(int timeoutMilliseconds)
+ {
+ Guard.ThrowIfInvalidTimeout(timeoutMilliseconds);
+
+ var sw = timeoutMilliseconds == Timeout.Infinite ? null : Stopwatch.StartNew();
+
+ this.OnShutdown(timeoutMilliseconds);
+
+ if (sw != null)
+ {
+ var timeout = timeoutMilliseconds - sw.ElapsedMilliseconds;
+
+ return this.ExportClient.Shutdown((int)Math.Max(timeout, 0));
+ }
+
+ return this.ExportClient.Shutdown(timeoutMilliseconds);
+ }
+
+ ///
+ /// Fired when the transmission handler is shutdown.
+ ///
+ ///
+ /// The number (non-negative) of milliseconds to wait, or
+ /// Timeout.Infinite to wait indefinitely.
+ ///
+ protected virtual void OnShutdown(int timeoutMilliseconds)
+ {
+ }
+
+ ///
+ /// Fired when a request could not be submitted.
+ ///
+ /// The request that was attempted to send to the server.
+ /// .
+ /// If the request is resubmitted and succeeds; otherwise, .
+ protected virtual bool OnSubmitRequestFailure(TRequest request, ExportClientResponse response)
+ {
+ return false;
+ }
+
+ ///
+ /// Fired when resending a request to the server.
+ ///
+ /// The request to be resent to the server.
+ /// .
+ /// If the retry succeeds; otherwise, .
+ protected bool TryRetryRequest(TRequest request, out ExportClientResponse response)
+ {
+ response = this.ExportClient.SendExportRequest(request);
+ if (!response.Success)
+ {
+ OpenTelemetryProtocolExporterEventSource.Log.ExportMethodException(response.Exception, isRetry: true);
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs
index 91a23749804..44133af1f84 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs
@@ -10,6 +10,7 @@
#if NETSTANDARD2_1 || NET6_0_OR_GREATER
using Grpc.Net.Client;
#endif
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
using LogOtlpCollector = OpenTelemetry.Proto.Collector.Logs.V1;
using MetricsOtlpCollector = OpenTelemetry.Proto.Collector.Metrics.V1;
using TraceOtlpCollector = OpenTelemetry.Proto.Collector.Trace.V1;
@@ -87,6 +88,15 @@ public static THeaders GetHeaders(this OtlpExporterOptions options, Ac
return headers;
}
+ public static OtlpExporterTransmissionHandler GetTraceExportTransmissionHandler(this OtlpExporterOptions options)
+ => new(GetTraceExportClient(options));
+
+ public static OtlpExporterTransmissionHandler GetMetricsExportTransmissionHandler(this OtlpExporterOptions options)
+ => new(GetMetricsExportClient(options));
+
+ public static OtlpExporterTransmissionHandler GetLogsExportTransmissionHandler(this OtlpExporterOptions options)
+ => new(GetLogExportClient(options));
+
public static IExportClient GetTraceExportClient(this OtlpExporterOptions options) =>
options.Protocol switch
{
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs
index 7ee6bf74f3c..8e5c626d917 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs
@@ -5,7 +5,7 @@
using System.Diagnostics;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
-using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
using OpenTelemetry.Internal;
using OpenTelemetry.Logs;
using OtlpCollector = OpenTelemetry.Proto.Collector.Logs.V1;
@@ -19,7 +19,7 @@ namespace OpenTelemetry.Exporter;
///
public sealed class OtlpLogExporter : BaseExporter
{
- private readonly IExportClient exportClient;
+ private readonly OtlpExporterTransmissionHandler transmissionHandler;
private readonly OtlpLogRecordTransformer otlpLogRecordTransformer;
private OtlpResource.Resource? processResource;
@@ -29,7 +29,7 @@ public sealed class OtlpLogExporter : BaseExporter
///
/// Configuration options for the exporter.
public OtlpLogExporter(OtlpExporterOptions options)
- : this(options, sdkLimitOptions: new(), experimentalOptions: new(), exportClient: null)
+ : this(options, sdkLimitOptions: new(), experimentalOptions: new(), transmissionHandler: null)
{
}
@@ -39,12 +39,12 @@ public OtlpLogExporter(OtlpExporterOptions options)
/// Configuration options for the exporter.
/// .
/// .
- /// Client used for sending export request.
+ /// .
internal OtlpLogExporter(
OtlpExporterOptions exporterOptions,
SdkLimitOptions sdkLimitOptions,
ExperimentalOptions experimentalOptions,
- IExportClient? exportClient = null)
+ OtlpExporterTransmissionHandler? transmissionHandler = null)
{
Debug.Assert(exporterOptions != null, "exporterOptions was null");
Debug.Assert(sdkLimitOptions != null, "sdkLimitOptions was null");
@@ -62,14 +62,7 @@ internal OtlpLogExporter(
OpenTelemetryProtocolExporterEventSource.Log.InvalidEnvironmentVariable(key, value);
};
- if (exportClient != null)
- {
- this.exportClient = exportClient;
- }
- else
- {
- this.exportClient = exporterOptions!.GetLogExportClient();
- }
+ this.transmissionHandler = transmissionHandler ?? exporterOptions.GetLogsExportTransmissionHandler();
this.otlpLogRecordTransformer = new OtlpLogRecordTransformer(sdkLimitOptions!, experimentalOptions!);
}
@@ -89,7 +82,7 @@ public override ExportResult Export(in Batch logRecordBatch)
{
request = this.otlpLogRecordTransformer.BuildExportRequest(this.ProcessResource, logRecordBatch);
- if (!this.exportClient.SendExportRequest(request).Success)
+ if (!this.transmissionHandler.TrySubmitRequest(request))
{
return ExportResult.Failure;
}
@@ -113,6 +106,6 @@ public override ExportResult Export(in Batch logRecordBatch)
///
protected override bool OnShutdown(int timeoutMilliseconds)
{
- return this.exportClient?.Shutdown(timeoutMilliseconds) ?? true;
+ return this.transmissionHandler?.Shutdown(timeoutMilliseconds) ?? true;
}
}
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs
index ecc97994166..a0026d1e9f4 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporter.cs
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
-using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
using OpenTelemetry.Internal;
using OpenTelemetry.Metrics;
using OtlpCollector = OpenTelemetry.Proto.Collector.Metrics.V1;
@@ -16,7 +16,7 @@ namespace OpenTelemetry.Exporter;
///
public class OtlpMetricExporter : BaseExporter
{
- private readonly IExportClient exportClient;
+ private readonly OtlpExporterTransmissionHandler transmissionHandler;
private OtlpResource.Resource processResource;
@@ -25,7 +25,7 @@ public class OtlpMetricExporter : BaseExporter
///
/// Configuration options for the exporter.
public OtlpMetricExporter(OtlpExporterOptions options)
- : this(options, null)
+ : this(options, transmissionHandler: null)
{
}
@@ -33,8 +33,10 @@ public OtlpMetricExporter(OtlpExporterOptions options)
/// Initializes a new instance of the class.
///
/// Configuration options for the export.
- /// Client used for sending export request.
- internal OtlpMetricExporter(OtlpExporterOptions options, IExportClient exportClient = null)
+ /// .
+ internal OtlpMetricExporter(
+ OtlpExporterOptions options,
+ OtlpExporterTransmissionHandler transmissionHandler = null)
{
// Each of the Otlp exporters: Traces, Metrics, and Logs set the same value for `OtlpKeyValueTransformer.LogUnsupportedAttributeType`
// and `ConfigurationExtensions.LogInvalidEnvironmentVariable` so it should be fine even if these exporters are used together.
@@ -48,14 +50,7 @@ internal OtlpMetricExporter(OtlpExporterOptions options, IExportClient this.processResource ??= this.ParentProvider.GetResource().ToOtlpResource();
@@ -72,7 +67,7 @@ public override ExportResult Export(in Batch metrics)
{
request.AddMetrics(this.ProcessResource, metrics);
- if (!this.exportClient.SendExportRequest(request).Success)
+ if (!this.transmissionHandler.TrySubmitRequest(request))
{
return ExportResult.Failure;
}
@@ -93,6 +88,6 @@ public override ExportResult Export(in Batch metrics)
///
protected override bool OnShutdown(int timeoutMilliseconds)
{
- return this.exportClient?.Shutdown(timeoutMilliseconds) ?? true;
+ return this.transmissionHandler.Shutdown(timeoutMilliseconds);
}
}
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs
index 5febb7f4d01..f017d075428 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporter.cs
@@ -3,7 +3,7 @@
using System.Diagnostics;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
-using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
using OpenTelemetry.Internal;
using OtlpCollector = OpenTelemetry.Proto.Collector.Trace.V1;
using OtlpResource = OpenTelemetry.Proto.Resource.V1;
@@ -17,7 +17,7 @@ namespace OpenTelemetry.Exporter;
public class OtlpTraceExporter : BaseExporter
{
private readonly SdkLimitOptions sdkLimitOptions;
- private readonly IExportClient exportClient;
+ private readonly OtlpExporterTransmissionHandler transmissionHandler;
private OtlpResource.Resource processResource;
@@ -26,7 +26,7 @@ public class OtlpTraceExporter : BaseExporter
///
/// Configuration options for the export.
public OtlpTraceExporter(OtlpExporterOptions options)
- : this(options, new(), null)
+ : this(options, sdkLimitOptions: new(), transmissionHandler: null)
{
}
@@ -35,35 +35,22 @@ public OtlpTraceExporter(OtlpExporterOptions options)
///
/// .
/// .
- /// Client used for sending export request.
+ /// .
internal OtlpTraceExporter(
- OtlpExporterOptions exporterOptions,
- SdkLimitOptions sdkLimitOptions,
- IExportClient exportClient = null)
+ OtlpExporterOptions exporterOptions,
+ SdkLimitOptions sdkLimitOptions,
+ OtlpExporterTransmissionHandler transmissionHandler = null)
{
Debug.Assert(exporterOptions != null, "exporterOptions was null");
Debug.Assert(sdkLimitOptions != null, "sdkLimitOptions was null");
this.sdkLimitOptions = sdkLimitOptions;
- OtlpKeyValueTransformer.LogUnsupportedAttributeType = (string tagValueType, string tagKey) =>
- {
- OpenTelemetryProtocolExporterEventSource.Log.UnsupportedAttributeType(tagValueType, tagKey);
- };
+ OtlpKeyValueTransformer.LogUnsupportedAttributeType = OpenTelemetryProtocolExporterEventSource.Log.UnsupportedAttributeType;
- ConfigurationExtensions.LogInvalidEnvironmentVariable = (string key, string value) =>
- {
- OpenTelemetryProtocolExporterEventSource.Log.InvalidEnvironmentVariable(key, value);
- };
+ ConfigurationExtensions.LogInvalidEnvironmentVariable = OpenTelemetryProtocolExporterEventSource.Log.InvalidEnvironmentVariable;
- if (exportClient != null)
- {
- this.exportClient = exportClient;
- }
- else
- {
- this.exportClient = exporterOptions.GetTraceExportClient();
- }
+ this.transmissionHandler = transmissionHandler ?? exporterOptions.GetTraceExportTransmissionHandler();
}
internal OtlpResource.Resource ProcessResource => this.processResource ??= this.ParentProvider.GetResource().ToOtlpResource();
@@ -80,7 +67,7 @@ public override ExportResult Export(in Batch activityBatch)
{
request.AddBatch(this.sdkLimitOptions, this.ProcessResource, activityBatch);
- if (!this.exportClient.SendExportRequest(request).Success)
+ if (!this.transmissionHandler.TrySubmitRequest(request))
{
return ExportResult.Failure;
}
@@ -101,6 +88,6 @@ public override ExportResult Export(in Batch activityBatch)
///
protected override bool OnShutdown(int timeoutMilliseconds)
{
- return this.exportClient?.Shutdown(timeoutMilliseconds) ?? true;
+ return this.transmissionHandler.Shutdown(timeoutMilliseconds);
}
}
diff --git a/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs b/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs
index b8cffdbdb71..f80d59d2a14 100644
--- a/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs
+++ b/test/Benchmarks/Exporter/OtlpGrpcExporterBenchmarks.cs
@@ -11,6 +11,8 @@
using OpenTelemetryProtocol::OpenTelemetry.Exporter;
using OpenTelemetryProtocol::OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetryProtocol::OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
+using OpenTelemetryProtocol::OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
+using OpenTelemetryProtocol::OpenTelemetry.Proto.Collector.Trace.V1;
namespace Benchmarks.Exporter;
@@ -33,7 +35,7 @@ public void GlobalSetup()
this.exporter = new OtlpTraceExporter(
options,
new SdkLimitOptions(),
- new OtlpGrpcTraceExportClient(options, new TestTraceServiceClient()));
+ new OtlpExporterTransmissionHandler(new OtlpGrpcTraceExportClient(options, new TestTraceServiceClient())));
this.activity = ActivityHelper.CreateTestActivity();
this.activityBatch = new CircularBuffer(this.NumberOfSpans);
diff --git a/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs b/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs
index d4560579a92..86e79812be0 100644
--- a/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs
+++ b/test/Benchmarks/Exporter/OtlpHttpExporterBenchmarks.cs
@@ -12,6 +12,8 @@
using OpenTelemetryProtocol::OpenTelemetry.Exporter;
using OpenTelemetryProtocol::OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetryProtocol::OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient;
+using OpenTelemetryProtocol::OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
+using OpenTelemetryProtocol::OpenTelemetry.Proto.Collector.Trace.V1;
namespace Benchmarks.Exporter;
@@ -61,7 +63,7 @@ public void GlobalSetup()
this.exporter = new OtlpTraceExporter(
options,
new SdkLimitOptions(),
- new OtlpHttpTraceExportClient(options, options.HttpClientFactory()));
+ new OtlpExporterTransmissionHandler(new OtlpHttpTraceExportClient(options, options.HttpClientFactory())));
this.activity = ActivityHelper.CreateTestActivity();
this.activityBatch = new CircularBuffer(this.NumberOfSpans);
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs
index 7181557ae5a..a01d992040b 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs
@@ -10,6 +10,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
using OpenTelemetry.Internal;
using OpenTelemetry.Logs;
using OpenTelemetry.Resources;
@@ -731,13 +732,14 @@ public void Export_WhenExportClientIsProvidedInCtor_UsesProvidedExportClient()
{
// Arrange.
var testExportClient = new TestExportClient();
+ var transmissionHandler = new OtlpExporterTransmissionHandler(testExportClient);
var emptyLogRecords = Array.Empty();
var emptyBatch = new Batch(emptyLogRecords, emptyLogRecords.Length);
var sut = new OtlpLogExporter(
new OtlpExporterOptions(),
new SdkLimitOptions(),
new ExperimentalOptions(),
- testExportClient);
+ transmissionHandler);
// Act.
sut.Export(emptyBatch);
@@ -751,13 +753,14 @@ public void Export_WhenExportClientThrowsException_ReturnsExportResultFailure()
{
// Arrange.
var testExportClient = new TestExportClient(throwException: true);
+ var transmissionHandler = new OtlpExporterTransmissionHandler(testExportClient);
var emptyLogRecords = Array.Empty();
var emptyBatch = new Batch(emptyLogRecords, emptyLogRecords.Length);
var sut = new OtlpLogExporter(
new OtlpExporterOptions(),
new SdkLimitOptions(),
new ExperimentalOptions(),
- testExportClient);
+ transmissionHandler);
// Act.
var result = sut.Export(emptyBatch);
@@ -771,13 +774,14 @@ public void Export_WhenExportIsSuccessful_ReturnsExportResultSuccess()
{
// Arrange.
var testExportClient = new TestExportClient();
+ var transmissionHandler = new OtlpExporterTransmissionHandler(testExportClient);
var emptyLogRecords = Array.Empty();
var emptyBatch = new Batch(emptyLogRecords, emptyLogRecords.Length);
var sut = new OtlpLogExporter(
new OtlpExporterOptions(),
new SdkLimitOptions(),
new ExperimentalOptions(),
- testExportClient);
+ transmissionHandler);
// Act.
var result = sut.Export(emptyBatch);
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs
index 95f61d41297..0c7a5db76e2 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs
@@ -5,6 +5,7 @@
using Google.Protobuf.Collections;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
+using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Tests;
@@ -629,7 +630,9 @@ public void Shutdown_ClientShutdownIsCalled()
{
var exportClientMock = new TestExportClient();
- var exporter = new OtlpTraceExporter(new OtlpExporterOptions(), DefaultSdkLimitOptions, exportClientMock);
+ var transmissionHandler = new OtlpExporterTransmissionHandler(exportClientMock);
+
+ var exporter = new OtlpTraceExporter(new OtlpExporterOptions(), DefaultSdkLimitOptions, transmissionHandler);
exporter.Shutdown();