Skip to content
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

fix(#237): Use Prometheus type Counter instead of Gauge for forward module's packet and byte counters #238

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func InitializeMetrics() {
dropBytesTotalDescription,
utils.Reason,
utils.Direction)
ForwardCounter = exporter.CreatePrometheusGaugeVecForMetric(
ForwardCounter = exporter.CreatePrometheusCounterVecForMetric(
exporter.DefaultRegistry,
utils.ForwardCountTotalName,
forwardCountTotalDescription,
utils.Direction)
ForwardBytesCounter = exporter.CreatePrometheusGaugeVecForMetric(
ForwardBytesCounter = exporter.CreatePrometheusCounterVecForMetric(
exporter.DefaultRegistry,
utils.ForwardBytesTotalName,
forwardBytesTotalDescription,
Expand Down
4 changes: 2 additions & 2 deletions pkg/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ var (
// Common counters across os distributions
DropCounter IGaugeVec
DropBytesCounter IGaugeVec
ForwardCounter IGaugeVec
ForwardBytesCounter IGaugeVec
ForwardCounter ICounterVec
ForwardBytesCounter ICounterVec

WindowsCounter IGaugeVec

Expand Down
6 changes: 3 additions & 3 deletions pkg/module/metrics/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (

type ForwardMetrics struct {
baseMetricObject
forwardMetric metricsinit.IGaugeVec
forwardMetric metricsinit.ICounterVec
// bytesMetric metricsinit.IGaugeVec
metricName string
}
Expand All @@ -47,13 +47,13 @@ func NewForwardCountMetrics(ctxOptions *api.MetricsContextOptions, fl *log.ZapLo
func (f *ForwardMetrics) Init(metricName string) {
switch metricName {
case utils.ForwardCountTotalName:
f.forwardMetric = exporter.CreatePrometheusGaugeVecForMetric(
f.forwardMetric = exporter.CreatePrometheusCounterVecForMetric(
exporter.AdvancedRegistry,
TotalCountName,
TotalCountDesc,
f.getLabels()...)
case utils.ForwardBytesTotalName:
f.forwardMetric = exporter.CreatePrometheusGaugeVecForMetric(
f.forwardMetric = exporter.CreatePrometheusCounterVecForMetric(
exporter.AdvancedRegistry,
TotalBytesName,
TotalBytesDesc,
Expand Down
2 changes: 1 addition & 1 deletion pkg/module/metrics/forward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func TestNewForward(t *testing.T) {
assert.NotNil(t, f, "forward metrics should not be nil Test Name: %s", tc.name)
}

forwardMock := metricsinit.NewMockIGaugeVec(ctrl) //nolint:typecheck
forwardMock := metricsinit.NewMockICounterVec(ctrl) //nolint:typecheck

f.forwardMetric = forwardMock

Expand Down
Loading