// Collect implements the prometheus.Collector interface.
487737
func (c *totalVolumesCollector) Collect(ch chan<- prometheus.Metric) {
	for stateName, pluginCount := range c.getVolumeCount() {
		for pluginName, count := range pluginCount {
			metric, err := prometheus.NewConstMetric(totalVolumesDesc,
				prometheus.GaugeValue,
				float64(count),
				pluginName,
				stateName)
			if err != nil {
				klog.Warningf("Failed to create metric : %v", err)
			}
			ch <- metric
		}
	}
}
118589
func (a *Group) Collect(waitables ...Waitable) {
	a.Lock()
	a.waitables = append(a.waitables, waitables...)
	a.Unlock()
}
538346
func (c *Collector) Collect(ch chan<- prometheus.Metric) {
	c.TotalConnections.Collect(ch)
	c.APIConnections.Collect(ch)
	c.LoginAttempts.Collect(ch)
	c.APIRequestDuration.Collect(ch)
	c.PingFailureCount.Collect(ch)
	c.LogWriteCount.Collect(ch)
	c.LogReadCount.Collect(ch)

	// TODO (stickupkid): remove post 2.6 release
	c.DeprecatedAPIConnections.Collect(ch)
	c.DeprecatedAPIRequestsTotal.Collect(ch)
	c.DeprecatedAPIRequestDuration.Collect(ch)
}
1369046
func (c *TxnCollector) Collect(ch chan<- prometheus.Metric) {
	c.txnOpsTotalCounter.Collect(ch)
}
821255
func (i *Interceptor) Collect(in chan<- prometheus.Metric) {
	i.monitoring.dialer.Collect(in)
	i.monitoring.server.Collect(in)
	i.monitoring.client.Collect(in)
}
1088761
func (c *minioCollector) Collect(ch chan<- prometheus.Metric) {

	// Always expose network stats

	// Network Sent/Received Bytes
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName("minio", "network", "sent_bytes_total"),
			"Total number of bytes sent by current MinIO server instance",
			nil, nil),
		prometheus.CounterValue,
		float64(globalConnStats.getTotalOutputBytes()),
	)
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName("minio", "network", "received_bytes_total"),
			"Total number of bytes received by current MinIO server instance",
			nil, nil),
		prometheus.CounterValue,
		float64(globalConnStats.getTotalInputBytes()),
	)

	// Expose cache stats only if available
	cacheObjLayer := newCacheObjectsFn()
	if cacheObjLayer != nil {
		cs := cacheObjLayer.StorageInfo(context.Background())
		ch <- prometheus.MustNewConstMetric(
			prometheus.NewDesc(
				prometheus.BuildFQName("minio", "disk", "cache_storage_bytes"),
				"Total cache capacity on current MinIO server instance",
				nil, nil),
			prometheus.GaugeValue,
			float64(cs.Total),
		)
		ch <- prometheus.MustNewConstMetric(
			prometheus.NewDesc(
				prometheus.BuildFQName("minio", "disk", "cache_storage_free_bytes"),
				"Total cache available on current MinIO server instance",
				nil, nil),
			prometheus.GaugeValue,
			float64(cs.Free),
		)
	}

	// Expose disk stats only if applicable

	// Fetch disk space info
	objLayer := newObjectLayerFn()
	// Service not initialized yet
	if objLayer == nil {
		return
	}

	s := objLayer.StorageInfo(context.Background())

	// Gateways don't provide disk info
	if s.Backend.Type == Unknown {
		return
	}

	var totalDisks, offlineDisks int
	// Setting totalDisks to 1 and offlineDisks to 0 in FS mode
	if s.Backend.Type == BackendFS {
		totalDisks = 1
		offlineDisks = 0
	} else {
		offlineDisks = s.Backend.OfflineDisks
		totalDisks = s.Backend.OfflineDisks + s.Backend.OnlineDisks
	}

	// Total disk usage by current MinIO server instance
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName("minio", "disk", "storage_used_bytes"),
			"Total disk storage used by current MinIO server instance",
			nil, nil),
		prometheus.GaugeValue,
		float64(s.Used),
	)

	// Total disk available space seen by MinIO server instance
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName("minio", "disk", "storage_available_bytes"),
			"Total disk available space seen by MinIO server instance",
			nil, nil),
		prometheus.GaugeValue,
		float64(s.Available),
	)

	// Total disk space seen by MinIO server instance
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName("minio", "disk", "storage_total_bytes"),
			"Total disk space seen by MinIO server instance",
			nil, nil),
		prometheus.GaugeValue,
		float64(s.Total),
	)

	// MinIO Total Disk/Offline Disk
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName("minio", "total", "disks"),
			"Total number of disks for current MinIO server instance",
			nil, nil),
		prometheus.GaugeValue,
		float64(totalDisks),
	)
	ch <- prometheus.MustNewConstMetric(
		prometheus.NewDesc(
			prometheus.BuildFQName("minio", "offline", "disks"),
			"Total number of offline disks for current MinIO server instance",
			nil, nil),
		prometheus.GaugeValue,
		float64(offlineDisks),
	)
}
1293932
func (m *Metrics) Collect() (a map[string]AggregatedMetrics) {
	a = make(map[string]AggregatedMetrics)

	for _, fnName := range m.FunctionNames {
		metric := Metric{
			Config:       m.Config,
			FunctionName: fnName,
		}

		a[fnName] = metric.Collect()
	}

	return
}
432889
func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
	// Scrape the Data
	var err = e.gatherData()
	if err != nil {
		return
	}
	// Set prometheus gauge metrics using the data gathered
	ch <- prometheus.MustNewConstMetric(
		Height,
		prometheus.CounterValue,
		e.datum.LatestBlockHeight,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstMetric(
		UnconfirmedTransactions,
		prometheus.GaugeValue,
		e.datum.UnconfirmedTxs,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstMetric(
		TotalPeers,
		prometheus.GaugeValue,
		e.datum.TotalPeers,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstMetric(
		InboundPeers,
		prometheus.GaugeValue,
		e.datum.InboundPeers,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstMetric(
		OutboundPeers,
		prometheus.GaugeValue,
		e.datum.OutboundPeers,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstHistogram(
		TxPerBlock,
		e.datum.BlockSampleSize,
		e.datum.TotalTxs,
		e.datum.TxPerBlockBuckets,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstHistogram(
		TimePerBlock,
		// Duration between each block in sample
		e.datum.BlockSampleSize-1,
		e.datum.TotalTime,
		e.datum.TimePerBlockBuckets,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstMetric(
		Contracts,
		prometheus.GaugeValue,
		e.datum.AccountsWithCode,
		e.chainID,
		e.validatorMoniker,
	)
	ch <- prometheus.MustNewConstMetric(
		Users,
		prometheus.GaugeValue,
		e.datum.AccountsWithoutCode,
		e.chainID,
		e.validatorMoniker,
	)

	e.logger.InfoMsg("All Metrics successfully collected")
}
1239887
func (g *GoMetrics) Collect() {
	now := time.Now()

	lastTotalAlloc := g.ms.TotalAlloc
	lastLookups := g.ms.Lookups
	lastMallocs := g.ms.Mallocs
	lastFrees := g.ms.Frees
	lastHeapRealeased := g.ms.HeapReleased
	lastNumGC := g.ms.NumGC
	lastNumCgoCall := g.runtime.lastNumCgoCall
	g.runtime.lastNumCgoCall = int(runtime.NumCgoCall())

	g.runtime.numCPU = runtime.NumCPU()
	g.runtime.numGoroutine = runtime.NumGoroutine()
	g.runtime.numCgoCall = g.runtime.lastNumCgoCall - lastNumCgoCall

	pauses := collectMemoryStats(&g.ms, lastNumGC)

	g.memstats.total.alloc = g.ms.Alloc
	g.memstats.total.totalAlloc = g.ms.TotalAlloc - lastTotalAlloc
	g.memstats.total.lookups = g.ms.Lookups - lastLookups
	g.memstats.total.mallocs = g.ms.Mallocs - lastMallocs
	g.memstats.total.frees = g.ms.Frees - lastFrees

	g.memstats.heap.alloc = g.ms.HeapAlloc
	g.memstats.heap.sys = g.ms.HeapSys
	g.memstats.heap.idle = g.ms.HeapIdle
	g.memstats.heap.inuse = g.ms.HeapInuse
	g.memstats.heap.released = g.ms.HeapReleased - lastHeapRealeased
	g.memstats.heap.objects = g.ms.HeapObjects

	g.memstats.stack.inuse = g.ms.StackInuse
	g.memstats.stack.sys = g.ms.StackSys
	g.memstats.mspan.inuse = g.ms.MSpanInuse
	g.memstats.mspan.sys = g.ms.MSpanSys
	g.memstats.mcache.inuse = g.ms.MCacheInuse
	g.memstats.mcache.sys = g.ms.MCacheSys
	g.memstats.buckhash.sys = g.ms.BuckHashSys
	g.memstats.gc.sys = g.ms.GCSys
	g.memstats.other.sys = g.ms.OtherSys

	g.memstats.numGC = g.ms.NumGC - lastNumGC
	g.memstats.nextGC = g.ms.NextGC
	g.memstats.gcCPUFraction = g.ms.GCCPUFraction

	if len(pauses) == 0 {
		g.memstats.gcPauseAvg = 0
		g.memstats.gcPauseMin = 0
		g.memstats.gcPauseMax = 0
	} else {
		g.memstats.gcPauseMin = pauses[0]
		g.memstats.gcPauseMax = pauses[0]
		g.memstats.gcPauseAvg = pauses[0]

		for _, pause := range pauses[1:] {
			g.memstats.gcPauseAvg += pause
			switch {
			case pause < g.memstats.gcPauseMin:
				g.memstats.gcPauseMin = pause
			case pause > g.memstats.gcPauseMax:
				g.memstats.gcPauseMax = pause
			}
		}

		g.memstats.gcPauseAvg /= time.Duration(len(pauses))
	}

	g.engine.ReportAt(now, g)
}
1217476
func (m *cacheMetrics) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		m.MemSize,
		m.DiskSize,
		m.SnapshotsActive,
		m.Age,
		m.SnapshottedBytes,
		m.WrittenBytes,
		m.Writes,
	}
}
1210211
func PrometheusCollectors() []prometheus.Collector {
	mmu.RLock()
	defer mmu.RUnlock()

	var collectors []prometheus.Collector
	if wms != nil {
		collectors = append(collectors, wms.PrometheusCollectors()...)
	}

	return collectors
}
1180129
func (c *MgoStatsCollector) Collect(ch chan<- prometheus.Metric) {
	stats, prevStats := c.getStats()

	c.clustersGauge.Set(float64(stats.Clusters))
	c.masterConnsGauge.Set(float64(stats.MasterConns))
	c.slaveConnsGauge.Set(float64(stats.SlaveConns))
	if n := stats.SentOps - prevStats.SentOps; n > 0 {
		c.sentOpsCounter.Add(float64(n))
	}
	if n := stats.ReceivedOps - prevStats.ReceivedOps; n > 0 {
		c.receivedOpsCounter.Add(float64(n))
	}
	if n := stats.ReceivedDocs - prevStats.ReceivedDocs; n > 0 {
		c.receivedDocsCounter.Add(float64(n))
	}
	c.socketsAliveGauge.Set(float64(stats.SocketsAlive))
	c.socketsInuseGauge.Set(float64(stats.SocketsInUse))
	c.socketRefsGauge.Set(float64(stats.SocketRefs))

	c.clustersGauge.Collect(ch)
	c.masterConnsGauge.Collect(ch)
	c.slaveConnsGauge.Collect(ch)
	c.sentOpsCounter.Collect(ch)
	c.receivedOpsCounter.Collect(ch)
	c.receivedDocsCounter.Collect(ch)
	c.socketsAliveGauge.Collect(ch)
	c.socketsInuseGauge.Collect(ch)
	c.socketRefsGauge.Collect(ch)
}
1316425
func (c *Chan) Collect() []Path {
	acc := make([]Path, 0, 0)
	c.Do(func(ts Path) {
		acc = append(acc, ts)
	})
	return acc
}
751028
func (collector *procTableCollector) Collect(ch chan<- prometheus.Metric) {
	stats := collector.procTable.Stats()
	addGauge := func(desc *prometheus.Desc, v float64, lv ...string) {
		ch <- prometheus.MustNewConstMetric(desc, prometheus.GaugeValue, v, lv...)
	}
	addGauge(procTableRunning, float64(stats.Running))
	addGauge(procTableSucceeded, float64(stats.Succeeded))
	addGauge(procTableFailed, float64(stats.Failed))
}
1221600
func (ppl *Pipeline) Collect() ([]*ResultSet, error) {
	defer func() {
		ppl.resp = nil
	}()
	err := ppl.ensureProtocol()
	if err != nil {
		return nil, err
	}
	results := []*ResultSet{}
	for i := ppl.counter; i > 0; i-- {
		result, err := ppl.resp.receiveResultSet()
		if err != nil {
			ppl.database.pool.kill(ppl.resp)
			return nil, err
		}
		results = append(results, result)
	}
	ppl.database.pool.push(ppl.resp)
	return results, nil
}
759018
func (c *metricsCollector) Collect(ch chan<- prometheus.Metric) {
	c.requests.Collect(ch)
}
512106
func (src List) collect(f func(*Tools) string) []string {
	seen := make(set.Strings)
	for _, tools := range src {
		seen.Add(f(tools))
	}
	return seen.SortedValues()
}