fix: contrib metrics datadog lint err (#1517)

pull/1521/head
倒霉狐狸 3 years ago committed by GitHub
parent 7cc6565d01
commit bae20ba735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      contrib/metrics/datadog/counter.go
  2. 8
      contrib/metrics/datadog/gauge.go
  3. 8
      contrib/metrics/datadog/observer.go
  4. 1
      hack/.lintcheck_failures

@ -14,16 +14,16 @@ type counter struct {
// NewCounter new a DataDog counter and returns Counter. // NewCounter new a DataDog counter and returns Counter.
func NewCounter(name string, opts ...Option) metrics.Counter { func NewCounter(name string, opts ...Option) metrics.Counter {
options := options{ counterOpts := options{
sampleRate: 1, sampleRate: 1,
client: defaultClient, client: defaultClient,
} }
for _, o := range opts { for _, o := range opts {
o(&options) o(&counterOpts)
} }
return &counter{ return &counter{
name: name, name: name,
opts: options, opts: counterOpts,
} }
} }
@ -37,9 +37,9 @@ func (d *counter) With(values ...string) metrics.Counter {
} }
func (d *counter) Inc() { 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) { 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)
} }

@ -14,16 +14,16 @@ type gauge struct {
// NewGauge new a DataDog gauge and returns Gauge. // NewGauge new a DataDog gauge and returns Gauge.
func NewGauge(name string, opts ...Option) metrics.Gauge { func NewGauge(name string, opts ...Option) metrics.Gauge {
options := options{ gaugeOpts := options{
sampleRate: 1, sampleRate: 1,
client: defaultClient, client: defaultClient,
} }
for _, o := range opts { for _, o := range opts {
o(&options) o(&gaugeOpts)
} }
return &gauge{ return &gauge{
name: name, name: name,
opts: options, opts: gaugeOpts,
} }
} }
@ -36,7 +36,7 @@ func (d *gauge) With(values ...string) metrics.Gauge {
} }
func (d *gauge) Set(value float64) { 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) { func (d *gauge) Add(delta float64) {

@ -16,16 +16,16 @@ type timing struct {
// NewTiming new a DataDog timer and returns Observer. // NewTiming new a DataDog timer and returns Observer.
func NewTiming(name string, opts ...Option) metrics.Observer { func NewTiming(name string, opts ...Option) metrics.Observer {
options := options{ timingOpts := options{
sampleRate: 1, sampleRate: 1,
client: defaultClient, client: defaultClient,
} }
for _, o := range opts { for _, o := range opts {
o(&options) o(&timingOpts)
} }
return &timing{ return &timing{
name: name, name: name,
opts: options, opts: timingOpts,
} }
} }
@ -39,5 +39,5 @@ func (d *timing) With(values ...string) metrics.Observer {
} }
func (d *timing) Observe(value float64) { 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)
} }

@ -1,4 +1,3 @@
./contrib/metrics/datadog
./contrib/config/nacos ./contrib/config/nacos
./contrib/config/apollo ./contrib/config/apollo
./contrib/config/kubernetes ./contrib/config/kubernetes

Loading…
Cancel
Save