diff --git a/stackdriver_exporter.go b/stackdriver_exporter.go index 98286860..04ba0ded 100644 --- a/stackdriver_exporter.go +++ b/stackdriver_exporter.go @@ -76,6 +76,9 @@ func createMonitoringService() (*monitoring.Service, error) { ctx := context.Background() googleClient, err := google.DefaultClient(ctx, monitoring.MonitoringReadScope) + if err != nil { + return nil, fmt.Errorf("Error creating Google client: %v", err) + } googleClient.Timeout = *stackdriverHttpTimeout googleClient.Transport = rehttp.NewTransport( @@ -86,10 +89,6 @@ func createMonitoringService() (*monitoring.Service, error) { rehttp.ExpJitterDelay(*stackdriverBackoffJitterBase, *stackdriverMaxBackoffDuration), // Set timeout to <10s as that is prom default timeout ) - if err != nil { - return nil, fmt.Errorf("Error creating Google client: %v", err) - } - monitoringService, err := monitoring.New(googleClient) if err != nil { return nil, fmt.Errorf("Error creating Google Stackdriver Monitoring service: %v", err)