-
Notifications
You must be signed in to change notification settings - Fork 774
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into server.port-always
- Loading branch information
Showing
5 changed files
with
322 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...OpenTelemetryProtocol/Implementation/Transmission/OtlpExporterRetryTransmissionHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#nullable enable | ||
|
||
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; | ||
|
||
namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission; | ||
|
||
internal sealed class OtlpExporterRetryTransmissionHandler<TRequest> : OtlpExporterTransmissionHandler<TRequest> | ||
{ | ||
internal OtlpExporterRetryTransmissionHandler(IExportClient<TRequest> exportClient, double timeoutMilliseconds) | ||
: base(exportClient, timeoutMilliseconds) | ||
{ | ||
} | ||
|
||
protected override bool OnSubmitRequestFailure(TRequest request, ExportClientResponse response) | ||
{ | ||
var nextRetryDelayMilliseconds = OtlpRetry.InitialBackoffMilliseconds; | ||
while (RetryHelper.ShouldRetryRequest(request, response, nextRetryDelayMilliseconds, out var retryResult)) | ||
{ | ||
// Note: This delay cannot exceed the configured timeout period for otlp exporter. | ||
// If the backend responds with `RetryAfter` duration that would result in exceeding the configured timeout period | ||
// we would fail fast and drop the data. | ||
Thread.Sleep(retryResult.RetryDelay); | ||
|
||
if (this.TryRetryRequest(request, response.DeadlineUtc, out response)) | ||
{ | ||
return true; | ||
} | ||
|
||
nextRetryDelayMilliseconds = retryResult.NextRetryDelayMilliseconds; | ||
} | ||
|
||
return false; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Transmission/RetryHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#nullable enable | ||
|
||
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; | ||
|
||
namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.Transmission; | ||
|
||
internal static class RetryHelper | ||
{ | ||
internal static bool ShouldRetryRequest<TRequest>(TRequest request, ExportClientResponse response, int retryDelayMilliseconds, out OtlpRetry.RetryResult retryResult) | ||
{ | ||
if (response is ExportClientGrpcResponse grpcResponse) | ||
{ | ||
if (OtlpRetry.TryGetGrpcRetryResult(grpcResponse, retryDelayMilliseconds, out retryResult)) | ||
{ | ||
return true; | ||
} | ||
} | ||
else if (response is ExportClientHttpResponse httpResponse) | ||
{ | ||
if (OtlpRetry.TryGetHttpRetryResult(httpResponse, retryDelayMilliseconds, out retryResult)) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
retryResult = default; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.