From c5502a9057c7b154ed678020277b7143e1d7fe59 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 11:34:11 -0700 Subject: [PATCH 01/11] [otlp] rename environment variable for retries --- .../Implementation/ExperimentalOptions.cs | 6 +++--- .../OpenTelemetryConfigurationExtensions.cs | 18 ++++++++++++++++++ .../MockCollectorIntegrationTests.cs | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index 66c60f338a4..40b1a6f483a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -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()) @@ -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; } } diff --git a/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs b/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs index d591ae22076..417603cdb5f 100644 --- a/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs +++ b/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs @@ -107,6 +107,24 @@ public static bool TryGetBoolValue( return true; } + public static bool TryGetStringValue( + 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( this IConfiguration configuration, IConfigurationExtensionsLogger logger, diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs index e90201341c6..a5ce7a0a279 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs @@ -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 { [ExperimentalOptions.EnableInMemoryRetryEnvVar] = useRetryTransmissionHandler.ToString() }) + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.OtlpRetryEnvVar] = useRetryTransmissionHandler ? "in_memory" : null }) .Build(); var otlpExporter = new OtlpTraceExporter(exporterOptions, new SdkLimitOptions(), new ExperimentalOptions(configuration)); @@ -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 { [ExperimentalOptions.EnableInMemoryRetryEnvVar] = useRetryTransmissionHandler.ToString() }) + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.OtlpRetryEnvVar] = useRetryTransmissionHandler ? "in_memory" : null }) .Build(); var otlpExporter = new OtlpTraceExporter(exporterOptions, new SdkLimitOptions(), new ExperimentalOptions(configuration)); From 1ffea91ef17b209a46ba37706f4cc1a62921839e Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 11:36:03 -0700 Subject: [PATCH 02/11] update readme --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 6648f4d1581..e1b72393a78 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -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 encountered while sending telemetry. Added in `1.8.0-beta.1`. From 78d85b3cbb08cccb543cbea738dd1075eab2c2b8 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 11:43:45 -0700 Subject: [PATCH 03/11] Changelog --- .../CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 535403998ab..f5812463a20 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -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`. Added + `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. + ([#5495](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5495)) + ## 1.8.0-rc.1 Released 2024-Mar-27 From 6b69400e3a9c34f2573caa377021da309fc639d1 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 11:48:27 -0700 Subject: [PATCH 04/11] reword --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index f5812463a20..e7834c7cb30 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -10,7 +10,7 @@ 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`. Added +* **Removed** `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` and added `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. From fcb4eee52782684d80a95d26b72c2227b2fb1adf Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 11:56:08 -0700 Subject: [PATCH 05/11] Read me fix --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index e1b72393a78..dd14461e6a5 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -630,7 +630,7 @@ want to solicit feedback from the community. When set to `in_memory`, it enables in-memory retry for transient errors encountered while sending telemetry. - Added in `1.8.0-beta.1`. + Added in `1.8.0`. * Logs From ebdae7a166ec99a26b83b649a13addfee53b5869 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 12:00:08 -0700 Subject: [PATCH 06/11] review --- .../Implementation/ExperimentalOptions.cs | 2 +- .../OpenTelemetryConfigurationExtensions.cs | 18 ------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index 40b1a6f483a..da9c185a516 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -29,7 +29,7 @@ public ExperimentalOptions(IConfiguration configuration) this.EmitLogEventAttributes = emitLogEventAttributes; } - if (configuration.TryGetStringValue(OpenTelemetryProtocolExporterEventSource.Log, OtlpRetryEnvVar, out var retryPolicy) && retryPolicy != null && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase)) + if (configuration.TryGetStringValue(OtlpRetryEnvVar, out var retryPolicy) && retryPolicy != null && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase)) { this.EnableInMemoryRetry = true; } diff --git a/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs b/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs index 417603cdb5f..d591ae22076 100644 --- a/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs +++ b/src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs @@ -107,24 +107,6 @@ public static bool TryGetBoolValue( return true; } - public static bool TryGetStringValue( - 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( this IConfiguration configuration, IConfigurationExtensionsLogger logger, From 47dde08d39d29602910ef18e08fee6b50d2b6cff Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 12:05:26 -0700 Subject: [PATCH 07/11] review --- .../Implementation/ExperimentalOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index da9c185a516..ad9b1277f0d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -29,7 +29,7 @@ public ExperimentalOptions(IConfiguration configuration) this.EmitLogEventAttributes = emitLogEventAttributes; } - if (configuration.TryGetStringValue(OtlpRetryEnvVar, out var retryPolicy) && retryPolicy != null && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase)) + if (configuration.TryGetStringValue(OtlpRetryEnvVar, out var retryPolicy) && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase)) { this.EnableInMemoryRetry = true; } From a1911f27dfd0296af48990fd1a57f6fd7f073454 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 12:12:56 -0700 Subject: [PATCH 08/11] revert --- .../Implementation/ExperimentalOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index ad9b1277f0d..da9c185a516 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -29,7 +29,7 @@ public ExperimentalOptions(IConfiguration configuration) this.EmitLogEventAttributes = emitLogEventAttributes; } - if (configuration.TryGetStringValue(OtlpRetryEnvVar, out var retryPolicy) && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase)) + if (configuration.TryGetStringValue(OtlpRetryEnvVar, out var retryPolicy) && retryPolicy != null && retryPolicy.Equals("in_memory", StringComparison.OrdinalIgnoreCase)) { this.EnableInMemoryRetry = true; } From 85bc08f8dfda3101b76525e6a59a389f0396a2b5 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 14:28:35 -0700 Subject: [PATCH 09/11] Update src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md Co-authored-by: Reiley Yang --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index e7834c7cb30..e64091137dc 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -13,7 +13,7 @@ * **Removed** `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` and added `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. + failures during data export to an OTLP endpoint. ([#5495](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5495)) ## 1.8.0-rc.1 From 93b5a7bc28674537c45ad4f2c74262a94b999e12 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 15:25:02 -0700 Subject: [PATCH 10/11] Update src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md Co-authored-by: Reiley Yang --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index e64091137dc..5b2327484d4 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -10,7 +10,7 @@ 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 +* Replaced environment variable `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` with `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 an OTLP endpoint. From 02b9fc14167fa22f3d88de6a12648f701cf6c959 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 1 Apr 2024 15:25:58 -0700 Subject: [PATCH 11/11] fix md format --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 5b2327484d4..1bfb82fae75 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -10,7 +10,8 @@ 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)) -* Replaced environment variable `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` with +* Replaced environment variable + `OTEL_DOTNET_EXPERIMENTAL_OTLP_ENABLE_INMEMORY_RETRY` with `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 an OTLP endpoint.