Remove extra defers in screenshot sevice (#84697)

This commit is contained in:
George Robinson 2024-03-20 07:13:16 +00:00 committed by GitHub
parent 034c232ec9
commit f3e5ad00d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,22 +132,22 @@ func (s *HeadlessScreenshotService) Take(ctx context.Context, opts ScreenshotOpt
return nil, fmt.Errorf("failed to take screenshot: %w", err)
}
defer s.successes.Inc()
s.successes.Inc()
screenshot := Screenshot{Path: result.FilePath}
return &screenshot, nil
}
func (s *HeadlessScreenshotService) instrumentError(err error) {
if errors.Is(err, dashboards.ErrDashboardNotFound) {
defer s.failures.With(prometheus.Labels{
s.failures.With(prometheus.Labels{
"reason": "dashboard_not_found",
}).Inc()
} else if errors.Is(err, context.Canceled) {
defer s.failures.With(prometheus.Labels{
s.failures.With(prometheus.Labels{
"reason": "context_canceled",
}).Inc()
} else {
defer s.failures.With(prometheus.Labels{
s.failures.With(prometheus.Labels{
"reason": "error",
}).Inc()
}