From ea5a71d27b16cafdd33027319caf5f8b85d5531e Mon Sep 17 00:00:00 2001 From: Puneet Agarwal Date: Wed, 18 Sep 2024 20:02:27 +0530 Subject: [PATCH] ENG-48179: Revert to use DialContext in grpc client With NewClient API usage, we are facing issues at few customers who have intermediate proxies between collector and platform. With NewClient API instead Dial, DNS resolution happens on the client side while it should happen on proxy. Also, with SGProxy client does not get the correct certificate. This can be changed once grpc fixes grpc/grpc-go#7556 and otel collector picks the fix --- FORK.md | 3 ++- config/configgrpc/configgrpc.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/FORK.md b/FORK.md index 0136ec61ac4..b6a4c57bdcd 100644 --- a/FORK.md +++ b/FORK.md @@ -21,4 +21,5 @@ git push --tags - In `config/configgrpc/configgrpc.go` we added the ability to add extra `ClientDialOptionHandler`. Also a unit test for this in `config/configgrpc/configgrpcclientdialoptionhandler_test.go`. Also commented out warning on servers starting `UnspecifiedHost` aka `0.0.0.0`. - In `config/configgrpc/configgrpc_test.go` we commented a unit test checking for a warning on servers starting `UnspecifiedHost` aka `0.0.0.0`. - In `config/confighttp/confighttp.go` we commented out warning on servers starting `UnspecifiedHost`. -- In ` config/confighttp/confighttp_test.go` we commented a unit test checking for a warning on servers starting `UnspecifiedHost`. +- In `config/confighttp/confighttp_test.go` we commented a unit test checking for a warning on servers starting `UnspecifiedHost`. +- In `config/configgrpc/configgrpc.go` we reverted back to use `grpc.DialContext` method instead of `grpc.NewClient` diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index 93a373b2333..f19e04a5519 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -275,7 +275,7 @@ func (gcs *ClientConfig) ToClientConnWithOptions( if err != nil { return nil, err } - return grpc.NewClient(gcs.sanitizedEndpoint(), grpcOpts...) + return grpc.DialContext(ctx, gcs.sanitizedEndpoint(), grpcOpts...) } func (gcs *ClientConfig) getGrpcDialOptions(