From bae20ba7355694c1d016fd7474a6b765c5dc8f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=92=E9=9C=89=E7=8B=90=E7=8B=B8?= Date: Mon, 27 Sep 2021 19:58:50 +0800 Subject: [PATCH] fix: contrib metrics datadog lint err (#1517) --- contrib/metrics/datadog/counter.go | 10 +++++----- contrib/metrics/datadog/gauge.go | 8 ++++---- contrib/metrics/datadog/observer.go | 8 ++++---- hack/.lintcheck_failures | 1 - 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/contrib/metrics/datadog/counter.go b/contrib/metrics/datadog/counter.go index a1e0838a3..360490241 100644 --- a/contrib/metrics/datadog/counter.go +++ b/contrib/metrics/datadog/counter.go @@ -14,16 +14,16 @@ type counter struct { // NewCounter new a DataDog counter and returns Counter. func NewCounter(name string, opts ...Option) metrics.Counter { - options := options{ + counterOpts := options{ sampleRate: 1, client: defaultClient, } for _, o := range opts { - o(&options) + o(&counterOpts) } return &counter{ name: name, - opts: options, + opts: counterOpts, } } @@ -37,9 +37,9 @@ func (d *counter) With(values ...string) metrics.Counter { } func (d *counter) Inc() { - d.opts.client.Incr(d.name, d.lvs, d.opts.sampleRate) + _ = d.opts.client.Incr(d.name, d.lvs, d.opts.sampleRate) } func (d *counter) Add(delta float64) { - d.opts.client.Count(d.name, int64(delta), d.lvs, d.opts.sampleRate) + _ = d.opts.client.Count(d.name, int64(delta), d.lvs, d.opts.sampleRate) } diff --git a/contrib/metrics/datadog/gauge.go b/contrib/metrics/datadog/gauge.go index 323b86f2c..fbff772be 100644 --- a/contrib/metrics/datadog/gauge.go +++ b/contrib/metrics/datadog/gauge.go @@ -14,16 +14,16 @@ type gauge struct { // NewGauge new a DataDog gauge and returns Gauge. func NewGauge(name string, opts ...Option) metrics.Gauge { - options := options{ + gaugeOpts := options{ sampleRate: 1, client: defaultClient, } for _, o := range opts { - o(&options) + o(&gaugeOpts) } return &gauge{ name: name, - opts: options, + opts: gaugeOpts, } } @@ -36,7 +36,7 @@ func (d *gauge) With(values ...string) metrics.Gauge { } func (d *gauge) Set(value float64) { - d.opts.client.Gauge(d.name, value, d.lvs, d.opts.sampleRate) + _ = d.opts.client.Gauge(d.name, value, d.lvs, d.opts.sampleRate) } func (d *gauge) Add(delta float64) { diff --git a/contrib/metrics/datadog/observer.go b/contrib/metrics/datadog/observer.go index f6f90fc06..92c8cab01 100644 --- a/contrib/metrics/datadog/observer.go +++ b/contrib/metrics/datadog/observer.go @@ -16,16 +16,16 @@ type timing struct { // NewTiming new a DataDog timer and returns Observer. func NewTiming(name string, opts ...Option) metrics.Observer { - options := options{ + timingOpts := options{ sampleRate: 1, client: defaultClient, } for _, o := range opts { - o(&options) + o(&timingOpts) } return &timing{ name: name, - opts: options, + opts: timingOpts, } } @@ -39,5 +39,5 @@ func (d *timing) With(values ...string) metrics.Observer { } func (d *timing) Observe(value float64) { - d.opts.client.TimeInMilliseconds(d.name, value*float64(time.Second/time.Millisecond), d.lvs, d.opts.sampleRate) + _ = d.opts.client.TimeInMilliseconds(d.name, value*float64(time.Second/time.Millisecond), d.lvs, d.opts.sampleRate) } diff --git a/hack/.lintcheck_failures b/hack/.lintcheck_failures index 65c33a88f..2cfe406c4 100644 --- a/hack/.lintcheck_failures +++ b/hack/.lintcheck_failures @@ -1,4 +1,3 @@ -./contrib/metrics/datadog ./contrib/config/nacos ./contrib/config/apollo ./contrib/config/kubernetes