func (mr *Merger) DefaultSubsystem(v string) *Merger {
	if len(v) == 0 {
		mr.defaultSubsystem = DefaultSubsystem
	} else {
		mr.defaultSubsystem = v
	}
	return mr
}
DefaultSubsystem sets the default subsystem used for metrics that do not specify one.  This value applies
to all subsequent AddXXX calls, but does not affect any metrics already merged.  If the value is empty,
the global DefaultSubsystem constant is used.
package xmetrics
import (
	"errors"
	"fmt"
	"time"
	"github.com/go-kit/kit/log"
	"github.com/go-kit/kit/log/level"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/xmidt-org/webpa-common/v2/logging"
)
const (
	CounterType   = "counter"
	GaugeType     = "gauge"
	HistogramType = "histogram"
	SummaryType   = "summary"
)
type Module func() []Metric
type Metric struct {
	Name string
	Type string
	Namespace string
	Subsystem string
	Help string
	ConstLabels map[string]string
	LabelNames []string
	Buckets []float64
	Objectives map[float64]float64
	MaxAge time.Duration
	AgeBuckets uint32
	BufCap uint32
}
func NewCollector(m Metric) (prometheus.Collector, error) {
	if len(m.Name) == 0 {
		return nil, errors.New("A name is required for a metric")
	}
	var (
		namespace = m.Namespace
		subsystem = m.Subsystem
		help      = m.Help
	)
	if len(namespace) == 0 {
		namespace = DefaultNamespace
	}
	if len(subsystem) == 0 {
		subsystem = DefaultSubsystem
	}
	if len(help) == 0 {
		help = m.Name
	}
	switch m.Type {
	case CounterType:
		return prometheus.NewCounterVec(prometheus.CounterOpts{
			Namespace:   namespace,
			Subsystem:   subsystem,
			Name:        m.Name,
			Help:        help,
			ConstLabels: prometheus.Labels(m.ConstLabels),
		}, m.LabelNames), nil
	case GaugeType:
		return prometheus.NewGaugeVec(prometheus.GaugeOpts{
			Namespace:   namespace,
			Subsystem:   subsystem,
			Name:        m.Name,
			Help:        help,
			ConstLabels: prometheus.Labels(m.ConstLabels),
		}, m.LabelNames), nil
	case HistogramType:
		return prometheus.NewHistogramVec(prometheus.HistogramOpts{
			Namespace:   namespace,
			Subsystem:   subsystem,
			Name:        m.Name,
			Help:        help,
			Buckets:     m.Buckets,
			ConstLabels: prometheus.Labels(m.ConstLabels),
		}, m.LabelNames), nil
	case SummaryType:
		return prometheus.NewSummaryVec(prometheus.SummaryOpts{
			Namespace:   namespace,
			Subsystem:   subsystem,
			Name:        m.Name,
			Help:        help,
			Objectives:  m.Objectives,
			MaxAge:      m.MaxAge,
			AgeBuckets:  m.AgeBuckets,
			BufCap:      m.BufCap,
			ConstLabels: prometheus.Labels(m.ConstLabels),
		}, m.LabelNames), nil
	default:
		return nil, fmt.Errorf("Unsupported metric type: %s", m.Type)
	}
}
type Merger struct {
	logger           log.Logger
	defaultNamespace string
	defaultSubsystem string
	namer            func(string, string, string) string
	merged           map[string]Metric
	err              error
}
func NewMerger() *Merger {
	return &Merger{
		logger:           logging.DefaultLogger(),
		defaultNamespace: DefaultNamespace,
		defaultSubsystem: DefaultSubsystem,
		namer:            prometheus.BuildFQName,
		merged:           make(map[string]Metric),
	}
}
func (mr *Merger) Logger(logger log.Logger) *Merger {
	if logger != nil {
		mr.logger = logger
	} else {
		mr.logger = logging.DefaultLogger()
	}
	return mr
}
func (mr *Merger) Namer(f func(namespace, subsystem, name string) string) *Merger {
	if f == nil {
		mr.namer = prometheus.BuildFQName
	} else {
		mr.namer = f
	}
	return mr
}
func (mr *Merger) DefaultNamespace(v string) *Merger {
	if len(v) == 0 {
		mr.defaultNamespace = DefaultNamespace
	} else {
		mr.defaultNamespace = v
	}
	return mr
}