// Collect implements Collector.
346021
func (c *timingsCollector) Collect(ch chan<- prometheus.Metric) {
	for cat, his := range c.t.Histograms() {
		ch <- prometheus.MustNewConstHistogram(
			c.desc,
			uint64(his.Count()),
			float64(his.Total())/1000000000,
			makeCumulativeBuckets(c.cutoffs, his.Buckets()),
			cat)
	}
}
975231
func (kvw *Writer) Collect(key, val sophie.SophieWriter) error {
	// write key
	kvw.objBuf.Reset()
	key.WriteTo(&kvw.objBuf)
	if err := sophie.VInt(len(kvw.objBuf)).WriteTo(kvw.writer); err != nil {
		return err
	}
	if _, err := kvw.writer.Write([]byte(kvw.objBuf)); err != nil {
		return err
	}
	// write val
	kvw.objBuf.Reset()
	val.WriteTo(&kvw.objBuf)
	if err := sophie.VInt(len(kvw.objBuf)).WriteTo(kvw.writer); err != nil {
		return err
	}
	if _, err := kvw.writer.Write([]byte(kvw.objBuf)); err != nil {
		return err
	}
	// success
	return nil
}
894963
func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
	e.mutex.Lock() // To protect metrics from concurrent collects.
	defer e.mutex.Unlock()

	up := e.scrape(ch)

	ch <- prometheus.MustNewConstMetric(haproxyUp, prometheus.GaugeValue, up)
	ch <- e.totalScrapes
	ch <- e.csvParseFailures
}
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)
}
189506
func (h *StatsHandler) Collect(in chan<- prometheus.Metric) {
	for _, c := range h.handlers {
		c.Collect(in)
	}
}
508029
func (b BufferedLogWriterMetrics) Collect(ch chan<- prometheus.Metric) {
	stats := b.Stats()
	ch <- prometheus.MustNewConstMetric(
		jujuLogsenderCapacityDesc,
		prometheus.CounterValue,
		float64(b.Capacity()),
	)
	ch <- prometheus.MustNewConstMetric(
		jujuLogsenderEnqueuedTotalDesc,
		prometheus.CounterValue,
		float64(stats.Enqueued),
	)
	ch <- prometheus.MustNewConstMetric(
		jujuLogsenderSentTotalDesc,
		prometheus.CounterValue,
		float64(stats.Sent),
	)
	ch <- prometheus.MustNewConstMetric(
		jujuLogsenderDroppedTotalDesc,
		prometheus.CounterValue,
		float64(stats.Dropped),
	)
}
1063231
func (m *ClientMetrics) Collect(ch chan<- prom.Metric) {
	m.clientStartedCounter.Collect(ch)
	m.clientHandledCounter.Collect(ch)
	m.clientStreamMsgReceived.Collect(ch)
	m.clientStreamMsgSent.Collect(ch)
	if m.clientHandledHistogramEnabled {
		m.clientHandledHistogram.Collect(ch)
	}
	if m.clientStreamRecvHistogramEnabled {
		m.clientStreamRecvHistogram.Collect(ch)
	}
	if m.clientStreamSendHistogramEnabled {
		m.clientStreamSendHistogram.Collect(ch)
	}
}
540783
func (c *influxCollector) Collect(ch chan<- prometheus.Metric) {
	ch <- prometheus.MustNewConstMetric(c.influxInfoDesc, prometheus.GaugeValue, 1)

	uptime := time.Since(c.start).Seconds()
	ch <- prometheus.MustNewConstMetric(c.influxUptimeDesc, prometheus.GaugeValue, float64(uptime))
}
1327715
func (c *metricsFuncWithMultiLabelsCollector) Collect(ch chan<- prometheus.Metric) {
	for lvs, val := range c.cfml.Counts() {
		labelValues := strings.Split(lvs, ".")
		value := float64(val)
		ch <- prometheus.MustNewConstMetric(c.desc, c.vt, value, labelValues...)
	}
}
719284
func (a *AllocGarbageCollector) Collect(allocID string) bool {
	gcAlloc := a.allocRunners.Remove(allocID)
	if gcAlloc == nil {
		a.logger.Debug("alloc was already garbage collected", "alloc_id", allocID)
		return false
	}

	a.destroyAllocRunner(allocID, gcAlloc.allocRunner, "forced collection")
	return true
}
863093
func (p *promProducer) Collect(ch chan<- prometheus.Metric) {
	for name, datapointsLabels := range datapointLabelsByName(p.store) {
		variableLabels := getLabelNames(datapointsLabels)
		desc := prometheus.NewDesc(sanitize(name), "DC/OS Metrics Datapoint", sanitizeSlice(variableLabels), nil)

		// Publish a metric for each datapoint.
		for _, dpLabels := range datapointsLabels {
			// Collect this datapoint's variable label values.
			var variableLabelVals []string
			for _, labelName := range variableLabels {
				if val, ok := dpLabels.labels[labelName]; ok {
					variableLabelVals = append(variableLabelVals, val)
				} else {
					variableLabelVals = append(variableLabelVals, "")
				}
			}

			val, err := coerceToFloat(dpLabels.datapoint.Value)
			if err != nil {
				promLog.Debugf("Bad datapoint value %q: (%s) %s", dpLabels.datapoint.Value, dpLabels.datapoint.Name, err)
				continue
			}

			metric, err := prometheus.NewConstMetric(desc, prometheus.GaugeValue, val, variableLabelVals...)
			if err != nil {
				promLog.Warnf("Could not create Prometheus metric %s: %s", name, err)
				continue
			}

			promLog.Debugf("Emitting datapoint %s", name)
			ch <- metric
		}
	}
}
682801
func (s *Store) Collect(ch chan<- prometheus.Metric) {
	s.metrics.Collect(ch)
}
422634
func (c *DialCollector) Collect(ch chan<- prometheus.Metric) {
	c.dialsTotal.Collect(ch)
	c.dialDuration.Collect(ch)
}
300179
func (m *monitor) Collect(in chan<- prometheus.Metric) {
	// Gauge
	m.connections.Collect(in)
	m.requests.Collect(in)

	// HistogramVec
	m.requestDuration.Collect(in)

	// CounterVec
	m.requestsTotal.Collect(in)
	m.messagesReceived.Collect(in)
	m.messagesSend.Collect(in)
	m.errors.Collect(in)
}
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()
}
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)
}