// AddMetric will add a new metric to the current registry
AddMetric will add a new metric to the current registry
// AddMetric will add a new metric to the current registry
func (r *PCPRegistry) AddMetric(m Metric) error {
	if r.mapped {
		return errors.New("cannot add a metric when a mapping is active")
	}
	if r.HasMetric(m.Name()) {
		return errors.New("metric is already defined for the current registry")
	}
	pcpm := m.(PCPMetric)
	if pcpm.Indom() != nil && !r.HasInstanceDomain(pcpm.Indom().Name()) {
		err := r.AddInstanceDomain(pcpm.Indom())
		if err != nil {
			return err
		}
	}
	r.metricslock.Lock()
	defer r.metricslock.Unlock()
	r.addMetric(pcpm)
	return nil
}
func ( r * PCPRegistry ) AddMetric ( m Metric ) error { if r . mapped { return errors . New ( " " ) } if r . HasMetric ( m . Name ( ) ) { return errors . New ( " " ) } pcpm := m . ( PCPMetric ) if pcpm . Indom ( ) != nil && ! r . HasInstanceDomain ( pcpm . Indom ( ) . Name ( ) ) { err := r . AddInstanceDomain ( pcpm . Indom ( ) ) if err != nil { return err } } r . metricslock . Lock ( ) defer r . metricslock . Unlock ( ) r . addMetric ( pcpm ) return nil }
AddMetric will add a new metric to the current registry
AddMetric will add a new metric to the current registry
// if it is an indom metric