From ad9ac85ee090f8bb006c5b095c0fe3ac7e1b71cd Mon Sep 17 00:00:00 2001 From: George Robinson Date: Tue, 8 Nov 2022 22:37:49 +0000 Subject: [PATCH] Alerting: Use hash of opts in singleflight (#58474) --- pkg/services/ngalert/image/service.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/services/ngalert/image/service.go b/pkg/services/ngalert/image/service.go index d113a209fbe..0c6a9d280e3 100644 --- a/pkg/services/ngalert/image/service.go +++ b/pkg/services/ngalert/image/service.go @@ -2,6 +2,7 @@ package image import ( "context" + "encoding/base64" "errors" "fmt" "time" @@ -135,8 +136,8 @@ func (s *ScreenshotImageService) NewImage(ctx context.Context, r *models.AlertRu Timeout: screenshotTimeout, } - k := fmt.Sprintf("%s-%d-%s", opts.DashboardUID, opts.PanelID, opts.Theme) - result, err, _ := s.singleflight.Do(k, func() (interface{}, error) { + optsHash := base64.StdEncoding.EncodeToString(opts.Hash()) + result, err, _ := s.singleflight.Do(optsHash, func() (interface{}, error) { screenshot, err := s.limiter.Do(ctx, opts, s.screenshots.Take) if err != nil { if errors.Is(err, dashboards.ErrDashboardNotFound) {