Skip to content

Commit

Permalink
Add metric on score api error after on change
Browse files Browse the repository at this point in the history
  • Loading branch information
berejant committed Oct 15, 2023
1 parent 596646f commit c12e305
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ScoreChangedEventHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (handler *ScoreChangedEventHandler) callControllerAction(
uint32(event.StudentId), int(event.DisciplineId), int(event.LessonId),
)
if err != nil {
scoreApiGetScoreAfterChangeErrorCount.Inc()
_, _ = fmt.Fprintf(handler.out, "GetStudentScore return error: %v\n", err)
return
}
Expand All @@ -104,7 +105,8 @@ func (handler *ScoreChangedEventHandler) callControllerAction(
previousMessageIds := handler.scoreChangedMessageIdStorage.GetAll(event.StudentId, event.LessonId)
for _, chatId := range *chatIds {
scoreChangesSendCount.Inc()
err, newMessageId := handler.serviceContainer.ClientController.ScoreChangedAction(
var newMessageId string
err, newMessageId = handler.serviceContainer.ClientController.ScoreChangedAction(
chatId, previousMessageIds[chatId], &disciplineScore, previousScore,
)

Expand All @@ -114,7 +116,7 @@ func (handler *ScoreChangedEventHandler) callControllerAction(
)

if err != nil {
welcomeAuthorizedActionErrorCount.Inc()
scoreChangeActionErrorCount.Inc()
_, _ = fmt.Fprintf(handler.out, "ScoreChangedAction return error: %v\n", err)
}

Expand Down
2 changes: 2 additions & 0 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ var (

welcomeAuthorizedActionErrorCount = metrics.NewCounter(`error_count{type="WelcomeAuthorizedAction"}`)
scoreChangeActionErrorCount = metrics.NewCounter(`error_count{type="ScoreChangeAction"}`)

scoreApiGetScoreAfterChangeErrorCount = metrics.NewCounter(`error_count{type="ScoreApiGetScoreAfterReceiveChange"}`)
)

0 comments on commit c12e305

Please sign in to comment.