diff --git a/example/otel-collector/main.go b/example/otel-collector/main.go index c3372ab482a..7720e96f650 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)