update nameMetric
This commit is contained in:
parent
8466104303
commit
8969e845c9
@ -173,7 +173,10 @@ func NewHistogramByVM(name string) *Histogram {
|
|||||||
//
|
//
|
||||||
// Performance tip: prefer NewHistogram instead of GetOrCreateHistogram.
|
// Performance tip: prefer NewHistogram instead of GetOrCreateHistogram.
|
||||||
func GetOrCreateHistogram(name string) *Histogram {
|
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.
|
// UpdateDuration updates request duration based on the given startTime.
|
||||||
|
4
push.go
4
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))
|
pushesTotal := pushMetrics.GetOrCreateCounter(fmt.Sprintf(`metrics_push_total{url=%q}`, pushURLRedacted))
|
||||||
pushErrorsTotal := pushMetrics.GetOrCreateCounter(fmt.Sprintf(`metrics_push_errors_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))
|
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))
|
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))
|
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())
|
pushMetrics.GetOrCreateFloatCounter(fmt.Sprintf(`metrics_push_interval_seconds{url=%q}`, pushURLRedacted)).Set(interval.Seconds())
|
||||||
go func() {
|
go func() {
|
||||||
ticker := time.NewTicker(interval)
|
ticker := time.NewTicker(interval)
|
||||||
|
4
set.go
4
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.
|
// The returned histogram is safe to use from concurrent goroutines.
|
||||||
//
|
//
|
||||||
// Performance tip: prefer NewHistogram instead of GetOrCreateHistogram.
|
// 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()
|
s.mu.Lock()
|
||||||
nm := s.m[name]
|
nm := s.m[name]
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
@ -95,7 +95,7 @@ func (s *Set) GetOrCreateHistogram(name string) *Histogram {
|
|||||||
}
|
}
|
||||||
nmNew := &namedMetric{
|
nmNew := &namedMetric{
|
||||||
name: name,
|
name: name,
|
||||||
metric: &Histogram{},
|
metric: &Histogram{compatible: compatible},
|
||||||
}
|
}
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
nm = s.m[name]
|
nm = s.m[name]
|
||||||
|
Loading…
Reference in New Issue
Block a user