Skip to content

Commit

Permalink
add timeout to grpc connection in otel-collector example (#2939)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu authored Jun 2, 2022
1 parent 1818a82 commit ec33fe0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example/otel-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ec33fe0

Please sign in to comment.