From 2edca30e7c5a86f55b193ae265a9379679912216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 7 Feb 2022 11:52:13 +0100 Subject: [PATCH 01/10] default endpoint for otel exporter - http/protobuf fixes #2857 --- .../CHANGELOG.md | 3 + .../OtlpExporterOptions.cs | 84 ++++++++++++++++--- .../OtlpExporterOptionsExtensions.cs | 4 +- .../OtlpMetricExporterExtensions.cs | 4 +- .../OtlpTraceExporterHelperExtensions.cs | 4 +- .../OtlpExporterOptionsExtensionsTests.cs | 11 ++- .../OtlpExporterOptionsTests.cs | 33 ++++++++ 7 files changed, 117 insertions(+), 26 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 41b14d77289..f41de14d750 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -6,6 +6,9 @@ ## Unreleased +* Fixed the default endpoint for OTLP exporter over HTTP/Protobuf. + ([#2686](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2868)) + ## 1.2.0-rc2 Released 2022-Feb-02 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs index a5725b9ba6c..05285782692 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs @@ -44,16 +44,19 @@ public class OtlpExporterOptions internal readonly Func DefaultHttpClientFactory; + private const string DefaultGrpcEndpoint = "http://localhost:4317"; + private const string DefaultHttpProtobufEndpoint = "http://localhost:4318"; + private const OtlpExportProtocol DefaultOtlpExportProtocol = OtlpExportProtocol.Grpc; + + private OtlpExportProtocol protocol; + private Uri endpoint; + private bool isCustomEndpointSet; + /// /// Initializes a new instance of the class. /// public OtlpExporterOptions() { - if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri endpoint)) - { - this.Endpoint = endpoint; - } - if (EnvironmentVariableHelper.LoadString(HeadersEnvVarName, out string headersEnvVar)) { this.Headers = headersEnvVar; @@ -66,20 +69,29 @@ public OtlpExporterOptions() if (EnvironmentVariableHelper.LoadString(ProtocolEnvVarName, out string protocolEnvVar)) { - var protocol = protocolEnvVar.ToOtlpExportProtocol(); - if (protocol.HasValue) + var parsedProtocol = protocolEnvVar.ToOtlpExportProtocol(); + if (parsedProtocol.HasValue) { - this.Protocol = protocol.Value; + this.Protocol = parsedProtocol.Value; } else { throw new FormatException($"{ProtocolEnvVarName} environment variable has an invalid value: '${protocolEnvVar}'"); } } + else + { + this.Protocol = DefaultOtlpExportProtocol; + } + + if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri parsedEndpoint)) + { + this.SetEndpoint(parsedEndpoint, custom: true); + } this.HttpClientFactory = this.DefaultHttpClientFactory = () => { - return new HttpClient() + return new HttpClient { Timeout = TimeSpan.FromMilliseconds(this.TimeoutMilliseconds), }; @@ -89,9 +101,19 @@ public OtlpExporterOptions() /// /// Gets or sets the target to which the exporter is going to send telemetry. /// Must be a valid Uri with scheme (http or https) and host, and - /// may contain a port and path. The default value is http://localhost:4317. + /// may contain a port and path. The default value is + /// * http://localhost:4317 for + /// * http://localhost:4318 for . /// - public Uri Endpoint { get; set; } = new Uri("http://localhost:4317"); + public Uri Endpoint + { + get => this.endpoint; + set + { + this.SetEndpoint(value, custom: true); + this.ProgrammaticallyModifiedEndpoint = true; + } + } /// /// Gets or sets optional headers for the connection. Refer to the @@ -107,7 +129,24 @@ public OtlpExporterOptions() /// /// Gets or sets the the OTLP transport protocol. Supported values: Grpc and HttpProtobuf. /// - public OtlpExportProtocol Protocol { get; set; } = OtlpExportProtocol.Grpc; + public OtlpExportProtocol Protocol + { + get => this.protocol; + set + { + this.protocol = value; + + switch (value) + { + case OtlpExportProtocol.Grpc: + this.SetEndpoint(new Uri(DefaultGrpcEndpoint)); + break; + case OtlpExportProtocol.HttpProtobuf: + this.SetEndpoint(new Uri(DefaultHttpProtobufEndpoint)); + break; + } + } + } /// /// Gets or sets the export processor type to be used with the OpenTelemetry Protocol Exporter. The default value is . @@ -167,5 +206,26 @@ public OtlpExporterOptions() /// /// public Func HttpClientFactory { get; set; } + + /// + /// Gets a value indicating whether was programmatically modified. + /// + internal bool ProgrammaticallyModifiedEndpoint { get; private set; } + + private void SetEndpoint(Uri value, bool custom = false) + { + if (custom) + { + this.isCustomEndpointSet = true; + this.endpoint = value; + } + else + { + if (!this.isCustomEndpointSet) + { + this.endpoint = value; + } + } + } } } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs index 3760a1830de..407e9b30b40 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs @@ -155,12 +155,12 @@ public static void TryEnableIHttpClientFactoryIntegration(this OtlpExporterOptio } } - internal static void AppendExportPath(this OtlpExporterOptions options, Uri initialEndpoint, string exportRelativePath) + internal static void AppendExportPath(this OtlpExporterOptions options, string exportRelativePath) { // The exportRelativePath is only appended when the options.Endpoint property wasn't set by the user, // the protocol is HttpProtobuf and the OTEL_EXPORTER_OTLP_ENDPOINT environment variable // is present. If the user provides a custom value for options.Endpoint that value is taken as is. - if (ReferenceEquals(initialEndpoint, options.Endpoint)) + if (!options.ProgrammaticallyModifiedEndpoint) { if (options.Protocol == OtlpExportProtocol.HttpProtobuf) { diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index fc0956d0ad5..12f2333b8ad 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -52,13 +52,11 @@ private static MeterProviderBuilder AddOtlpExporter( Action configure, IServiceProvider serviceProvider) { - var initialEndpoint = options.Endpoint; - configure?.Invoke(options); options.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter"); - options.AppendExportPath(initialEndpoint, OtlpExporterOptions.MetricsExportPath); + options.AppendExportPath(OtlpExporterOptions.MetricsExportPath); var metricExporter = new OtlpMetricExporter(options); diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs index d9e66316919..7c4cc479f36 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpTraceExporterHelperExtensions.cs @@ -52,13 +52,11 @@ private static TracerProviderBuilder AddOtlpExporter( Action configure, IServiceProvider serviceProvider) { - var originalEndpoint = exporterOptions.Endpoint; - configure?.Invoke(exporterOptions); exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpTraceExporter"); - exporterOptions.AppendExportPath(originalEndpoint, OtlpExporterOptions.TracesExportPath); + exporterOptions.AppendExportPath(OtlpExporterOptions.TracesExportPath); var otlpExporter = new OtlpTraceExporter(exporterOptions); diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs index 970f96daaea..3a9b32b179e 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs @@ -173,9 +173,9 @@ public void AppendExportPath_EndpointNotSet_EnvironmentVariableNotDefined_NotApp var options = new OtlpExporterOptions { Protocol = OtlpExportProtocol.HttpProtobuf }; - options.AppendExportPath(options.Endpoint, "test/path"); + options.AppendExportPath("test/path"); - Assert.Equal("http://localhost:4317/", options.Endpoint.AbsoluteUri); + Assert.Equal("http://localhost:4318/", options.Endpoint.AbsoluteUri); } [Fact] @@ -185,7 +185,7 @@ public void AppendExportPath_EndpointNotSet_EnvironmentVariableDefined_Appended( var options = new OtlpExporterOptions { Protocol = OtlpExportProtocol.HttpProtobuf }; - options.AppendExportPath(options.Endpoint, "test/path"); + options.AppendExportPath("test/path"); Assert.Equal("http://test:8888/test/path", options.Endpoint.AbsoluteUri); @@ -198,10 +198,9 @@ public void AppendExportPath_EndpointSetEqualToEnvironmentVariable_EnvironmentVa Environment.SetEnvironmentVariable(OtlpExporterOptions.EndpointEnvVarName, "http://test:8888"); var options = new OtlpExporterOptions { Protocol = OtlpExportProtocol.HttpProtobuf }; - var originalEndpoint = options.Endpoint; options.Endpoint = new Uri("http://test:8888"); - options.AppendExportPath(originalEndpoint, "test/path"); + options.AppendExportPath("test/path"); Assert.Equal("http://test:8888/", options.Endpoint.AbsoluteUri); @@ -219,7 +218,7 @@ public void AppendExportPath_EndpointSet_EnvironmentVariableNotDefined_NotAppend var originalEndpoint = options.Endpoint; options.Endpoint = new Uri(endpoint); - options.AppendExportPath(originalEndpoint, "test/path"); + options.AppendExportPath("test/path"); Assert.Equal(endpoint, options.Endpoint.AbsoluteUri); } diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs index 2b7a612fa06..e4f69e34a59 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs @@ -42,6 +42,19 @@ public void OtlpExporterOptions_Defaults() Assert.Equal(OtlpExportProtocol.Grpc, options.Protocol); } + [Fact] + public void OtlpExporterOptions_DefaultsForHttpProtobuf() + { + var options = new OtlpExporterOptions + { + Protocol = OtlpExportProtocol.HttpProtobuf, + }; + Assert.Equal(new Uri("http://localhost:4318"), options.Endpoint); + Assert.Null(options.Headers); + Assert.Equal(10000, options.TimeoutMilliseconds); + Assert.Equal(OtlpExportProtocol.HttpProtobuf, options.Protocol); + } + [Fact] public void OtlpExporterOptions_EnvironmentVariableOverride() { @@ -104,6 +117,26 @@ public void OtlpExporterOptions_SetterOverridesEnvironmentVariable() Assert.Equal(OtlpExportProtocol.HttpProtobuf, options.Protocol); } + [Fact] + public void OtlpExporterOptions_ProtocolSetterDoesNotOverrideCustomEndpointFromEnvVariables() + { + Environment.SetEnvironmentVariable(OtlpExporterOptions.EndpointEnvVarName, "http://test:8888"); + + var options = new OtlpExporterOptions {Protocol = OtlpExportProtocol.Grpc}; + + Assert.Equal(new Uri("http://test:8888"), options.Endpoint); + Assert.Equal(OtlpExportProtocol.Grpc, options.Protocol); + } + + [Fact] + public void OtlpExporterOptions_ProtocolSetterDoesNotOverrideCustomEndpointFromSetter() + { + var options = new OtlpExporterOptions {Endpoint = new Uri("http://test:8888"), Protocol = OtlpExportProtocol.Grpc}; + + Assert.Equal(new Uri("http://test:8888"), options.Endpoint); + Assert.Equal(OtlpExportProtocol.Grpc, options.Protocol); + } + [Fact] public void OtlpExporterOptions_EnvironmentVariableNames() { From 2f9beb37b9485052c9b61aa84643f14ab43935c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 7 Feb 2022 14:20:20 +0100 Subject: [PATCH 02/10] fix compilation issues --- .../OtlpExporterOptionsTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs index e4f69e34a59..f92b7996885 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsTests.cs @@ -122,7 +122,7 @@ public void OtlpExporterOptions_ProtocolSetterDoesNotOverrideCustomEndpointFromE { Environment.SetEnvironmentVariable(OtlpExporterOptions.EndpointEnvVarName, "http://test:8888"); - var options = new OtlpExporterOptions {Protocol = OtlpExportProtocol.Grpc}; + var options = new OtlpExporterOptions { Protocol = OtlpExportProtocol.Grpc }; Assert.Equal(new Uri("http://test:8888"), options.Endpoint); Assert.Equal(OtlpExportProtocol.Grpc, options.Protocol); @@ -131,7 +131,7 @@ public void OtlpExporterOptions_ProtocolSetterDoesNotOverrideCustomEndpointFromE [Fact] public void OtlpExporterOptions_ProtocolSetterDoesNotOverrideCustomEndpointFromSetter() { - var options = new OtlpExporterOptions {Endpoint = new Uri("http://test:8888"), Protocol = OtlpExportProtocol.Grpc}; + var options = new OtlpExporterOptions { Endpoint = new Uri("http://test:8888"), Protocol = OtlpExportProtocol.Grpc }; Assert.Equal(new Uri("http://test:8888"), options.Endpoint); Assert.Equal(OtlpExportProtocol.Grpc, options.Protocol); From 50aea8b4131792af6f74594f3fd3b9aeb3d7dc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Tue, 8 Feb 2022 08:50:52 +0100 Subject: [PATCH 03/10] typo fix --- 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 63d4687b00e..d3ded675544 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -6,7 +6,7 @@ ([#2871](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2871)) * Fixed the default endpoint for OTLP exporter over HTTP/Protobuf. - ([#2686](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2868)) + ([#2868](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2868)) ## 1.2.0-rc2 From cbfa617d6f9a50446680e6cc3b6fcff035fd7ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Tue, 8 Feb 2022 20:20:28 +0100 Subject: [PATCH 04/10] bump Microsoft.DotNet.ApiCompat to 7.0.0-beta.22108.2 --- build/Common.prod.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Common.prod.props b/build/Common.prod.props index c97f40a0ed9..5ac92ee13eb 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -12,7 +12,7 @@ - + From 35dc2661393af2af3e9a61222a2a183a5b0a5916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 9 Feb 2022 09:16:19 +0100 Subject: [PATCH 05/10] Code review fixes --- .../OtlpExporterOptions.cs | 60 +++++-------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs index 05285782692..e627f519322 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs @@ -45,12 +45,10 @@ public class OtlpExporterOptions internal readonly Func DefaultHttpClientFactory; private const string DefaultGrpcEndpoint = "http://localhost:4317"; - private const string DefaultHttpProtobufEndpoint = "http://localhost:4318"; + private const string DefaultHttpEndpoint = "http://localhost:4318"; private const OtlpExportProtocol DefaultOtlpExportProtocol = OtlpExportProtocol.Grpc; - private OtlpExportProtocol protocol; private Uri endpoint; - private bool isCustomEndpointSet; /// /// Initializes a new instance of the class. @@ -79,14 +77,10 @@ public OtlpExporterOptions() throw new FormatException($"{ProtocolEnvVarName} environment variable has an invalid value: '${protocolEnvVar}'"); } } - else - { - this.Protocol = DefaultOtlpExportProtocol; - } if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri parsedEndpoint)) { - this.SetEndpoint(parsedEndpoint, custom: true); + this.endpoint = parsedEndpoint; } this.HttpClientFactory = this.DefaultHttpClientFactory = () => @@ -107,10 +101,21 @@ public OtlpExporterOptions() /// public Uri Endpoint { - get => this.endpoint; + get + { + if (this.endpoint == null) + { + this.endpoint = this.Protocol == OtlpExportProtocol.Grpc + ? new Uri(DefaultGrpcEndpoint) + : new Uri(DefaultHttpEndpoint); + } + + return this.endpoint; + } + set { - this.SetEndpoint(value, custom: true); + this.endpoint = value; this.ProgrammaticallyModifiedEndpoint = true; } } @@ -129,24 +134,7 @@ public Uri Endpoint /// /// Gets or sets the the OTLP transport protocol. Supported values: Grpc and HttpProtobuf. /// - public OtlpExportProtocol Protocol - { - get => this.protocol; - set - { - this.protocol = value; - - switch (value) - { - case OtlpExportProtocol.Grpc: - this.SetEndpoint(new Uri(DefaultGrpcEndpoint)); - break; - case OtlpExportProtocol.HttpProtobuf: - this.SetEndpoint(new Uri(DefaultHttpProtobufEndpoint)); - break; - } - } - } + public OtlpExportProtocol Protocol { get; set; } = DefaultOtlpExportProtocol; /// /// Gets or sets the export processor type to be used with the OpenTelemetry Protocol Exporter. The default value is . @@ -211,21 +199,5 @@ public OtlpExportProtocol Protocol /// Gets a value indicating whether was programmatically modified. /// internal bool ProgrammaticallyModifiedEndpoint { get; private set; } - - private void SetEndpoint(Uri value, bool custom = false) - { - if (custom) - { - this.isCustomEndpointSet = true; - this.endpoint = value; - } - else - { - if (!this.isCustomEndpointSet) - { - this.endpoint = value; - } - } - } } } From 16b2ef83ad17005e5e6134e7ff5525b1ad05445a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 9 Feb 2022 09:21:51 +0100 Subject: [PATCH 06/10] accept changes detected by ApiCompat in OpenTelemetry.Exporter.OpenTelemetryProtocol --- .../ApiCompatBaseline.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/OpenTelemetry.Exporter.OpenTelemetryProtocol/ApiCompatBaseline.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/ApiCompatBaseline.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/ApiCompatBaseline.txt new file mode 100644 index 00000000000..e7158253a98 --- /dev/null +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/ApiCompatBaseline.txt @@ -0,0 +1,4 @@ +Compat issues with assembly OpenTelemetry.Exporter.OpenTelemetryProtocol: +CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.CompilerGeneratedAttribute' exists on 'OpenTelemetry.Exporter.OtlpExporterOptions.Endpoint.get()' in the contract but not the implementation. +CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.CompilerGeneratedAttribute' exists on 'OpenTelemetry.Exporter.OtlpExporterOptions.Endpoint.set(System.Uri)' in the contract but not the implementation. +Total Issues: 2 From 360ad79c50e574e724edb8792085838fb92627fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 9 Feb 2022 09:29:59 +0100 Subject: [PATCH 07/10] revert not needed changes --- .../OtlpExporterOptions.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs index e627f519322..74fe6852a59 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs @@ -55,6 +55,11 @@ public class OtlpExporterOptions /// public OtlpExporterOptions() { + if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri parsedEndpoint)) + { + this.endpoint = parsedEndpoint; + } + if (EnvironmentVariableHelper.LoadString(HeadersEnvVarName, out string headersEnvVar)) { this.Headers = headersEnvVar; @@ -67,10 +72,10 @@ public OtlpExporterOptions() if (EnvironmentVariableHelper.LoadString(ProtocolEnvVarName, out string protocolEnvVar)) { - var parsedProtocol = protocolEnvVar.ToOtlpExportProtocol(); - if (parsedProtocol.HasValue) + var protocol = protocolEnvVar.ToOtlpExportProtocol(); + if (protocol.HasValue) { - this.Protocol = parsedProtocol.Value; + this.Protocol = protocol.Value; } else { @@ -78,11 +83,6 @@ public OtlpExporterOptions() } } - if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri parsedEndpoint)) - { - this.endpoint = parsedEndpoint; - } - this.HttpClientFactory = this.DefaultHttpClientFactory = () => { return new HttpClient From e6eb99c724eaee4c22a2a73143fc7117d5526c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 9 Feb 2022 09:31:30 +0100 Subject: [PATCH 08/10] Update src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert PajÄ…k --- .../OtlpExporterOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs index 74fe6852a59..e8b06e43914 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs @@ -196,7 +196,7 @@ public Uri Endpoint public Func HttpClientFactory { get; set; } /// - /// Gets a value indicating whether was programmatically modified. + /// Gets a value indicating whether was modified via its setter. /// internal bool ProgrammaticallyModifiedEndpoint { get; private set; } } From c07f390ccafee095448773ab675397dbe2ef94ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 9 Feb 2022 10:34:56 +0100 Subject: [PATCH 09/10] Revert "bump Microsoft.DotNet.ApiCompat to 7.0.0-beta.22108.2" This reverts commit cbfa617d6f9a50446680e6cc3b6fcff035fd7ac7. --- build/Common.prod.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Common.prod.props b/build/Common.prod.props index 5ac92ee13eb..c97f40a0ed9 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -12,7 +12,7 @@ - + From a2b6c07530f8246eca87d30f981247b3d98af193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 14 Feb 2022 06:41:12 +0100 Subject: [PATCH 10/10] extend changelog to include default value for the endpoint --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index d3ded675544..da8dedcd2ad 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -6,6 +6,7 @@ ([#2871](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2871)) * Fixed the default endpoint for OTLP exporter over HTTP/Protobuf. + The default value is `http://localhost:4318`. ([#2868](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2868)) ## 1.2.0-rc2