func (r *Registry) Register(c Collector) error {
	descChan := make(chan *Desc, r.opts.CapDescChan)
	go func() {
		c.Describe(descChan)
		close(descChan)
	}()
	r.mtx.Lock()
	defer func() {
		for range descChan {
		}
		r.mtx.Unlock()
	}()
	for desc := range descChan {
		if desc.err != nil {
			return desc.err
		}
		if _, ok := r.metadata[desc.fqName]; ok {
			return fmt.Errorf("duplicated mertric FQName:(%s)", desc.fqName)
		}
		r.metadata[desc.fqName] = &MetaData{
			Metric: desc.fqName,
			Help:   desc.help,
			Step:   desc.step,
		}
	}
	r.collectors = append(r.collectors, c)
	return nil
}
Register register a collector and handler all its `metrics desc`.
package aura
import (
	"fmt"
	"sync"
	"time"
)
const (
	defaultCapMetricChan = 2500
	defaultCapDescChan   = 20
)
type Reporter interface {
	Report(ch chan Metric)
}
type MetaData struct {
	Metric string `json:"metric"`
	Help   string `json:"help"`
	Step   uint32 `json:"step"`
}
type Registry struct {
	opts       *RegistryOpts
	reporter   Reporter
	mtx        sync.RWMutex
	collectors []Collector
	metricChs  chan Metric
	metadata   map[string]*MetaData
	stop       chan struct{}
	exit       chan struct{}
}
type RegistryOpts struct {
	CapMetricChan int
	CapDescChan   int
}
var DefaultRegistryOpts = &RegistryOpts{
	CapMetricChan: defaultCapMetricChan,
	CapDescChan:   defaultCapDescChan,
}
func NewRegistry(opts *RegistryOpts) *Registry {
	if opts == nil {
		opts = DefaultRegistryOpts
	}
	if opts.CapDescChan < 1 {
		opts.CapDescChan = defaultCapDescChan
	}
	if opts.CapMetricChan < 1 {
		opts.CapMetricChan = defaultCapMetricChan
	}
	return &Registry{
		opts:       opts,
		reporter:   nil,
		mtx:        sync.RWMutex{},
		collectors: []Collector{},
		metricChs:  make(chan Metric, opts.CapMetricChan),
		metadata:   map[string]*MetaData{},
		stop:       make(chan struct{}),
		exit:       make(chan struct{}),
	}
}
func (r *Registry) AddReporter(reporter Reporter) {
	r.reporter = reporter
}