Skip to content

Commit

Permalink
Initialize success and error counters
Browse files Browse the repository at this point in the history
We need to initialize success and error counters properly in order
to avoid having undefined metrics.

Closes: #59
  • Loading branch information
adidenko committed Nov 6, 2023
1 parent ee3de08 commit 8e3f62b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
)

// Constants and vars
const version = "0.5.0"
const version = "0.5.1"
const workersCannelSize = 1024
const errorBadHTTPCode = "Bad HTTP status code"

Expand Down Expand Up @@ -516,9 +516,7 @@ func worker(ctx context.Context, id int, config appConfig, comm chan message, st
}

} else {

config.metrics.requestsSendSuccess.WithLabelValues(config.metrics.labelValues...).Inc()

}
}
}
Expand Down
2 changes: 2 additions & 0 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ func initMetrics(config appConfig, labelNames, labelValues []string) appMetrics
am.channelConfigLength.WithLabelValues(labelValues...).Set(float64(workersCannelSize))
am.channelLength.WithLabelValues(labelValues...).Set(float64(0))
am.channelFullEvents.WithLabelValues(labelValues...).Add(0)
am.requestsSendSuccess.WithLabelValues(labelValues...).Add(0)
am.requestsSendErrors.WithLabelValues(labelValues...).Add(0)

return am
}
Expand Down

0 comments on commit 8e3f62b

Please sign in to comment.