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

Provide an option to customize GrpcChannelOptions #5083

Open
En3Tho opened this issue Nov 26, 2023 · 2 comments
Open

Provide an option to customize GrpcChannelOptions #5083

En3Tho opened this issue Nov 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@En3Tho
Copy link

En3Tho commented Nov 26, 2023

Feature Request

Is your feature request related to a problem?

Unable to use grpc exporter in BlazorWasm with current OpenTelemetry grpc exporter code. Currently GrpcChannel is created with default GrpcChannelOptions which default ot using SocketsHttpHandler and invoke load balancing code which ends up crashing.

Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
         at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.IsSocketsHttpHandlerSetup(SocketsHttpHandler socketsHttpHandler)
         at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.ConfigureSocketsHttpHandlerSetup(SocketsHttpHandler socketsHttpHandler, Func`3 connectCallback)
         at Grpc.Net.Client.GrpcChannel.CreateInternalHttpInvoker(HttpMessageHandler handler)
         at Grpc.Net.Client.GrpcChannel..ctor(Uri address, GrpcChannelOptions channelOptions)
         at Grpc.Net.Client.GrpcChannel.ForAddress(Uri address, GrpcChannelOptions channelOptions)
         at Grpc.Net.Client.GrpcChannel.ForAddress(Uri address)

Describe the solution you'd like:

I want to introduce a class

public class OpenTelemetryGrpcChannelOptions
{
    public GrpcChannelOptions { get; set; } = new()
}

And augment OtlpGrpcTraceExportClient to somehow consume these options which then will be passed to OtlpExporterOptionsExtensions.CreateChannel

What do you want to happen instead? What is the expected behavior?

I want to provide a custom HttpClient/HttpClientHandler so grpc exporter in wasm won't crash

Which alternative solutions or features have you considered?

Alternative solution would be using HttpProtobuf but it requires keeping track of special endpoint for wasm and it is less effective than grpc

Additional Context

Add any other context about the feature request here.

@En3Tho En3Tho added the enhancement New feature or request label Nov 26, 2023
@En3Tho
Copy link
Author

En3Tho commented Nov 26, 2023

Related: #5028 but with a different approach

@pihai
Copy link

pihai commented Apr 4, 2024

We face a similar issue. Behind our corporate proxy load-balancing does not work:

2024-04-04T06:42:16.9695242Z:Exporter failed send data to collector to {0} endpoint. Data will not be sent. Exception: {1}{https://xxx.apm.westeurope.azure.elastic-cloud.com/}{Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Unable to get subchannel from HttpRequestMessage. (127.0.0.1:9000) InvalidOperationException: Unable to get subchannel from HttpRequestMessage.", DebugException="System.Net.Http.HttpRequestException: Unable to get subchannel from HttpRequestMessage. (127.0.0.1:9000)")
 ---> System.Net.Http.HttpRequestException: Unable to get subchannel from HttpRequestMessage. (127.0.0.1:9000)
 ---> System.InvalidOperationException: Unable to get subchannel from HttpRequestMessage.
   at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.OnConnect(SocketsHttpConnectionContext context, CancellationToken cancellationToken) in /_/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)
   --- End of inner exception stack trace ---

In other gRPC scenarios the following suggestion solved this issue: grpc/grpc-dotnet#2116 (comment)

It requires to set the HttpHandler property of GrpcChannelOptions. Without this possibility we have to stick with version 1.5 of the OpenTelemetry.Exporter.OpenTelemetryProtocol package. An upgrade to version 1.6 results in the problem described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants