Skip to content

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasbu committed Dec 22, 2022
1 parent 06fa862 commit 2c049d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion reporters/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ type Reporter interface {
// Reporters hold a map of structs that implement the Reporter interface
type Reporters struct {
reporters map[string]Reporter
logger logrus.FieldLogger
}

// setLogger sets logger to the Reporters singleton
func (r *Reporters) setLogger(logger logrus.FieldLogger) {
r.logger = logger
}

// SetReporter sets a Reporter in Reporters' map
Expand Down Expand Up @@ -55,7 +61,13 @@ func (r *Reporters) Report(event string, opts map[string]interface{}) error {
// We ignore the reporter errors explicitly here for the following reason:
// if we return these errors, it could bring issues in the ping mechanism,
// and we would not be able to find any room.
_ = reporter.Report(event, copyOpts(opts))
if err := reporter.Report(event, copyOpts(opts)); err != nil {
if r.logger != nil {
r.logger.
WithError(err).
Errorf("failed to report event '%s'", event)
}
}
}
return nil
}
Expand All @@ -72,6 +84,8 @@ func Report(event string, opts map[string]interface{}) error {

// MakeReporters creates Reporters' singleton from config/{}.yaml
func MakeReporters(config *viper.Viper, logger logrus.FieldLogger) {
GetInstance().setLogger(logger)

if config.IsSet("reporters.dogstatsd") {
MakeDogStatsD(config, logger, GetInstance())
}
Expand Down
2 changes: 2 additions & 0 deletions watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,11 @@ func (w *Watcher) reportRoomsStatusesRoutine() {
case <-podStateCountTicker.C:
w.PodStatesCount()
case <-roomStatusTicker.C:
w.Logger.Info("Start to report rooms status")
if err := w.ReportRoomsStatuses(); err != nil {
w.Logger.WithError(err).Error("failed to report room status")
}
w.Logger.Info("Finished to report rooms status")
}
}
}
Expand Down

0 comments on commit 2c049d9

Please sign in to comment.