Alerting: Logs should not be capitalized and the errors key should be "err" (#50333)

* Alerting: decapitalize log lines and use "err" as the key for errors

Found using (logger|log).(Warn|Debug|Info|Error)\([A-Z] and (logger|log).(Warn|Debug|Info|Error)\(.+"error"
This commit is contained in:
gotjosh
2022-06-07 18:54:23 +01:00
committed by GitHub
parent af841a79ae
commit 0cde283505
25 changed files with 88 additions and 77 deletions

View File

@@ -353,7 +353,7 @@ func (st *Manager) annotateState(ctx context.Context, alertRule *ngModels.AlertR
err = st.dashboardService.GetDashboard(ctx, query)
if err != nil {
st.log.Error("error getting dashboard for alert annotation", "dashboardUID", dashUid, "alertRuleUID", alertRule.UID, "error", err.Error())
st.log.Error("error getting dashboard for alert annotation", "dashboardUID", dashUid, "alertRuleUID", alertRule.UID, "err", err.Error())
return
}
@@ -363,7 +363,7 @@ func (st *Manager) annotateState(ctx context.Context, alertRule *ngModels.AlertR
annotationRepo := annotations.GetRepository()
if err := annotationRepo.Save(item); err != nil {
st.log.Error("error saving alert annotation", "alertRuleUID", alertRule.UID, "error", err.Error())
st.log.Error("error saving alert annotation", "alertRuleUID", alertRule.UID, "err", err.Error())
return
}
}
@@ -378,11 +378,11 @@ func (st *Manager) staleResultsHandler(ctx context.Context, alertRule *ngModels.
ilbs := ngModels.InstanceLabels(s.Labels)
_, labelsHash, err := ilbs.StringAndHash()
if err != nil {
st.log.Error("unable to get labelsHash", "error", err.Error(), "orgID", s.OrgID, "alertRuleUID", s.AlertRuleUID)
st.log.Error("unable to get labelsHash", "err", err.Error(), "orgID", s.OrgID, "alertRuleUID", s.AlertRuleUID)
}
if err = st.instanceStore.DeleteAlertInstance(ctx, s.OrgID, s.AlertRuleUID, labelsHash); err != nil {
st.log.Error("unable to delete stale instance from database", "error", err.Error(), "orgID", s.OrgID, "alertRuleUID", s.AlertRuleUID, "cacheID", s.CacheId)
st.log.Error("unable to delete stale instance from database", "err", err.Error(), "orgID", s.OrgID, "alertRuleUID", s.AlertRuleUID, "cacheID", s.CacheId)
}
if s.State == eval.Alerting {