Alerting: Fix logging pointer address of DashboardUID and PanelID variables (#58539)
This commit is contained in:
@@ -115,24 +115,26 @@ func NewScreenshotImageServiceFromCfg(cfg *setting.Cfg, db *store.DBstore, ds da
|
||||
func (s *ScreenshotImageService) NewImage(ctx context.Context, r *models.AlertRule) (*models.Image, error) {
|
||||
logger := s.logger.FromContext(ctx)
|
||||
|
||||
if r.DashboardUID == nil || *r.DashboardUID == "" {
|
||||
dashboardUID := r.GetDashboardUID()
|
||||
if dashboardUID == "" {
|
||||
logger.Debug("Cannot take screenshot for alert rule as it is not associated with a dashboard")
|
||||
return nil, models.ErrNoDashboard
|
||||
}
|
||||
|
||||
if r.PanelID == nil || *r.PanelID == 0 {
|
||||
panelID := r.GetPanelID()
|
||||
if panelID <= 0 {
|
||||
logger.Debug("Cannot take screenshot for alert rule as it is not associated with a panel")
|
||||
return nil, models.ErrNoPanel
|
||||
}
|
||||
|
||||
logger = logger.New("dashboard", dashboardUID, "panel", panelID)
|
||||
|
||||
opts := screenshot.ScreenshotOptions{
|
||||
DashboardUID: *r.DashboardUID,
|
||||
PanelID: *r.PanelID,
|
||||
DashboardUID: dashboardUID,
|
||||
PanelID: panelID,
|
||||
Timeout: screenshotTimeout,
|
||||
}
|
||||
|
||||
logger = logger.New("dashboard", opts.DashboardUID, "panel", opts.PanelID)
|
||||
|
||||
// To prevent concurrent screenshots of the same dashboard panel we use singleflight,
|
||||
// deduplicated on a base64 hash of the screenshot options.
|
||||
optsHash := base64.StdEncoding.EncodeToString(opts.Hash())
|
||||
|
||||
Reference in New Issue
Block a user