Skip to content

Commit 32d2ea4

Browse files
committed
Remove unused timeout parameter from OTLP Shutdown methods
No implementation honored timeoutMilliseconds - all paths just dispose the HttpClient. The real flush is bounded by the HTTP client timeout during the preceding DisposeAsync/StopAsync, so Shutdown() does not need to block. Drop the parameter and the now-unused _timeoutMs field in MetricReader.
1 parent 6b4a632 commit 32d2ea4

8 files changed

Lines changed: 23 additions & 17 deletions

File tree

tracer/src/Datadog.Trace/Logging/DirectSubmission/Sink/OtlpSubmissionLogSink.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ protected override void DelayEvents(TimeSpan delayUntilNextFlush)
7676

7777
public override async Task DisposeAsync()
7878
{
79+
// Final flush is awaited by base.DisposeAsync() and bounded by the HTTP
80+
// client timeout; Shutdown() just releases the HTTP client resources.
7981
await base.DisposeAsync().ConfigureAwait(false);
80-
if (!_otlpExporter.Shutdown(timeoutMilliseconds: 5000))
82+
if (!_otlpExporter.Shutdown())
8183
{
8284
_logger.Warning("OTLP exporter shutdown did not complete successfully.");
8385
}

tracer/src/Datadog.Trace/OpenTelemetry/Logs/IOtlpExporter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ internal interface IOtlpExporter
2626
Task<ExportResult> ExportAsync(IReadOnlyList<LogPoint> logs);
2727

2828
/// <summary>
29-
/// Shuts down the exporter and ensures all pending exports complete.
29+
/// Releases the exporter's HTTP resources. Does not wait on pending exports:
30+
/// the final flush runs synchronously in the sink's DisposeAsync before this is
31+
/// called, bounded by the HTTP client timeout (OTEL_EXPORTER_OTLP_TIMEOUT).
3032
/// </summary>
31-
/// <param name="timeoutMilliseconds">Maximum time to wait for shutdown</param>
3233
/// <returns>True if shutdown completed successfully</returns>
33-
bool Shutdown(int timeoutMilliseconds);
34+
bool Shutdown();
3435
}
3536
#endif

tracer/src/Datadog.Trace/OpenTelemetry/Logs/OtlpExporter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ public async Task<ExportResult> ExportAsync(IReadOnlyList<LogPoint> logs)
129129
}
130130

131131
/// <summary>
132-
/// Shuts down the exporter and ensures all pending exports complete.
132+
/// Releases the exporter's HTTP resources. The final flush already ran
133+
/// synchronously in the sink's DisposeAsync (bounded by the HTTP client
134+
/// timeout, OTEL_EXPORTER_OTLP_TIMEOUT), so there is nothing further to wait on.
133135
/// </summary>
134-
/// <param name="timeoutMilliseconds">Maximum time to wait for shutdown</param>
135136
/// <returns>True if shutdown completed successfully</returns>
136-
public bool Shutdown(int timeoutMilliseconds)
137+
public bool Shutdown()
137138
{
138139
try
139140
{

tracer/src/Datadog.Trace/OpenTelemetry/Metrics/InMemoryExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public override Task<ExportResult> ExportAsync(IReadOnlyList<MetricPoint> metric
4646
return Task.FromResult(result);
4747
}
4848

49-
public override bool Shutdown(int timeoutMilliseconds)
49+
public override bool Shutdown()
5050
{
5151
return true;
5252
}

tracer/src/Datadog.Trace/OpenTelemetry/Metrics/MetricExporter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ internal abstract class MetricExporter
2323
public abstract Task<ExportResult> ExportAsync(IReadOnlyList<MetricPoint> metrics);
2424

2525
/// <summary>
26-
/// Shuts down the exporter.
26+
/// Releases exporter resources. The final flush is driven by the caller
27+
/// (MetricReader.StopAsync) and bounded by the export path's own timeout;
28+
/// this method is not expected to block.
2729
/// </summary>
28-
public abstract bool Shutdown(int timeoutMilliseconds);
30+
public abstract bool Shutdown();
2931
}
3032
}
3133
#endif

tracer/src/Datadog.Trace/OpenTelemetry/Metrics/MetricReader.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ internal sealed class MetricReader
2424
{
2525
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(MetricReader));
2626
private readonly int _exportIntervalMs;
27-
private readonly int _timeoutMs;
2827
private readonly MetricReaderHandler _handler;
2928
private readonly MetricExporter _exporter;
3029
private MeterListener? _listener;
@@ -33,7 +32,6 @@ internal sealed class MetricReader
3332
public MetricReader(TracerSettings settings, MetricReaderHandler handler, MetricExporter exporter)
3433
{
3534
_exportIntervalMs = settings.OtelMetricExportIntervalMs;
36-
_timeoutMs = settings.OtlpMetricsTimeoutMs;
3735
_handler = handler;
3836
_exporter = exporter;
3937
}
@@ -95,7 +93,7 @@ public async Task StopAsync()
9593
}
9694
finally
9795
{
98-
_exporter.Shutdown(_timeoutMs);
96+
_exporter.Shutdown();
9997
_listener?.Dispose();
10098
_listener = null;
10199
Log.Debug("MetricReader stopped");

tracer/src/Datadog.Trace/OpenTelemetry/Metrics/OtlpExporter.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ public override async Task<ExportResult> ExportAsync(IReadOnlyList<MetricPoint>
126126
}
127127

128128
/// <summary>
129-
/// Shuts down the exporter and ensures all pending exports complete.
129+
/// Releases the exporter's HTTP resources. The final export already ran
130+
/// synchronously in MetricReader.StopAsync and is bounded by the HTTP
131+
/// request timeout (OTEL_EXPORTER_OTLP_METRICS_TIMEOUT), so there is
132+
/// nothing further to wait on here.
130133
/// </summary>
131-
/// <param name="timeoutMilliseconds">Maximum time to wait for shutdown</param>
132134
/// <returns>True if shutdown completed successfully, false otherwise</returns>
133-
public override bool Shutdown(int timeoutMilliseconds)
135+
public override bool Shutdown()
134136
{
135137
try
136138
{

tracer/test/Datadog.Trace.Tests/Logging/DirectSubmission/Sink/OtlpSinkTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public async Task<ExportResult> ExportAsync(IReadOnlyList<LogPoint> logs)
263263
return await _exportFunc(logs).ConfigureAwait(false);
264264
}
265265

266-
public bool Shutdown(int timeoutMilliseconds)
266+
public bool Shutdown()
267267
{
268268
return true;
269269
}

0 commit comments

Comments
 (0)