mirror of
https://github.com/go-kratos/kratos.git
synced 2025-03-19 21:18:07 +02:00
fix: contrib metrics datadog lint err (#1517)
This commit is contained in:
parent
7cc6565d01
commit
bae20ba735
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user