diff --git a/histogram.go b/histogram.go index c98eb39..e86c0c8 100644 --- a/histogram.go +++ b/histogram.go @@ -173,7 +173,10 @@ func NewHistogramByVM(name string) *Histogram { // // Performance tip: prefer NewHistogram instead of GetOrCreateHistogram. func GetOrCreateHistogram(name string) *Histogram { - return defaultSet.GetOrCreateHistogram(name) + return defaultSet.GetOrCreateHistogram(name, true) +} +func GetOrCreateHistogramByVM(name string) *Histogram { + return defaultSet.GetOrCreateHistogram(name, false) } // UpdateDuration updates request duration based on the given startTime. diff --git a/push.go b/push.go index 4215f48..f878408 100644 --- a/push.go +++ b/push.go @@ -115,8 +115,8 @@ func InitPushExt(pushURL string, interval time.Duration, extraLabels string, wri pushesTotal := pushMetrics.GetOrCreateCounter(fmt.Sprintf(`metrics_push_total{url=%q}`, pushURLRedacted)) pushErrorsTotal := pushMetrics.GetOrCreateCounter(fmt.Sprintf(`metrics_push_errors_total{url=%q}`, pushURLRedacted)) bytesPushedTotal := pushMetrics.GetOrCreateCounter(fmt.Sprintf(`metrics_push_bytes_pushed_total{url=%q}`, pushURLRedacted)) - pushDuration := pushMetrics.GetOrCreateHistogram(fmt.Sprintf(`metrics_push_duration_seconds{url=%q}`, pushURLRedacted)) - pushBlockSize := pushMetrics.GetOrCreateHistogram(fmt.Sprintf(`metrics_push_block_size_bytes{url=%q}`, pushURLRedacted)) + pushDuration := pushMetrics.GetOrCreateHistogram(fmt.Sprintf(`metrics_push_duration_seconds{url=%q}`, pushURLRedacted), false) + pushBlockSize := pushMetrics.GetOrCreateHistogram(fmt.Sprintf(`metrics_push_block_size_bytes{url=%q}`, pushURLRedacted), false) pushMetrics.GetOrCreateFloatCounter(fmt.Sprintf(`metrics_push_interval_seconds{url=%q}`, pushURLRedacted)).Set(interval.Seconds()) go func() { ticker := time.NewTicker(interval) diff --git a/set.go b/set.go index 43667be..6ecbfe2 100644 --- a/set.go +++ b/set.go @@ -84,7 +84,7 @@ func (s *Set) NewHistogram(name string, compatible bool) *Histogram { // The returned histogram is safe to use from concurrent goroutines. // // Performance tip: prefer NewHistogram instead of GetOrCreateHistogram. -func (s *Set) GetOrCreateHistogram(name string) *Histogram { +func (s *Set) GetOrCreateHistogram(name string, compatible bool) *Histogram { s.mu.Lock() nm := s.m[name] s.mu.Unlock() @@ -95,7 +95,7 @@ func (s *Set) GetOrCreateHistogram(name string) *Histogram { } nmNew := &namedMetric{ name: name, - metric: &Histogram{}, + metric: &Histogram{compatible: compatible}, } s.mu.Lock() nm = s.m[name]