func NewPrometheus(cfg PrometheusCfg, reg prometheus.Registerer, logger log.Logger) Output {
	cfg.Validate()
	p := &prometheusOutput{
		cfg:          cfg,
		metricValues: map[string]*metricValue{},
		reg:          reg,
		logger:       logger,
	}
	p.reg.MustRegister(p)
	return p
}
NewPrometheus returns a new Prometheus output.
package output
import (
	"fmt"
	"sync"
	"time"
	"github.com/prometheus/client_golang/prometheus"
	monitoringv1alpha1 "github.com/spotahome/service-level-operator/pkg/apis/monitoring/v1alpha1"
	"github.com/spotahome/service-level-operator/pkg/log"
	"github.com/spotahome/service-level-operator/pkg/service/sli"
)
const (
	promNS            = "service_level"
	promSLOSubsystem  = "slo"
	promSLISubsystem  = "sli"
	defExpireDuration = 90 * time.Second
)
type metricValue struct {
	serviceLevel *monitoringv1alpha1.ServiceLevel
	slo          *monitoringv1alpha1.SLO
	errorSum     float64
	countSum     float64
	objective    float64
	expire       time.Time  
}
type PrometheusCfg struct {
	ExpireDuration time.Duration
}
func (p *PrometheusCfg) Validate() {
	if p.ExpireDuration == 0 {
		p.ExpireDuration = defExpireDuration
	}
}
type prometheusOutput struct {
	cfg            PrometheusCfg
	metricValuesMu sync.Mutex
	metricValues   map[string]*metricValue
	reg            prometheus.Registerer
	logger         log.Logger
}