From ec33fe0fbcc2004b5ae280eac53faf8b59205a16 Mon Sep 17 00:00:00 2001 From: Damien Mathieu <42@dmathieu.com> Date: Thu, 2 Jun 2022 17:18:17 +0200 Subject: [PATCH] add timeout to grpc connection in otel-collector example (#2939) --- example/otel-collector/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/otel-collector/main.go b/example/otel-collector/main.go index c3372ab48..7720e96f6 100644 --- a/example/otel-collector/main.go +++ b/example/otel-collector/main.go @@ -58,6 +58,8 @@ func initProvider() (func(context.Context) error, error) { // `localhost:30080` endpoint. Otherwise, replace `localhost` with the // endpoint of your cluster. If you run the app inside k8s, then you can // probably connect directly to the service through dns + ctx, cancel := context.WithTimeout(ctx, time.Second) + defer cancel() conn, err := grpc.DialContext(ctx, "localhost:30080", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { return nil, fmt.Errorf("failed to create gRPC connection to collector: %w", err)