From 6b2bb13a543430d93311ac8ae2f7bca9b43c87e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Mon, 2 Aug 2021 12:45:06 +0200 Subject: [PATCH 01/11] Add support for OTEL_BSP_EXPORT_* environmental variables --- .../BatchExportProcessorOptions.cs | 66 +++++++++++ .../Trace/BatchExportProcessorOptionsTest.cs | 103 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 test/OpenTelemetry.Tests/Trace/BatchExportProcessorOptionsTest.cs diff --git a/src/OpenTelemetry/BatchExportProcessorOptions.cs b/src/OpenTelemetry/BatchExportProcessorOptions.cs index 90abda8abbb..3bd32e24729 100644 --- a/src/OpenTelemetry/BatchExportProcessorOptions.cs +++ b/src/OpenTelemetry/BatchExportProcessorOptions.cs @@ -14,11 +14,57 @@ // limitations under the License. // +using System; +using System.Security; + namespace OpenTelemetry { public class BatchExportProcessorOptions where T : class { + internal const string MaxQueueSizeEnvVarKey = "OTEL_BSP_MAX_QUEUE_SIZE"; + + internal const string MaxExportBatchSizeEnvVarKey = "OTEL_BSP_MAX_EXPORT_BATCH_SIZE"; + + internal const string ExporterTimeoutEnvVarKey = "OTEL_BSP_EXPORT_TIMEOUT"; + + internal const string ScheduledDelayEnvVarKey = "OTEL_BSP_SCHEDULE_DELAY"; + + public BatchExportProcessorOptions() + { + try + { + int value; + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, out value)) + { + this.ExporterTimeoutMilliseconds = value; + } + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxExportBatchSizeEnvVarKey, out value)) + { + this.MaxExportBatchSize = value; + } + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxQueueSizeEnvVarKey, out value)) + { + this.MaxQueueSize = value; + } + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.ScheduledDelayEnvVarKey, out value)) + { + this.ScheduledDelayMilliseconds = value; + } + } + catch (SecurityException) + { + // TODO: + // The caller does not have the required permission to + // retrieve the value of an environment variable from the current process. + // JaegerExporterEventSource.Log.MissingPermissionsToReadEnvironmentVariable(ex); + } + } + /// /// Gets or sets the maximum queue size. The queue drops the data if the maximum size is reached. The default value is 2048. /// @@ -38,5 +84,25 @@ public class BatchExportProcessorOptions /// Gets or sets the maximum batch size of every export. It must be smaller or equal to MaxQueueLength. The default value is 512. /// public int MaxExportBatchSize { get; set; } = BatchExportProcessor.DefaultMaxExportBatchSize; + + private static bool TryLoadEnvVarInt(string envVarKey, out int field) + { + field = 0; + string exporterTimeoutEnvVar = Environment.GetEnvironmentVariable(envVarKey); + if (string.IsNullOrEmpty(exporterTimeoutEnvVar)) + { + return false; + } + + if (!int.TryParse(exporterTimeoutEnvVar, out var exporterTimeoutValue)) + { + // TODO: + // JaegerExporterEventSource.Log.FailedToParseEnvironmentVariable(OTelAgentPortEnvVarKey, agentPortEnvVar); + return false; + } + + field = exporterTimeoutValue; + return true; + } } } diff --git a/test/OpenTelemetry.Tests/Trace/BatchExportProcessorOptionsTest.cs b/test/OpenTelemetry.Tests/Trace/BatchExportProcessorOptionsTest.cs new file mode 100644 index 00000000000..d4a038783b6 --- /dev/null +++ b/test/OpenTelemetry.Tests/Trace/BatchExportProcessorOptionsTest.cs @@ -0,0 +1,103 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using Xunit; + +using Options = OpenTelemetry.BatchExportProcessorOptions; + +namespace OpenTelemetry.Trace.Tests +{ + public class BatchExportProcessorOptionsTest : IDisposable + { + public BatchExportProcessorOptionsTest() + { + this.ClearEnvVars(); + } + + public void Dispose() + { + this.ClearEnvVars(); + } + + [Fact] + public void BatchExportProcessorOptions_Defaults() + { + var options = new Options(); + + Assert.Equal(30000, options.ExporterTimeoutMilliseconds); + Assert.Equal(512, options.MaxExportBatchSize); + Assert.Equal(2048, options.MaxQueueSize); + Assert.Equal(5000, options.ScheduledDelayMilliseconds); + } + + [Fact] + public void BatchExportProcessorOptions_EnvironmentVariableOverride() + { + Environment.SetEnvironmentVariable(Options.ExporterTimeoutEnvVarKey, "1"); + Environment.SetEnvironmentVariable(Options.MaxExportBatchSizeEnvVarKey, "2"); + Environment.SetEnvironmentVariable(Options.MaxQueueSizeEnvVarKey, "3"); + Environment.SetEnvironmentVariable(Options.ScheduledDelayEnvVarKey, "4"); + + var options = new BatchExportProcessorOptions(); + + Assert.Equal(1, options.ExporterTimeoutMilliseconds); + Assert.Equal(2, options.MaxExportBatchSize); + Assert.Equal(3, options.MaxQueueSize); + Assert.Equal(4, options.ScheduledDelayMilliseconds); + } + + [Fact] + public void BatchExportProcessorOptions_InvalidPortEnvironmentVariableOverride() + { + Environment.SetEnvironmentVariable(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, "invalid"); + + var options = new Options(); + + Assert.Equal(30000, options.ExporterTimeoutMilliseconds); // use default + } + + [Fact] + public void BatchExportProcessorOptions_SetterOverridesEnvironmentVariable() + { + Environment.SetEnvironmentVariable(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, "123"); + + var options = new Options + { + ExporterTimeoutMilliseconds = 89000, + }; + + Assert.Equal(89000, options.ExporterTimeoutMilliseconds); + } + + [Fact] + public void BatchExportProcessorOptions_EnvironmentVariableNames() + { + Assert.Equal("OTEL_BSP_EXPORT_TIMEOUT", Options.ExporterTimeoutEnvVarKey); + Assert.Equal("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", Options.MaxExportBatchSizeEnvVarKey); + Assert.Equal("OTEL_BSP_MAX_QUEUE_SIZE", Options.MaxQueueSizeEnvVarKey); + Assert.Equal("OTEL_BSP_SCHEDULE_DELAY", Options.ScheduledDelayEnvVarKey); + } + + private void ClearEnvVars() + { + Environment.SetEnvironmentVariable(Options.ExporterTimeoutEnvVarKey, null); + Environment.SetEnvironmentVariable(Options.MaxExportBatchSizeEnvVarKey, null); + Environment.SetEnvironmentVariable(Options.MaxQueueSizeEnvVarKey, null); + Environment.SetEnvironmentVariable(Options.ScheduledDelayEnvVarKey, null); + } + } +} From 2ce1898fbaee1f6d1dc9b8f4db8ea02f1a00cbf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Mon, 2 Aug 2021 13:54:31 +0200 Subject: [PATCH 02/11] Handle errors --- .../BatchExportProcessorOptions.cs | 21 +++++++++--------- .../Internal/OpenTelemetrySdkEventSource.cs | 22 +++++++++++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/OpenTelemetry/BatchExportProcessorOptions.cs b/src/OpenTelemetry/BatchExportProcessorOptions.cs index 3bd32e24729..af87c9563a3 100644 --- a/src/OpenTelemetry/BatchExportProcessorOptions.cs +++ b/src/OpenTelemetry/BatchExportProcessorOptions.cs @@ -16,6 +16,7 @@ using System; using System.Security; +using OpenTelemetry.Internal; namespace OpenTelemetry { @@ -56,12 +57,11 @@ public BatchExportProcessorOptions() this.ScheduledDelayMilliseconds = value; } } - catch (SecurityException) + catch (SecurityException ex) { - // TODO: // The caller does not have the required permission to // retrieve the value of an environment variable from the current process. - // JaegerExporterEventSource.Log.MissingPermissionsToReadEnvironmentVariable(ex); + OpenTelemetrySdkEventSource.Log.MissingPermissionsToReadEnvironmentVariable(ex); } } @@ -85,23 +85,22 @@ public BatchExportProcessorOptions() /// public int MaxExportBatchSize { get; set; } = BatchExportProcessor.DefaultMaxExportBatchSize; - private static bool TryLoadEnvVarInt(string envVarKey, out int field) + private static bool TryLoadEnvVarInt(string envVarKey, out int result) { - field = 0; - string exporterTimeoutEnvVar = Environment.GetEnvironmentVariable(envVarKey); - if (string.IsNullOrEmpty(exporterTimeoutEnvVar)) + result = 0; + string value = Environment.GetEnvironmentVariable(envVarKey); + if (string.IsNullOrEmpty(value)) { return false; } - if (!int.TryParse(exporterTimeoutEnvVar, out var exporterTimeoutValue)) + if (!int.TryParse(value, out var parsedValue)) { - // TODO: - // JaegerExporterEventSource.Log.FailedToParseEnvironmentVariable(OTelAgentPortEnvVarKey, agentPortEnvVar); + OpenTelemetrySdkEventSource.Log.FailedToParseEnvironmentVariable(envVarKey, value); return false; } - field = exporterTimeoutValue; + result = parsedValue; return true; } } diff --git a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs index 11cbd2e696c..7e13a8f6041 100644 --- a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs +++ b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs @@ -21,6 +21,7 @@ #endif using System.Diagnostics; using System.Diagnostics.Tracing; +using System.Security; namespace OpenTelemetry.Internal { @@ -125,6 +126,15 @@ public void TracerProviderException(string evnt, Exception ex) } } + [NonEvent] + public void MissingPermissionsToReadEnvironmentVariable(SecurityException ex) + { + if (this.IsEnabled(EventLevel.Warning, EventKeywords.All)) + { + this.MissingPermissionsToReadEnvironmentVariable(ex.ToInvariantString()); + } + } + [Event(1, Message = "Span processor queue size reached maximum. Throttling spans.", Level = EventLevel.Warning)] public void SpanProcessorQueueIsExhausted() { @@ -287,6 +297,18 @@ public void TracerProviderException(string evnt, string ex) this.WriteEvent(28, evnt, ex); } + [Event(29, Message = "Failed to parse environment variable: '{0}', value: '{1}'.", Level = EventLevel.Warning)] + public void FailedToParseEnvironmentVariable(string name, string value) + { + this.WriteEvent(29, name, value); + } + + [Event(30, Message = "Missing permissions to read environment variable: '{0}'", Level = EventLevel.Warning)] + public void MissingPermissionsToReadEnvironmentVariable(string exception) + { + this.WriteEvent(30, exception); + } + #if DEBUG public class OpenTelemetryEventListener : EventListener { From 29e5f22de742816c16ddce0411a1d4d90d6056ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Mon, 2 Aug 2021 14:07:10 +0200 Subject: [PATCH 03/11] Update docs --- src/OpenTelemetry/CHANGELOG.md | 7 +++++++ src/OpenTelemetry/README.md | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 89595afcbd8..6ecaf00942f 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +* The `BatchExportProcessorOptions` defaults can be overridden using + `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, + `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` + envionmental variables as defined in the + [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.5.0/specification/sdk-environment-variables.md#batch-span-processor). + ([#2219](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2219)) + * Removes upper constraint for Microsoft.Extensions.Logging dependencies. ([#2179](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2179)) diff --git a/src/OpenTelemetry/README.md b/src/OpenTelemetry/README.md index 94744f5cadc..55b56754e8f 100644 --- a/src/OpenTelemetry/README.md +++ b/src/OpenTelemetry/README.md @@ -200,10 +200,24 @@ purposes, the SDK provides the following built-in processors: * [BatchExportProcessor<T>](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#batching-processor) : This is an exporting processor which batches the telemetry before sending to the configured exporter. + + The following environment variables can be used to override the default + values of the `BatchExportProcessorOptions`. + + + | Environment variable | `BatchExportProcessorOption` property | + | -------------------------------- | ---------------------------------------------- | + | `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | + | `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | + | `OTEL_BSP_MAX_QUEUE_SIZE` | `MaxQueueSize` | + | `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSizeEnvVarKey` | + + * [CompositeProcessor<T>](../../src/OpenTelemetry/CompositeProcessor.cs) : This is a processor which can be composed from multiple processors. This is typically used to construct multiple processing pipelines, each ending with its own exporter. + * [SimpleExportProcessor<T>](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#simple-processor) : This is an exporting processor which passes telemetry to the configured exporter without any batching. From e2932bedb4858dabbec697ac01ce2e51a2a11426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Mon, 2 Aug 2021 14:07:59 +0200 Subject: [PATCH 04/11] Fix typo --- src/OpenTelemetry/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry/README.md b/src/OpenTelemetry/README.md index 55b56754e8f..057feecf9d2 100644 --- a/src/OpenTelemetry/README.md +++ b/src/OpenTelemetry/README.md @@ -205,7 +205,7 @@ purposes, the SDK provides the following built-in processors: values of the `BatchExportProcessorOptions`. - | Environment variable | `BatchExportProcessorOption` property | + | Environment variable | `BatchExportProcessorOptions` property | | -------------------------------- | ---------------------------------------------- | | `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | | `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | From f679a640dcc9e6a197fb94a7aba46575a2aa63f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Fri, 6 Aug 2021 11:25:39 +0200 Subject: [PATCH 05/11] Refactor BatchExportProcessorOptions --- .../BatchExportProcessorOptions.cs | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/OpenTelemetry/BatchExportProcessorOptions.cs b/src/OpenTelemetry/BatchExportProcessorOptions.cs index af87c9563a3..6a618ee1209 100644 --- a/src/OpenTelemetry/BatchExportProcessorOptions.cs +++ b/src/OpenTelemetry/BatchExportProcessorOptions.cs @@ -33,35 +33,26 @@ public class BatchExportProcessorOptions public BatchExportProcessorOptions() { - try + int value; + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, out value)) { - int value; - - if (TryLoadEnvVarInt(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, out value)) - { - this.ExporterTimeoutMilliseconds = value; - } - - if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxExportBatchSizeEnvVarKey, out value)) - { - this.MaxExportBatchSize = value; - } - - if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxQueueSizeEnvVarKey, out value)) - { - this.MaxQueueSize = value; - } - - if (TryLoadEnvVarInt(BatchExportProcessorOptions.ScheduledDelayEnvVarKey, out value)) - { - this.ScheduledDelayMilliseconds = value; - } + this.ExporterTimeoutMilliseconds = value; } - catch (SecurityException ex) + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxExportBatchSizeEnvVarKey, out value)) { - // The caller does not have the required permission to - // retrieve the value of an environment variable from the current process. - OpenTelemetrySdkEventSource.Log.MissingPermissionsToReadEnvironmentVariable(ex); + this.MaxExportBatchSize = value; + } + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxQueueSizeEnvVarKey, out value)) + { + this.MaxQueueSize = value; + } + + if (TryLoadEnvVarInt(BatchExportProcessorOptions.ScheduledDelayEnvVarKey, out value)) + { + this.ScheduledDelayMilliseconds = value; } } @@ -88,7 +79,20 @@ public BatchExportProcessorOptions() private static bool TryLoadEnvVarInt(string envVarKey, out int result) { result = 0; - string value = Environment.GetEnvironmentVariable(envVarKey); + + string value; + try + { + value = Environment.GetEnvironmentVariable(envVarKey); + } + catch (SecurityException ex) + { + // The caller does not have the required permission to + // retrieve the value of an environment variable from the current process. + OpenTelemetrySdkEventSource.Log.MissingPermissionsToReadEnvironmentVariable(ex); + return false; + } + if (string.IsNullOrEmpty(value)) { return false; From b421b3dea6075fa14110a5020f20790d5e7bf0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Mon, 9 Aug 2021 10:32:09 +0200 Subject: [PATCH 06/11] Refactor --- src/OpenTelemetry/BatchExportProcessorOptions.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry/BatchExportProcessorOptions.cs b/src/OpenTelemetry/BatchExportProcessorOptions.cs index 6a618ee1209..75f93a3c6df 100644 --- a/src/OpenTelemetry/BatchExportProcessorOptions.cs +++ b/src/OpenTelemetry/BatchExportProcessorOptions.cs @@ -35,22 +35,22 @@ public BatchExportProcessorOptions() { int value; - if (TryLoadEnvVarInt(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, out value)) + if (TryLoadEnvVarInt(ExporterTimeoutEnvVarKey, out value)) { this.ExporterTimeoutMilliseconds = value; } - if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxExportBatchSizeEnvVarKey, out value)) + if (TryLoadEnvVarInt(MaxExportBatchSizeEnvVarKey, out value)) { this.MaxExportBatchSize = value; } - if (TryLoadEnvVarInt(BatchExportProcessorOptions.MaxQueueSizeEnvVarKey, out value)) + if (TryLoadEnvVarInt(MaxQueueSizeEnvVarKey, out value)) { this.MaxQueueSize = value; } - if (TryLoadEnvVarInt(BatchExportProcessorOptions.ScheduledDelayEnvVarKey, out value)) + if (TryLoadEnvVarInt(ScheduledDelayEnvVarKey, out value)) { this.ScheduledDelayMilliseconds = value; } From 092ddeabb984b5059cdeb0a757c34ad779a259d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 11 Aug 2021 10:41:36 +0200 Subject: [PATCH 07/11] Introduce BatchSpanExportProcessorOptions --- .../CHANGELOG.md | 8 ++ .../JaegerExporterOptions.cs | 3 +- .../CHANGELOG.md | 8 ++ .../OtlpExporterOptions.cs | 3 +- .../CHANGELOG.md | 8 ++ .../ZipkinExporterOptions.cs | 3 +- .../BatchExportProcessorOptions.cs | 69 -------------- src/OpenTelemetry/CHANGELOG.md | 4 +- src/OpenTelemetry/README.md | 4 +- .../Trace/BatchSpanExportProcessorOptions.cs | 91 +++++++++++++++++++ ...=> BatchSpanExportProcessorOptionsTest.cs} | 44 +++++---- 11 files changed, 146 insertions(+), 99 deletions(-) create mode 100644 src/OpenTelemetry/Trace/BatchSpanExportProcessorOptions.cs rename test/OpenTelemetry.Tests/Trace/{BatchExportProcessorOptionsTest.cs => BatchSpanExportProcessorOptionsTest.cs} (51%) diff --git a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md index 740395daa8c..d859a7da58e 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +* `JaegerExporterOptions.BatchExportProcessorOptions` is initalized with + `BatchSpanExportProcessorOptions` which supports field value overriding + using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, + `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` + envionmental variables as defined in the + [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.5.0/specification/sdk-environment-variables.md#batch-span-processor). + ([#2219](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2219)) + ## 1.2.0-alpha1 Released 2021-Jul-23 diff --git a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs index ed87beb5926..054c5f28555 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs @@ -18,6 +18,7 @@ using System.Diagnostics; using System.Security; using OpenTelemetry.Exporter.Jaeger.Implementation; +using OpenTelemetry.Trace; namespace OpenTelemetry.Exporter { @@ -82,6 +83,6 @@ public JaegerExporterOptions() /// /// Gets or sets the BatchExportProcessor options. Ignored unless ExportProcessorType is BatchExporter. /// - public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchExportProcessorOptions(); + public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchSpanExportProcessorOptions(); } } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index c464714f603..aa4a1b7251e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +* `OtlpExporterOptions.BatchExportProcessorOptions` is initalized with + `BatchSpanExportProcessorOptions` which supports field value overriding + using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, + `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` + envionmental variables as defined in the + [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.5.0/specification/sdk-environment-variables.md#batch-span-processor). + ([#2219](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2219)) + * The `OtlpExporterOptions` defaults can be overridden using `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_EXPORTER_OTLP_HEADERS` and `OTEL_EXPORTER_OTLP_TIMEOUT` envionmental variables as defined in the diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs index f112e76a773..42eb21881bf 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs @@ -18,6 +18,7 @@ using System.Diagnostics; using System.Security; using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation; +using OpenTelemetry.Trace; namespace OpenTelemetry.Exporter { @@ -104,7 +105,7 @@ public OtlpExporterOptions() /// /// Gets or sets the BatchExportProcessor options. Ignored unless ExportProcessorType is Batch. /// - public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchExportProcessorOptions(); + public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchSpanExportProcessorOptions(); /// /// Gets or sets the metric export interval in milliseconds. The default value is 1000 milliseconds. diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index 1e1dac0d3ff..1f12beefa5a 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +* `ZipkinExporterOptions.BatchExportProcessorOptions` is initalized with + `BatchSpanExportProcessorOptions` which supports field value overriding + using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, + `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` + envionmental variables as defined in the + [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.5.0/specification/sdk-environment-variables.md#batch-span-processor). + ([#2219](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2219)) + * Enabling endpoint configuration in ZipkinExporterOptions via `OTEL_EXPORTER_ZIPKIN_ENDPOINT` environment variable. ([#1453](https://github.com/open-telemetry/opentelemetry-dotnet/issues/1453)) diff --git a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs index 21df9181fd7..76b23a92ad9 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs @@ -17,6 +17,7 @@ using System; using System.Diagnostics; using OpenTelemetry.Exporter.Zipkin.Implementation; +using OpenTelemetry.Trace; namespace OpenTelemetry.Exporter { @@ -70,6 +71,6 @@ public ZipkinExporterOptions() /// /// Gets or sets the BatchExportProcessor options. Ignored unless ExportProcessorType is BatchExporter. /// - public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchExportProcessorOptions(); + public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchSpanExportProcessorOptions(); } } diff --git a/src/OpenTelemetry/BatchExportProcessorOptions.cs b/src/OpenTelemetry/BatchExportProcessorOptions.cs index 75f93a3c6df..90abda8abbb 100644 --- a/src/OpenTelemetry/BatchExportProcessorOptions.cs +++ b/src/OpenTelemetry/BatchExportProcessorOptions.cs @@ -14,48 +14,11 @@ // limitations under the License. // -using System; -using System.Security; -using OpenTelemetry.Internal; - namespace OpenTelemetry { public class BatchExportProcessorOptions where T : class { - internal const string MaxQueueSizeEnvVarKey = "OTEL_BSP_MAX_QUEUE_SIZE"; - - internal const string MaxExportBatchSizeEnvVarKey = "OTEL_BSP_MAX_EXPORT_BATCH_SIZE"; - - internal const string ExporterTimeoutEnvVarKey = "OTEL_BSP_EXPORT_TIMEOUT"; - - internal const string ScheduledDelayEnvVarKey = "OTEL_BSP_SCHEDULE_DELAY"; - - public BatchExportProcessorOptions() - { - int value; - - if (TryLoadEnvVarInt(ExporterTimeoutEnvVarKey, out value)) - { - this.ExporterTimeoutMilliseconds = value; - } - - if (TryLoadEnvVarInt(MaxExportBatchSizeEnvVarKey, out value)) - { - this.MaxExportBatchSize = value; - } - - if (TryLoadEnvVarInt(MaxQueueSizeEnvVarKey, out value)) - { - this.MaxQueueSize = value; - } - - if (TryLoadEnvVarInt(ScheduledDelayEnvVarKey, out value)) - { - this.ScheduledDelayMilliseconds = value; - } - } - /// /// Gets or sets the maximum queue size. The queue drops the data if the maximum size is reached. The default value is 2048. /// @@ -75,37 +38,5 @@ public BatchExportProcessorOptions() /// Gets or sets the maximum batch size of every export. It must be smaller or equal to MaxQueueLength. The default value is 512. /// public int MaxExportBatchSize { get; set; } = BatchExportProcessor.DefaultMaxExportBatchSize; - - private static bool TryLoadEnvVarInt(string envVarKey, out int result) - { - result = 0; - - string value; - try - { - value = Environment.GetEnvironmentVariable(envVarKey); - } - catch (SecurityException ex) - { - // The caller does not have the required permission to - // retrieve the value of an environment variable from the current process. - OpenTelemetrySdkEventSource.Log.MissingPermissionsToReadEnvironmentVariable(ex); - return false; - } - - if (string.IsNullOrEmpty(value)) - { - return false; - } - - if (!int.TryParse(value, out var parsedValue)) - { - OpenTelemetrySdkEventSource.Log.FailedToParseEnvironmentVariable(envVarKey, value); - return false; - } - - result = parsedValue; - return true; - } } } diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 2a3f5078d08..e792960eb2b 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* The `BatchExportProcessorOptions` defaults can be overridden using - `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, +* Add `BatchSpanExportProcessorOptions` which supports field value overriding + using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` envionmental variables as defined in the [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.5.0/specification/sdk-environment-variables.md#batch-span-processor). diff --git a/src/OpenTelemetry/README.md b/src/OpenTelemetry/README.md index 4dbd9085c6f..1d667199fa1 100644 --- a/src/OpenTelemetry/README.md +++ b/src/OpenTelemetry/README.md @@ -204,10 +204,10 @@ purposes, the SDK provides the following built-in processors: the configured exporter. The following environment variables can be used to override the default - values of the `BatchExportProcessorOptions`. + values of the `BatchSpanExportProcessorOptions`. - | Environment variable | `BatchExportProcessorOptions` property | + | Environment variable | `BatchSpanExportProcessorOptions` property | | -------------------------------- | ---------------------------------------------- | | `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | | `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | diff --git a/src/OpenTelemetry/Trace/BatchSpanExportProcessorOptions.cs b/src/OpenTelemetry/Trace/BatchSpanExportProcessorOptions.cs new file mode 100644 index 00000000000..1c155eda12c --- /dev/null +++ b/src/OpenTelemetry/Trace/BatchSpanExportProcessorOptions.cs @@ -0,0 +1,91 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Diagnostics; +using System.Security; +using OpenTelemetry.Internal; + +namespace OpenTelemetry.Trace +{ + public class BatchSpanExportProcessorOptions : BatchExportProcessorOptions + { + internal const string MaxQueueSizeEnvVarKey = "OTEL_BSP_MAX_QUEUE_SIZE"; + + internal const string MaxExportBatchSizeEnvVarKey = "OTEL_BSP_MAX_EXPORT_BATCH_SIZE"; + + internal const string ExporterTimeoutEnvVarKey = "OTEL_BSP_EXPORT_TIMEOUT"; + + internal const string ScheduledDelayEnvVarKey = "OTEL_BSP_SCHEDULE_DELAY"; + + public BatchSpanExportProcessorOptions() + { + int value; + + if (TryLoadEnvVarInt(ExporterTimeoutEnvVarKey, out value)) + { + this.ExporterTimeoutMilliseconds = value; + } + + if (TryLoadEnvVarInt(MaxExportBatchSizeEnvVarKey, out value)) + { + this.MaxExportBatchSize = value; + } + + if (TryLoadEnvVarInt(MaxQueueSizeEnvVarKey, out value)) + { + this.MaxQueueSize = value; + } + + if (TryLoadEnvVarInt(ScheduledDelayEnvVarKey, out value)) + { + this.ScheduledDelayMilliseconds = value; + } + } + + private static bool TryLoadEnvVarInt(string envVarKey, out int result) + { + result = 0; + + string value; + try + { + value = Environment.GetEnvironmentVariable(envVarKey); + } + catch (SecurityException ex) + { + // The caller does not have the required permission to + // retrieve the value of an environment variable from the current process. + OpenTelemetrySdkEventSource.Log.MissingPermissionsToReadEnvironmentVariable(ex); + return false; + } + + if (string.IsNullOrEmpty(value)) + { + return false; + } + + if (!int.TryParse(value, out var parsedValue)) + { + OpenTelemetrySdkEventSource.Log.FailedToParseEnvironmentVariable(envVarKey, value); + return false; + } + + result = parsedValue; + return true; + } + } +} diff --git a/test/OpenTelemetry.Tests/Trace/BatchExportProcessorOptionsTest.cs b/test/OpenTelemetry.Tests/Trace/BatchSpanExportProcessorOptionsTest.cs similarity index 51% rename from test/OpenTelemetry.Tests/Trace/BatchExportProcessorOptionsTest.cs rename to test/OpenTelemetry.Tests/Trace/BatchSpanExportProcessorOptionsTest.cs index d4a038783b6..073b9ca3c69 100644 --- a/test/OpenTelemetry.Tests/Trace/BatchExportProcessorOptionsTest.cs +++ b/test/OpenTelemetry.Tests/Trace/BatchSpanExportProcessorOptionsTest.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,13 +17,11 @@ using System; using Xunit; -using Options = OpenTelemetry.BatchExportProcessorOptions; - namespace OpenTelemetry.Trace.Tests { - public class BatchExportProcessorOptionsTest : IDisposable + public class BatchSpanExportProcessorOptionsTest : IDisposable { - public BatchExportProcessorOptionsTest() + public BatchSpanExportProcessorOptionsTest() { this.ClearEnvVars(); } @@ -36,7 +34,7 @@ public void Dispose() [Fact] public void BatchExportProcessorOptions_Defaults() { - var options = new Options(); + var options = new BatchSpanExportProcessorOptions(); Assert.Equal(30000, options.ExporterTimeoutMilliseconds); Assert.Equal(512, options.MaxExportBatchSize); @@ -47,12 +45,12 @@ public void BatchExportProcessorOptions_Defaults() [Fact] public void BatchExportProcessorOptions_EnvironmentVariableOverride() { - Environment.SetEnvironmentVariable(Options.ExporterTimeoutEnvVarKey, "1"); - Environment.SetEnvironmentVariable(Options.MaxExportBatchSizeEnvVarKey, "2"); - Environment.SetEnvironmentVariable(Options.MaxQueueSizeEnvVarKey, "3"); - Environment.SetEnvironmentVariable(Options.ScheduledDelayEnvVarKey, "4"); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, "1"); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxExportBatchSizeEnvVarKey, "2"); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxQueueSizeEnvVarKey, "3"); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ScheduledDelayEnvVarKey, "4"); - var options = new BatchExportProcessorOptions(); + var options = new BatchSpanExportProcessorOptions(); Assert.Equal(1, options.ExporterTimeoutMilliseconds); Assert.Equal(2, options.MaxExportBatchSize); @@ -63,9 +61,9 @@ public void BatchExportProcessorOptions_EnvironmentVariableOverride() [Fact] public void BatchExportProcessorOptions_InvalidPortEnvironmentVariableOverride() { - Environment.SetEnvironmentVariable(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, "invalid"); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, "invalid"); - var options = new Options(); + var options = new BatchSpanExportProcessorOptions(); Assert.Equal(30000, options.ExporterTimeoutMilliseconds); // use default } @@ -73,9 +71,9 @@ public void BatchExportProcessorOptions_InvalidPortEnvironmentVariableOverride() [Fact] public void BatchExportProcessorOptions_SetterOverridesEnvironmentVariable() { - Environment.SetEnvironmentVariable(BatchExportProcessorOptions.ExporterTimeoutEnvVarKey, "123"); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, "123"); - var options = new Options + var options = new BatchSpanExportProcessorOptions { ExporterTimeoutMilliseconds = 89000, }; @@ -86,18 +84,18 @@ public void BatchExportProcessorOptions_SetterOverridesEnvironmentVariable() [Fact] public void BatchExportProcessorOptions_EnvironmentVariableNames() { - Assert.Equal("OTEL_BSP_EXPORT_TIMEOUT", Options.ExporterTimeoutEnvVarKey); - Assert.Equal("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", Options.MaxExportBatchSizeEnvVarKey); - Assert.Equal("OTEL_BSP_MAX_QUEUE_SIZE", Options.MaxQueueSizeEnvVarKey); - Assert.Equal("OTEL_BSP_SCHEDULE_DELAY", Options.ScheduledDelayEnvVarKey); + Assert.Equal("OTEL_BSP_EXPORT_TIMEOUT", BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey); + Assert.Equal("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", BatchSpanExportProcessorOptions.MaxExportBatchSizeEnvVarKey); + Assert.Equal("OTEL_BSP_MAX_QUEUE_SIZE", BatchSpanExportProcessorOptions.MaxQueueSizeEnvVarKey); + Assert.Equal("OTEL_BSP_SCHEDULE_DELAY", BatchSpanExportProcessorOptions.ScheduledDelayEnvVarKey); } private void ClearEnvVars() { - Environment.SetEnvironmentVariable(Options.ExporterTimeoutEnvVarKey, null); - Environment.SetEnvironmentVariable(Options.MaxExportBatchSizeEnvVarKey, null); - Environment.SetEnvironmentVariable(Options.MaxQueueSizeEnvVarKey, null); - Environment.SetEnvironmentVariable(Options.ScheduledDelayEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxExportBatchSizeEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxQueueSizeEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ScheduledDelayEnvVarKey, null); } } } From 8315017b9c8beb76afe9ac0d7f77f0f65c511d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Wed, 11 Aug 2021 11:02:21 +0200 Subject: [PATCH 08/11] Fix typo --- src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md | 2 +- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md index d859a7da58e..353d311e2e9 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -* `JaegerExporterOptions.BatchExportProcessorOptions` is initalized with +* `JaegerExporterOptions.BatchExportProcessorOptions` is initialized with `BatchSpanExportProcessorOptions` which supports field value overriding using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index aa4a1b7251e..676b7d277ac 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -* `OtlpExporterOptions.BatchExportProcessorOptions` is initalized with +* `OtlpExporterOptions.BatchExportProcessorOptions` is initialized with `BatchSpanExportProcessorOptions` which supports field value overriding using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index 1f12beefa5a..800669dd21a 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -* `ZipkinExporterOptions.BatchExportProcessorOptions` is initalized with +* `ZipkinExporterOptions.BatchExportProcessorOptions` is initialized with `BatchSpanExportProcessorOptions` which supports field value overriding using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` From 7dfb93547d0267d229d941797cdd3ef438a32ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Thu, 12 Aug 2021 08:22:37 +0200 Subject: [PATCH 09/11] Rename to BatchExportActivityProcessorOptions --- ...=> BatchExportActivityProcessorOptions.cs} | 6 +-- ...atchExportActivityProcessorOptionsTest.cs} | 42 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) rename src/OpenTelemetry/Trace/{BatchSpanExportProcessorOptions.cs => BatchExportActivityProcessorOptions.cs} (92%) rename test/OpenTelemetry.Tests/Trace/{BatchSpanExportProcessorOptionsTest.cs => BatchExportActivityProcessorOptionsTest.cs} (52%) diff --git a/src/OpenTelemetry/Trace/BatchSpanExportProcessorOptions.cs b/src/OpenTelemetry/Trace/BatchExportActivityProcessorOptions.cs similarity index 92% rename from src/OpenTelemetry/Trace/BatchSpanExportProcessorOptions.cs rename to src/OpenTelemetry/Trace/BatchExportActivityProcessorOptions.cs index 1c155eda12c..a150cc74d8e 100644 --- a/src/OpenTelemetry/Trace/BatchSpanExportProcessorOptions.cs +++ b/src/OpenTelemetry/Trace/BatchExportActivityProcessorOptions.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,7 @@ namespace OpenTelemetry.Trace { - public class BatchSpanExportProcessorOptions : BatchExportProcessorOptions + public class BatchExportActivityProcessorOptions : BatchExportProcessorOptions { internal const string MaxQueueSizeEnvVarKey = "OTEL_BSP_MAX_QUEUE_SIZE"; @@ -31,7 +31,7 @@ public class BatchSpanExportProcessorOptions : BatchExportProcessorOptions +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,9 +19,9 @@ namespace OpenTelemetry.Trace.Tests { - public class BatchSpanExportProcessorOptionsTest : IDisposable + public class BatchExportActivityProcessorOptionsTest : IDisposable { - public BatchSpanExportProcessorOptionsTest() + public BatchExportActivityProcessorOptionsTest() { this.ClearEnvVars(); } @@ -34,7 +34,7 @@ public void Dispose() [Fact] public void BatchExportProcessorOptions_Defaults() { - var options = new BatchSpanExportProcessorOptions(); + var options = new BatchExportActivityProcessorOptions(); Assert.Equal(30000, options.ExporterTimeoutMilliseconds); Assert.Equal(512, options.MaxExportBatchSize); @@ -45,12 +45,12 @@ public void BatchExportProcessorOptions_Defaults() [Fact] public void BatchExportProcessorOptions_EnvironmentVariableOverride() { - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, "1"); - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxExportBatchSizeEnvVarKey, "2"); - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxQueueSizeEnvVarKey, "3"); - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ScheduledDelayEnvVarKey, "4"); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.ExporterTimeoutEnvVarKey, "1"); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.MaxExportBatchSizeEnvVarKey, "2"); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.MaxQueueSizeEnvVarKey, "3"); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.ScheduledDelayEnvVarKey, "4"); - var options = new BatchSpanExportProcessorOptions(); + var options = new BatchExportActivityProcessorOptions(); Assert.Equal(1, options.ExporterTimeoutMilliseconds); Assert.Equal(2, options.MaxExportBatchSize); @@ -61,9 +61,9 @@ public void BatchExportProcessorOptions_EnvironmentVariableOverride() [Fact] public void BatchExportProcessorOptions_InvalidPortEnvironmentVariableOverride() { - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, "invalid"); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.ExporterTimeoutEnvVarKey, "invalid"); - var options = new BatchSpanExportProcessorOptions(); + var options = new BatchExportActivityProcessorOptions(); Assert.Equal(30000, options.ExporterTimeoutMilliseconds); // use default } @@ -71,9 +71,9 @@ public void BatchExportProcessorOptions_InvalidPortEnvironmentVariableOverride() [Fact] public void BatchExportProcessorOptions_SetterOverridesEnvironmentVariable() { - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, "123"); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.ExporterTimeoutEnvVarKey, "123"); - var options = new BatchSpanExportProcessorOptions + var options = new BatchExportActivityProcessorOptions { ExporterTimeoutMilliseconds = 89000, }; @@ -84,18 +84,18 @@ public void BatchExportProcessorOptions_SetterOverridesEnvironmentVariable() [Fact] public void BatchExportProcessorOptions_EnvironmentVariableNames() { - Assert.Equal("OTEL_BSP_EXPORT_TIMEOUT", BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey); - Assert.Equal("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", BatchSpanExportProcessorOptions.MaxExportBatchSizeEnvVarKey); - Assert.Equal("OTEL_BSP_MAX_QUEUE_SIZE", BatchSpanExportProcessorOptions.MaxQueueSizeEnvVarKey); - Assert.Equal("OTEL_BSP_SCHEDULE_DELAY", BatchSpanExportProcessorOptions.ScheduledDelayEnvVarKey); + Assert.Equal("OTEL_BSP_EXPORT_TIMEOUT", BatchExportActivityProcessorOptions.ExporterTimeoutEnvVarKey); + Assert.Equal("OTEL_BSP_MAX_EXPORT_BATCH_SIZE", BatchExportActivityProcessorOptions.MaxExportBatchSizeEnvVarKey); + Assert.Equal("OTEL_BSP_MAX_QUEUE_SIZE", BatchExportActivityProcessorOptions.MaxQueueSizeEnvVarKey); + Assert.Equal("OTEL_BSP_SCHEDULE_DELAY", BatchExportActivityProcessorOptions.ScheduledDelayEnvVarKey); } private void ClearEnvVars() { - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ExporterTimeoutEnvVarKey, null); - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxExportBatchSizeEnvVarKey, null); - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.MaxQueueSizeEnvVarKey, null); - Environment.SetEnvironmentVariable(BatchSpanExportProcessorOptions.ScheduledDelayEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.ExporterTimeoutEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.MaxExportBatchSizeEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.MaxQueueSizeEnvVarKey, null); + Environment.SetEnvironmentVariable(BatchExportActivityProcessorOptions.ScheduledDelayEnvVarKey, null); } } } From 917fd8da484bab345b0eba3c9f30c7100acdd07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Thu, 12 Aug 2021 08:37:29 +0200 Subject: [PATCH 10/11] Rename in usages --- src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md | 2 +- src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs | 2 +- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- .../OtlpExporterOptions.cs | 2 +- src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md | 2 +- src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs | 2 +- src/OpenTelemetry/CHANGELOG.md | 2 +- src/OpenTelemetry/README.md | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md index 353d311e2e9..a95a5ef19f8 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased * `JaegerExporterOptions.BatchExportProcessorOptions` is initialized with - `BatchSpanExportProcessorOptions` which supports field value overriding + `BatchExportActivityProcessorOptions` which supports field value overriding using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` envionmental variables as defined in the diff --git a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs index 054c5f28555..b578beeb41c 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterOptions.cs @@ -83,6 +83,6 @@ public JaegerExporterOptions() /// /// Gets or sets the BatchExportProcessor options. Ignored unless ExportProcessorType is BatchExporter. /// - public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchSpanExportProcessorOptions(); + public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchExportActivityProcessorOptions(); } } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 676b7d277ac..a11e8ccae54 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased * `OtlpExporterOptions.BatchExportProcessorOptions` is initialized with - `BatchSpanExportProcessorOptions` which supports field value overriding + `BatchExportActivityProcessorOptions` which supports field value overriding using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` envionmental variables as defined in the diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs index 42eb21881bf..47277430c5a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs @@ -105,7 +105,7 @@ public OtlpExporterOptions() /// /// Gets or sets the BatchExportProcessor options. Ignored unless ExportProcessorType is Batch. /// - public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchSpanExportProcessorOptions(); + public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchExportActivityProcessorOptions(); /// /// Gets or sets the metric export interval in milliseconds. The default value is 1000 milliseconds. diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index 800669dd21a..7f5632cde4a 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased * `ZipkinExporterOptions.BatchExportProcessorOptions` is initialized with - `BatchSpanExportProcessorOptions` which supports field value overriding + `BatchExportActivityProcessorOptions` which supports field value overriding using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` envionmental variables as defined in the diff --git a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs index 76b23a92ad9..a2af6f2a776 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs @@ -71,6 +71,6 @@ public ZipkinExporterOptions() /// /// Gets or sets the BatchExportProcessor options. Ignored unless ExportProcessorType is BatchExporter. /// - public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchSpanExportProcessorOptions(); + public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchExportActivityProcessorOptions(); } } diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index e792960eb2b..8fcca5e83e7 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -* Add `BatchSpanExportProcessorOptions` which supports field value overriding +* Add `BatchExportActivityProcessorOptions` which supports field value overriding using `OTEL_BSP_SCHEDULE_DELAY`, `OTEL_BSP_EXPORT_TIMEOUT`, `OTEL_BSP_MAX_QUEUE_SIZE`, `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` envionmental variables as defined in the diff --git a/src/OpenTelemetry/README.md b/src/OpenTelemetry/README.md index 1d667199fa1..65e2be072b0 100644 --- a/src/OpenTelemetry/README.md +++ b/src/OpenTelemetry/README.md @@ -204,10 +204,10 @@ purposes, the SDK provides the following built-in processors: the configured exporter. The following environment variables can be used to override the default - values of the `BatchSpanExportProcessorOptions`. + values of the `BatchExportActivityProcessorOptions`. - | Environment variable | `BatchSpanExportProcessorOptions` property | + | Environment variable | `BatchExportActivityProcessorOptions` property | | -------------------------------- | ---------------------------------------------- | | `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | | `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | From 018b6a49fb0db8d9f91a870a25af0e4e6fa584ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Paj=C4=85k?= Date: Thu, 12 Aug 2021 08:52:05 +0200 Subject: [PATCH 11/11] Update public API --- src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt | 2 ++ .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt index e69de29bb2d..45e87d487f6 100644 --- a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +OpenTelemetry.Trace.BatchExportActivityProcessorOptions +OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions() -> void \ No newline at end of file diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index e69de29bb2d..45e87d487f6 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +OpenTelemetry.Trace.BatchExportActivityProcessorOptions +OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions() -> void \ No newline at end of file