// NewMetrics returns a pointer to an initialized Metrics structure.
344988
func NewMetrics() *Metrics {
	m := &Metrics{
		TimeMetrics:   make(map[string]*TimeStats),
		NumberMetrics: make(map[string]*NumberStats),
		BoolMetrics:   make(map[string]*BoolStats),
	}
	return m
}
1154591
func (sdk *FabricSDK) initMetrics(configs *configs) {
	if configs == nil {
		return
	}
	if sdk.system == nil {
		sdk.system = newOperationsSystem(configs)

		err := sdk.system.Start()
		if err != nil {
			panic("metrics failed to start: " + err.Error())
		}

		// for now NewClientMetrics supports channel client. TODO: if other client types require metrics tracking, update this function
		sdk.clientMetrics = metrics.NewClientMetrics(sdk.system.Provider)
	}
}
933811
func (md *metricsDu) GetMetrics() (*Metrics, error) {
	metrics := &Metrics{Time: metav1.Now()}
	if md.path == "" {
		return metrics, NewNoPathDefinedError()
	}

	err := md.runDiskUsage(metrics)
	if err != nil {
		return metrics, err
	}

	err = md.runFind(metrics)
	if err != nil {
		return metrics, err
	}

	err = md.getFsInfo(metrics)
	if err != nil {
		return metrics, err
	}

	return metrics, nil
}
232768
func NewMetrics(provider MetricsProvider) *Metrics {
	return &Metrics{
		EgressQueueLength:        provider.NewGauge(EgressQueueLengthOpts),
		EgressQueueCapacity:      provider.NewGauge(EgressQueueCapacityOpts),
		EgressStreamsCount:       provider.NewGauge(EgressStreamsCountOpts),
		EgressTLSConnectionCount: provider.NewGauge(EgressTLSConnectionCountOpts),
		EgressWorkerCount:        provider.NewGauge(EgressWorkersOpts),
		IngressStreamsCount:      provider.NewGauge(IngressStreamsCountOpts),
		MessagesDroppedCount:     provider.NewCounter(MessagesDroppedCountOpts),
		MessageSendTime:          provider.NewHistogram(MessageSendTimeOpts),
	}
}
1201150
func setupMetrics(c *caddy.Controller) error {
	c.OnStartup(func() error {
		metrics.MustRegister(c, templateMatchesCount, templateFailureCount, templateRRFailureCount)
		return nil
	})

	return nil
}
451048
func (s *Stackdriver) newListMetricDescriptorsFilters() []string {
	if len(s.MetricTypePrefixInclude) == 0 {
		return nil
	}

	metricTypeFilters := make([]string, len(s.MetricTypePrefixInclude))
	for i, metricTypePrefix := range s.MetricTypePrefixInclude {
		metricTypeFilters[i] = fmt.Sprintf(`metric.type = starts_with(%q)`, metricTypePrefix)
	}
	return metricTypeFilters
}
1255748
func NewMetricsClient(config *MetricsClientConfig) (Metrics, error) {
	// Use default implementation if no HawkularGetter is specified
	if config.HawkularGetter == nil {
		config.HawkularGetter = &defaultGetter{}
	}
	helper, err := config.GetHawkularRESTAPI(config)
	if err != nil {
		return nil, err
	}
	mc := &metricsClient{
		HawkularRESTAPI: helper,
	}

	return mc, nil
}
152669
func NewMetrics() *Metrics {
	return &Metrics{Status: StatusUp, Health: 1, Uptime: 0, lastTs: time.Now()}
}
779339
func newMetricsCollector() (prometheus.Collector, error) {
	sink, err := pmetrics.NewPrometheusSink()
	if err != nil {
		return nil, errors.Trace(err)
	}
	// go-metrics always registers the sink it returns in the default
	// registry, which we don't collect metrics from - unregister it
	// so subsequent calls don't fail because it's already registered
	// there.
	prometheus.DefaultRegisterer.Unregister(sink)
	config := metrics.DefaultConfig("juju")
	config.EnableRuntimeMetrics = false
	_, err = metrics.NewGlobal(config, sink)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return sink, nil
}
809108
func (s *Event) SetMetrics(v map[string]*float64) *Event {
	s.Metrics = v
	return s
}
169691
func NewRTMetrics(settings ...rrOptSetter) (*RTMetrics, error) {
	m := &RTMetrics{
		statusCodes:     make(map[int]*RollingCounter),
		statusCodesLock: sync.RWMutex{},
	}
	for _, s := range settings {
		if err := s(m); err != nil {
			return nil, err
		}
	}

	if m.clock == nil {
		m.clock = &timetools.RealTime{}
	}

	if m.newCounter == nil {
		m.newCounter = func() (*RollingCounter, error) {
			return NewCounter(counterBuckets, counterResolution, CounterClock(m.clock))
		}
	}

	if m.newHist == nil {
		m.newHist = func() (*RollingHDRHistogram, error) {
			return NewRollingHDRHistogram(histMin, histMax, histSignificantFigures, histPeriod, histBuckets, RollingClock(m.clock))
		}
	}

	h, err := m.newHist()
	if err != nil {
		return nil, err
	}

	netErrors, err := m.newCounter()
	if err != nil {
		return nil, err
	}

	total, err := m.newCounter()
	if err != nil {
		return nil, err
	}

	m.histogram = h
	m.netErrors = netErrors
	m.total = total
	return m, nil
}
25189
func NewMetric(m *Metric, subsystem string) prometheus.Collector {
	var metric prometheus.Collector
	switch m.Type {
	case "counter_vec":
		metric = prometheus.NewCounterVec(
			prometheus.CounterOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
			m.Args,
		)
	case "counter":
		metric = prometheus.NewCounter(
			prometheus.CounterOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
		)
	case "gauge_vec":
		metric = prometheus.NewGaugeVec(
			prometheus.GaugeOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
			m.Args,
		)
	case "gauge":
		metric = prometheus.NewGauge(
			prometheus.GaugeOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
		)
	case "histogram_vec":
		metric = prometheus.NewHistogramVec(
			prometheus.HistogramOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
			m.Args,
		)
	case "histogram":
		metric = prometheus.NewHistogram(
			prometheus.HistogramOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
		)
	case "summary_vec":
		metric = prometheus.NewSummaryVec(
			prometheus.SummaryOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
			m.Args,
		)
	case "summary":
		metric = prometheus.NewSummary(
			prometheus.SummaryOpts{
				Subsystem: subsystem,
				Name:      m.Name,
				Help:      m.Description,
			},
		)
	}
	return metric
}
459628
func (s *EnableMetricsCollectionInput) SetMetrics(v []*string) *EnableMetricsCollectionInput {
	s.Metrics = v
	return s
}
680452
func ToCoreMetrics(mts []*Metric) []core.Metric {
	metrics := make([]core.Metric, len(mts))
	for i, mt := range mts {
		metrics[i] = ToCoreMetric(mt)
	}
	return metrics
}
76758
func (s *EventDimensions) SetMetrics(v map[string]*MetricDimension) *EventDimensions {
	s.Metrics = v
	return s
}
798999
func (s *ResponseResourceMetricKey) SetMetric(v string) *ResponseResourceMetricKey {
	s.Metric = &v
	return s
}
799945
func NewWorkerMetrics() WorkerMetrics {
	return WorkerMetrics{
		counters:          map[samplers.MetricKey]*samplers.Counter{},
		globalCounters:    map[samplers.MetricKey]*samplers.Counter{},
		globalGauges:      map[samplers.MetricKey]*samplers.Gauge{},
		globalHistograms:  map[samplers.MetricKey]*samplers.Histo{},
		globalTimers:      map[samplers.MetricKey]*samplers.Histo{},
		gauges:            map[samplers.MetricKey]*samplers.Gauge{},
		histograms:        map[samplers.MetricKey]*samplers.Histo{},
		sets:              map[samplers.MetricKey]*samplers.Set{},
		timers:            map[samplers.MetricKey]*samplers.Histo{},
		localHistograms:   map[samplers.MetricKey]*samplers.Histo{},
		localSets:         map[samplers.MetricKey]*samplers.Set{},
		localTimers:       map[samplers.MetricKey]*samplers.Histo{},
		localStatusChecks: map[samplers.MetricKey]*samplers.StatusCheck{},
	}
}