open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.26k stars 769 forks source link

OpenTelemetryProtocol exporter while using a proxy #4771

Open AB027PS opened 1 year ago

AB027PS commented 1 year ago

Feature Request

Is your feature request related to a problem?

When I try to export data using OTLP exporter from behind a proxy, I get this exception: Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Unable to get subchannel from HttpRequestMessage. (proxy detail) InvalidOperationException: Unable to get subchannel from HttpRequestMessage.", DebugException="System.Net.Http.HttpRequestException: Unable to get subchannel from HttpRequestMessage. (proxy detail)") ---> System.Net.Http.HttpRequestException: Unable to get subchannel from HttpRequestMessage. (proxy detail) ---> System.InvalidOperationException: Unable to get subchannel from HttpRequestMessage. at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.OnConnect(SocketsHttpConnectionContext context, CancellationToken cancellationToken) in C:\Users\ab027ps\source\repos\grpc-dotnet\src\Grpc.Net.Client\Balancer\Internal\BalancerHttpHandler.cs:line 89 at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)

Describe the solution you'd like:

This can be fixed by substituting the line 46 in this file https://github.com/open-telemetry/opentelemetry-dotnet/blob/031ed48714e16ba4a5b099b6e14647994a0b9c1b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs for return GrpcChannel.ForAddress(options.Endpoint, new GrpcChannelOptions { HttpHandler = new HttpClientHandler() });

One possible solution would be to keep the current behavior as default but give users the ability to specify GrpcChannelOptions.

Describe alternatives you've considered.

Alternatively, there could be a boolean IsBehindAProxy property in OtlpExporterOptions which would switch between the current code and the line I posted above, although I don't know enough about gRPC to know if this would work generally.

github-actions[bot] commented 1 month ago

This issue was marked stale due to lack of activity and will be closed in 7 days. Commenting will instruct the bot to automatically remove the label. This bot runs once per day.