Skip to content

Commit dbec6f8

Browse files
[otlp] Rename key for enabling retries during transient failures (open-telemetry#5495)
Co-authored-by: Reiley Yang <reyang@microsoft.com>
1 parent e5ca93b commit dbec6f8

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
is not required to be set [when using .NET 5 or newer](https://learn.microsoft.com/aspnet/core/grpc/troubleshoot?view=aspnetcore-8.0#call-insecure-grpc-services-with-net-core-client).
1111
([#5486](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5486))
1212

13+
* Replaced environment variable
14+
`OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` with
15+
`OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY`. `OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY`
16+
when set to `in_memory` will enable automatic retries in case of transient
17+
failures during data export to an OTLP endpoint.
18+
([#5495](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5495))
19+
1320
## 1.8.0-rc.1
1421

1522
Released 2024-Mar-27

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal sealed class ExperimentalOptions
1515

1616
public const string EmitLogEventEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES";
1717

18-
public const string EnableInMemoryRetryEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY";
18+
public const string OtlpRetryEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY";
1919

2020
public ExperimentalOptions()
2121
: this(new ConfigurationBuilder().AddEnvironmentVariables().Build())
@@ -29,9 +29,9 @@ public ExperimentalOptions(IConfiguration configuration)
2929
this.EmitLogEventAttributes = emitLogEventAttributes;
3030
}
3131

32-
if (configuration.TryGetBoolValue(OpenTelemetryProtocolExporterEventSource.Log, EnableInMemoryRetryEnvVar, out var enableInMemoryRetry))
32+
if (configuration.TryGetStringValue(OtlpRetryEnvVar, out var retryPolicy) && retryPolicy != null && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase))
3333
{
34-
this.EnableInMemoryRetry = enableInMemoryRetry;
34+
this.EnableInMemoryRetry = true;
3535
}
3636
}
3737

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,12 @@ want to solicit feedback from the community.
625625

626626
* All signals
627627

628-
* `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY`
628+
* `OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY`
629629

630-
When set to `true`, it enables in-memory retry for transient errors
630+
When set to `in_memory`, it enables in-memory retry for transient errors
631631
encountered while sending telemetry.
632632

633-
Added in `1.8.0-beta.1`.
633+
Added in `1.8.0`.
634634

635635
* Logs
636636

test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public async Task GrpcRetryTests(bool useRetryTransmissionHandler, ExportResult
179179
var exporterOptions = new OtlpExporterOptions() { Endpoint = endpoint, TimeoutMilliseconds = 20000, Protocol = OtlpExportProtocol.Grpc };
180180

181181
var configuration = new ConfigurationBuilder()
182-
.AddInMemoryCollection(new Dictionary<string, string> { [ExperimentalOptions.EnableInMemoryRetryEnvVar] = useRetryTransmissionHandler.ToString() })
182+
.AddInMemoryCollection(new Dictionary<string, string> { [ExperimentalOptions.OtlpRetryEnvVar] = useRetryTransmissionHandler ? "in_memory" : null })
183183
.Build();
184184

185185
var otlpExporter = new OtlpTraceExporter(exporterOptions, new SdkLimitOptions(), new ExperimentalOptions(configuration));
@@ -263,7 +263,7 @@ public async Task HttpRetryTests(bool useRetryTransmissionHandler, ExportResult
263263
var exporterOptions = new OtlpExporterOptions() { Endpoint = endpoint, TimeoutMilliseconds = 20000, Protocol = OtlpExportProtocol.HttpProtobuf };
264264

265265
var configuration = new ConfigurationBuilder()
266-
.AddInMemoryCollection(new Dictionary<string, string> { [ExperimentalOptions.EnableInMemoryRetryEnvVar] = useRetryTransmissionHandler.ToString() })
266+
.AddInMemoryCollection(new Dictionary<string, string> { [ExperimentalOptions.OtlpRetryEnvVar] = useRetryTransmissionHandler ? "in_memory" : null })
267267
.Build();
268268

269269
var otlpExporter = new OtlpTraceExporter(exporterOptions, new SdkLimitOptions(), new ExperimentalOptions(configuration));

0 commit comments

Comments
 (0)