diff --git a/metric/metric.go b/metric/metric.go index dc5c154..51670a1 100644 --- a/metric/metric.go +++ b/metric/metric.go @@ -20,6 +20,9 @@ func Count(name string, value int64, tag map[string]string) { } func Duration(name string, costMs int64, tag map[string]string) { + if serv == nil { + return + } serv.add(&metric{ Type: TypeDuration, Metric: name, diff --git a/metric/service.go b/metric/service.go index 94acf45..8d24e3b 100644 --- a/metric/service.go +++ b/metric/service.go @@ -130,8 +130,7 @@ func (s *service) report() { bp.Database = s.config.Database bp.Tags = s.defaultTags() - _, err := s.client.Write(bp) - fmt.Println(err) + s.client.Write(bp) s.megers = nil }