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)
	}
}
NewCollector creates a Prometheus metric from a Metric descriptor.  The name must not be empty.
If not supplied in the metric, namespace, subsystem, and help all take on defaults.
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
}