Skip to content

Commit 07cf2d6

Browse files
sivchariSyedowais312
authored andcommitted
[chore] move from DialContext to NewClient (open-telemetry#13663)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Use grpc.NewClient instead of grpc.DialContext <!-- Issue number if applicable --> #### Link to tracking issue Fixes open-telemetry#13632 <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: sivchari <shibuuuu5@gmail.com>
1 parent 7f0abd8 commit 07cf2d6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

config/configgrpc/configgrpc.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,16 @@ func (cc *ClientConfig) ToClientConn(
310310
if err != nil {
311311
return nil, err
312312
}
313-
//nolint:staticcheck // SA1019 see https://github.com/open-telemetry/opentelemetry-collector/pull/11575
314-
return grpc.DialContext(ctx, cc.sanitizedEndpoint(), grpcOpts...)
313+
conn, err := grpc.NewClient(cc.sanitizedEndpoint(), grpcOpts...)
314+
if err != nil {
315+
return nil, err
316+
}
317+
318+
// Initiate connection to match the previous behavior of DialContext
319+
// This ensures the connection is established eagerly rather than lazily
320+
conn.Connect()
321+
322+
return conn, nil
315323
}
316324

317325
func (cc *ClientConfig) addHeadersIfAbsent(ctx context.Context) context.Context {

0 commit comments

Comments
 (0)