mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-12 10:04:29 +02:00
add timeout to grpc connection in otel-collector example (#2939)
This commit is contained in:
parent
1818a82372
commit
ec33fe0fbc
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user