1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-19 21:18:07 +02:00

fix: contrib metrics datadog lint err ()

This commit is contained in:
倒霉狐狸 2021-09-27 19:58:50 +08:00 committed by GitHub
parent 7cc6565d01
commit bae20ba735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 14 deletions

@ -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)
}

@ -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) {

@ -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)
}

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