Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Not for merging] Phase out Grpc package for OTLP Exporter. #3573

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
-->
<MinVerPkgVer>[4.1.0,5.0)</MinVerPkgVer>
<GoogleProtobufPkgVer>[3.19.4,4.0)</GoogleProtobufPkgVer>
<GrpcPkgVer>[2.44.0,3.0)</GrpcPkgVer>
<GrpcNetClientPkgVer>[2.43.0,3.0)</GrpcNetClientPkgVer>
<GrpcToolsPkgVer>[2.44.0,3.0)</GrpcToolsPkgVer>
<MicrosoftAspNetCoreHttpAbstractionsPkgVer>[2.1.1,6.0)</MicrosoftAspNetCoreHttpAbstractionsPkgVer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
using System.Threading;
using System.Threading.Tasks;
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
{
Expand All @@ -41,11 +39,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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,10 @@
<MinVerTagPrefix>core-</MinVerTagPrefix>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Grpc.Net.Client" Version="$(GrpcNetClientPkgVer)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="$(GrpcNetClientPkgVer)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Grpc" Version="$(GrpcPkgVer)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Grpc" Version="$(GrpcPkgVer)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPkgVer)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
using System.Net.Http;
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;
Expand All @@ -30,32 +28,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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.OtlpExporterOptionsExtensionsTests.GetTraceExportClient_SupportedProtocol_ReturnsCorrectExportClient(protocol: Grpc, expectedExportClientType: typeof(OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient.OtlpGrpcTraceExportClient))
 Source: OtlpExporterOptionsExtensionsTests.cs line 91
 Duration: 1.2 sec

Message: 
System.PlatformNotSupportedException : gRPC requires extra configuration on .NET implementations that don't support gRPC over HTTP/2. An HTTP provider must be specified using GrpcChannelOptions.HttpHandler.The configured HTTP provider must either support HTTP/2 or be configured to use gRPC-Web. See https://aka.ms/aspnet/grpc/netstandard for details.

Stack Trace: 
HttpHandlerFactory.CreatePrimaryHandler()
GrpcChannel.CreateInternalHttpInvoker(HttpMessageHandler handler)
GrpcChannel.ctor(Uri address, GrpcChannelOptions channelOptions)
GrpcChannel.ForAddress(Uri address, GrpcChannelOptions channelOptions)
GrpcChannel.ForAddress(Uri address)
OtlpExporterOptionsExtensions.CreateChannel(OtlpExporterOptions options) line 39
OtlpGrpcTraceExportClient.ctor(OtlpExporterOptions options, TraceServiceClient traceServiceClient) line 39
OtlpExporterOptionsExtensions.GetTraceExportClient(OtlpExporterOptions options) line 81
OtlpExporterOptionsExtensionsTests.GetTraceExportClient_SupportedProtocol_ReturnsCorrectExportClient(OtlpExportProtocol protocol, Type expectedExportClientType) line 106

#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)
Expand Down