// handleError makes the request to the StackDriver Error Reporting API func handleError(errorsClient *errors.Client, d device) { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() log.Printf("Sending report for %s (%s)", d.Name, d.Id) errorsClient.Reportf(ctx, nil, "Device is offline: %s (%s)", d.Name, d.Id) }