-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alerting: State Manager takes screenshots. #49338
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass looking good, some nits and comments.
// It's not an error if screenshots are disabled, or our rule isn't allowed to generate screenshots. | ||
return nil | ||
} else if err != nil { | ||
st.log.Error("failed to create image", "error", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But there is double logging here, which we don't need. I'm going to remove this one and keep the more detailed one in the outer function.
@@ -1770,7 +1770,7 @@ func TestProcessEvalResults(t *testing.T) { | |||
|
|||
for _, tc := range testCases { | |||
ss := mockstore.NewSQLStoreMock() | |||
st := state.NewManager(log.New("test_state_manager"), testMetrics.GetStateMetrics(), nil, nil, &store.FakeInstanceStore{}, ss, &dashboards.FakeDashboardService{}, &image.NoopImageService{}) | |||
st := state.NewManager(log.New("test_state_manager"), testMetrics.GetStateMetrics(), nil, nil, &store.FakeInstanceStore{}, ss, &dashboards.FakeDashboardService{}, &image.NotAvailableImageService{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was so I didn't have to modify a bunch of tests with zero-value image structs.
The State Manager will now take screenshots when an alert instance switches to an Alerting or Resolved state. Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
9fe09a0
to
223d4e8
Compare
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/19176 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Great structure and really readable PR - nice work. Had a single comment that was just a nitpick (and optional).
// 1. The alert state is transitioning into the "Alerting" state from something else. | ||
// 2. The alert state has just transitioned to the resolved state. | ||
// 3. The state is alerting and there is no screenshot annotation on the alert state. | ||
func (st *Manager) maybeNewImage(ctx context.Context, alertRule *ngModels.AlertRule, state *State, oldState eval.State) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (st *Manager) maybeNewImage(ctx context.Context, alertRule *ngModels.AlertRule, state *State, oldState eval.State) error { | |
func (st *Manager) maybeTakeScreenshot(ctx context.Context, alertRule *ngModels.AlertRule, state *State, oldState eval.State) error { |
Huge nit, ignore if you disagree. Just staying away from the new
term since that usually implies a constructor in Go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, much better name.
PanelIDAnnotation = "__panelId__" | ||
DashboardUIDAnnotation = "__dashboardUid__" | ||
PanelIDAnnotation = "__panelId__" | ||
ScreenshotTokenAnnotation = "__alertScreenshotToken__" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScreenshotTokenAnnotation = "__alertScreenshotToken__" | |
ScreenshotTokenAnnotation = "__alertScreenshotToken__ //nolint:gosec" |
To fix the linter
Drone build failed: https://drone.grafana.net/grafana/grafana-enterprise/19182 |
The State Manager will now take screenshots when an alert instance
switches to an Alerting or Resolved state.
Signed-off-by: Joe Blubaugh joe.blubaugh@grafana.com
Special notes for your reviewer:
This PR is based on joe/add-screenshots-to-ngalert, #49293 . Once that PR merges, I'll change the base to
main