From 2fe92958aa06fbe2f2bcb02b2e0f390c33b751c3 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 28 Jul 2023 12:06:36 -0700 Subject: [PATCH 1/4] Remove dependency on deprecated gRPC library --- .../ExportClient/BaseOtlpGrpcExportClient.cs | 8 +------ ...etry.Exporter.OpenTelemetryProtocol.csproj | 5 ++--- .../OtlpExporterOptionsExtensions.cs | 22 +------------------ 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpGrpcExportClient.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpGrpcExportClient.cs index e0a4d7b75b1..8628d2594ee 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpGrpcExportClient.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/BaseOtlpGrpcExportClient.cs @@ -15,10 +15,8 @@ // using Grpc.Core; -using OpenTelemetry.Internal; -#if NETSTANDARD2_1 || NET6_0_OR_GREATER using Grpc.Net.Client; -#endif +using OpenTelemetry.Internal; namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; @@ -38,11 +36,7 @@ protected BaseOtlpGrpcExportClient(OtlpExporterOptions options) this.TimeoutMilliseconds = options.TimeoutMilliseconds; } -#if NETSTANDARD2_1 || NET6_0_OR_GREATER internal GrpcChannel Channel { get; set; } -#else - internal Channel Channel { get; set; } -#endif internal Uri Endpoint { get; } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj index 0d8082df4f5..e9059f3bbb9 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj @@ -1,6 +1,6 @@ - $(DefaultTargetFrameworks);netstandard2.1 + net6.0;netstandard2.0 OpenTelemetry protocol exporter for OpenTelemetry .NET $(PackageTags);OTLP core- @@ -14,8 +14,7 @@ - - + diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs index 5f8758408a9..e67e7d3b2eb 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs @@ -19,10 +19,8 @@ #endif using System.Reflection; using Grpc.Core; -using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; -#if NETSTANDARD2_1 || NET6_0_OR_GREATER using Grpc.Net.Client; -#endif +using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; using LogOtlpCollector = OpenTelemetry.Proto.Collector.Logs.V1; using MetricsOtlpCollector = OpenTelemetry.Proto.Collector.Metrics.V1; using TraceOtlpCollector = OpenTelemetry.Proto.Collector.Trace.V1; @@ -31,32 +29,14 @@ namespace OpenTelemetry.Exporter; internal static class OtlpExporterOptionsExtensions { -#if NETSTANDARD2_1 || NET6_0_OR_GREATER public static GrpcChannel CreateChannel(this OtlpExporterOptions options) -#else - public static Channel CreateChannel(this OtlpExporterOptions options) -#endif { if (options.Endpoint.Scheme != Uri.UriSchemeHttp && options.Endpoint.Scheme != Uri.UriSchemeHttps) { throw new NotSupportedException($"Endpoint URI scheme ({options.Endpoint.Scheme}) is not supported. Currently only \"http\" and \"https\" are supported."); } -#if NETSTANDARD2_1 || NET6_0_OR_GREATER return GrpcChannel.ForAddress(options.Endpoint); -#else - ChannelCredentials channelCredentials; - if (options.Endpoint.Scheme == Uri.UriSchemeHttps) - { - channelCredentials = new SslCredentials(); - } - else - { - channelCredentials = ChannelCredentials.Insecure; - } - - return new Channel(options.Endpoint.Authority, channelCredentials); -#endif } public static Metadata GetMetadataFromHeaders(this OtlpExporterOptions options) From 7c9c250bfb5106afccec971e4ed9e29d353b46b7 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 15 Sep 2023 15:48:28 -0700 Subject: [PATCH 2/4] Clean up preprocessor directives --- .../Implementation/ExportClient/OtlpRetry.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/OtlpRetry.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/OtlpRetry.cs index e65a1204925..d3fe88c32b4 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/OtlpRetry.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/OtlpRetry.cs @@ -174,7 +174,7 @@ private static int CalculateNextRetryDelay(int nextRetryDelayMilliseconds) { Debug.Assert(headers != null, "headers was null"); -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NET6_0_OR_GREATER return statusCode == HttpStatusCode.TooManyRequests || statusCode == HttpStatusCode.ServiceUnavailable #else return statusCode == (HttpStatusCode)429 || statusCode == HttpStatusCode.ServiceUnavailable @@ -207,7 +207,7 @@ private static bool IsHttpStatusCodeRetryable(HttpStatusCode statusCode, bool _) { switch (statusCode) { -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NET6_0_OR_GREATER case HttpStatusCode.TooManyRequests: #else case (HttpStatusCode)429: From 33461d077058c98fe6a096e01e40ae906c71b308 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Mon, 31 Jul 2023 10:38:20 -0700 Subject: [PATCH 3/4] Use DefaultTargetFrameworks --- .../OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj index cc90b19078c..335a5e4b594 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj @@ -1,6 +1,6 @@ - net6.0;netstandard2.0 + $(DefaultTargetFrameworks) OpenTelemetry protocol exporter for OpenTelemetry .NET $(PackageTags);OTLP core- From 9d33848786c34b712a9e6188ad10df537d415aa7 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 15 Sep 2023 16:47:39 -0700 Subject: [PATCH 4/4] Upgrade to Grpc.Net.Client 2.56.0 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4b2193facb7..e301f67e72c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -15,7 +15,7 @@ - +