func GetOrCreateCounter(name string) *Counter {
	metricsMapLock.Lock()
	nm := metricsMap[name]
	metricsMapLock.Unlock()
	if nm == nil {
		// Slow path - create and register missing counter.
		if err := validateMetric(name); err != nil {
			panic(fmt.Errorf("BUG: invalid metric name %q: %s", name, err))
		}
		nmNew := &namedMetric{
			name:   name,
			metric: &Counter{},
		}
		metricsMapLock.Lock()
		nm = metricsMap[name]
		if nm == nil {
			nm = nmNew
			metricsMap[name] = nm
			metricsList = append(metricsList, nm)
		}
		metricsMapLock.Unlock()
	}
	c, ok := nm.metric.(*Counter)
	if !ok {
		panic(fmt.Errorf("BUG: metric %q isn't a Counter. It is %T", name, nm.metric))
	}
	return c
}
// GetOrCreateCounter returns registered counter with the given name
// or creates new counter if the registry doesn't contain counter with
// the given name.
//
// name must be valid Prometheus-compatible metric with possible lables.
// For instance,
//
//     * foo
//     * foo{bar="baz"}
//     * foo{bar="baz",aaa="b"}
//
// The returned counter is safe to use from concurrent goroutines.
//
// Performance tip: prefer NewCounter instead of GetOrCreateCounter.
GetOrCreateCounter returns registered counter with the given name
or creates new counter if the registry doesn't contain counter with
the given name.

name must be valid Prometheus-compatible metric with possible lables.
For instance.



The returned counter is safe to use from concurrent goroutines.

Performance tip: prefer NewCounter instead of GetOrCreateCounter.
// GetOrCreateCounter returns registered counter with the given name // or creates new counter if the registry doesn ' t contain counter with // the given name . // // name must be valid Prometheus - compatible metric with possible lables . // For instance // // * foo // * foo { bar = " baz " } // * foo { bar = " baz " aaa = " b " } // // The returned counter is safe to use from concurrent goroutines . // // Performance tip : prefer NewCounter instead of GetOrCreateCounter .
func GetOrCreateCounter(name string) *Counter {
	metricsMapLock.Lock()
	nm := metricsMap[name]
	metricsMapLock.Unlock()
	if nm == nil {
		if err := validateMetric(name); err != nil {
			panic(fmt.Errorf("BUG: invalid metric name %q: %s", name, err))
		}
		nmNew := &namedMetric{
			name:   name,
			metric: &Counter{},
		}
		metricsMapLock.Lock()
		nm = metricsMap[name]
		if nm == nil {
			nm = nmNew
			metricsMap[name] = nm
			metricsList = append(metricsList, nm)
		}
		metricsMapLock.Unlock()
	}
	c, ok := nm.metric.(*Counter)
	if !ok {
		panic(fmt.Errorf("BUG: metric %q isn't a Counter. It is %T", name, nm.metric))
	}
	return c
}
func GetOrCreateCounter ( name string ) * Counter { metricsMapLock . Lock ( ) nm := metricsMap [ name ] metricsMapLock . Unlock ( ) if nm == nil { if err := validateMetric ( name ) ; err != nil { panic ( fmt . Errorf ( " " , name , err ) ) } nmNew := & namedMetric { name : name , metric : & Counter { } , } metricsMapLock . Lock ( ) nm = metricsMap [ name ] if nm == nil { nm = nmNew metricsMap [ name ] = nm metricsList = append ( metricsList , nm ) } metricsMapLock . Unlock ( ) } c , ok := nm . metric . ( * Counter ) if ! ok { panic ( fmt . Errorf ( " " , name , nm . metric ) ) } return c }
GetOrCreateCounter returns registered counter with the given name
or creates new counter if the registry doesn't contain counter with
the given name.
GetOrCreateCounter returns registered counter with the given name or creates new counter if the registry doesn ' t contain counter with the given name .
// Slow path - create and register missing counter.