Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[otlp] Rename key for enabling retries during transient failures #5495

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
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).
([#5486](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5486))

* **Removed** `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` and added
vishweshbankwar marked this conversation as resolved.
Show resolved Hide resolved
`OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY`. `OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY`
when set to `in_memory` will enable automatic retries in case of transient
failures during data export to otlp endpoint.
vishweshbankwar marked this conversation as resolved.
Show resolved Hide resolved
([#5495](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5495))

## 1.8.0-rc.1

Released 2024-Mar-27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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 const string OtlpRetryEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY";

public ExperimentalOptions()
: this(new ConfigurationBuilder().AddEnvironmentVariables().Build())
Expand All @@ -29,9 +29,9 @@ public ExperimentalOptions(IConfiguration configuration)
this.EmitLogEventAttributes = emitLogEventAttributes;
}

if (configuration.TryGetBoolValue(OpenTelemetryProtocolExporterEventSource.Log, EnableInMemoryRetryEnvVar, out var enableInMemoryRetry))
if (configuration.TryGetStringValue(OpenTelemetryProtocolExporterEventSource.Log, OtlpRetryEnvVar, out var retryPolicy) && retryPolicy != null && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase))
{
this.EnableInMemoryRetry = enableInMemoryRetry;
this.EnableInMemoryRetry = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,9 @@ want to solicit feedback from the community.

* All signals

* `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY`
* `OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY`

When set to `true`, it enables in-memory retry for transient errors
When set to `in_memory`, it enables in-memory retry for transient errors
vishweshbankwar marked this conversation as resolved.
Show resolved Hide resolved
encountered while sending telemetry.

Added in `1.8.0-beta.1`.
Expand Down
18 changes: 18 additions & 0 deletions src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ public static bool TryGetBoolValue(
return true;
}

public static bool TryGetStringValue(
vishweshbankwar marked this conversation as resolved.
Show resolved Hide resolved
this IConfiguration configuration,
IConfigurationExtensionsLogger logger,
string key,
out string? value)
{
Debug.Assert(logger != null, "logger was null");

if (!configuration.TryGetStringValue(key, out var stringValue))
{
value = null;
return false;
}

value = stringValue;
return true;
}

public static bool TryGetValue<T>(
this IConfiguration configuration,
IConfigurationExtensionsLogger logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public async Task GrpcRetryTests(bool useRetryTransmissionHandler, ExportResult
var exporterOptions = new OtlpExporterOptions() { Endpoint = endpoint, TimeoutMilliseconds = 20000, Protocol = OtlpExportProtocol.Grpc };

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

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

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

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