示例#1
0
func reportCollector(collector collector.Collector) {
	log.Warn(fmt.Sprintf("%s collector took too long to run, reporting incident!", collector.Name()))
	metric := metric.New("fullerite.collection_time_exceeded")
	metric.Value = 1
	metric.AddDimension("interval", fmt.Sprintf("%d", collector.Interval()))
	collector.Channel() <- metric
}
示例#2
0
// Collect produces some random test metrics.
func (t Test) Collect() {
	metric := metric.New(t.metricName)
	metric.Value = rand.Float64()
	metric.AddDimension("testing", "yes")
	t.Channel() <- metric
	t.log.Debug(metric)
}
示例#3
0
// Collect produces some random test metrics.
func (t Test) Collect() {
	metric := metric.New(t.metricName)
	metric.Value = t.generator()
	metric.AddDimension("testing", "yes")
	time.Sleep(3 * time.Second)
	t.Channel() <- metric
	t.log.Debug(metric)
}
示例#4
0
func readFromCollector(collector collector.Collector, metrics chan metric.Metric) {
	for metric := range collector.Channel() {
		if _, exists := metric.GetDimensionValue("collector"); !exists {
			metric.AddDimension("collector", collector.Name())
		}
		metrics <- metric
	}
}
示例#5
0
func (hook *LogErrorHook) reportErrors(entry *logrus.Entry) {
	metric := metric.New("fullerite.collector_errors")
	metric.Value = 1
	if val, exists := entry.Data["collector"]; exists {
		metric.AddDimension("collector", val.(string))
	}
	hook.metricsChannel <- metric
	return
}
示例#6
0
// Collect Emits the no of CPUs and ModelName
func (c CPUInfo) Collect() {
	value, model, err := c.getCPUInfo()
	if err != nil {
		c.log.Error("Error while collecting metrics: ", err)
		return
	}
	metric := metric.New(c.metricName)
	metric.Value = value
	metric.AddDimension("model", model)
	c.Channel() <- metric
	c.log.Debug(metric)
}
示例#7
0
func (d *Diamond) parseMetrics(line []byte) ([]metric.Metric, bool) {
	var metrics []metric.Metric
	if err := json.Unmarshal(line, &metrics); err != nil {
		d.log.Error("Cannot unmarshal metric line from diamond:", line)
		return metrics, false
	}
	// All diamond metric_types are reported in uppercase, lets make them
	// fullerite compatible
	for _, metric := range metrics {
		metric.MetricType = strings.ToLower(metric.MetricType)
		metric.AddDimension("diamond", "yes")
	}
	return metrics, true
}
示例#8
0
func readFromCollector(collector collector.Collector, handlers []handler.Handler) {
	for metric := range collector.Channel() {
		var exists bool
		c := collector.CanonicalName()
		if _, exists = metric.GetDimensionValue("collector"); !exists {
			metric.AddDimension("collector", collector.Name())
		}
		// We allow external collectors to provide us their collector's CanonicalName
		// by sending it as a metric dimension. For example in the case of Diamond the
		// individual python collectors can send their names this way.
		if val, ok := metric.GetDimensionValue("collectorCanonicalName"); ok {
			c = val
			metric.RemoveDimension("collectorCanonicalName")
		}

		for i := range handlers {
			if _, exists := handlers[i].CollectorChannels()[c]; exists {
				handlers[i].CollectorChannels()[c] <- metric
			}
		}
	}
}
示例#9
0
func readFromCollector(collector collector.Collector, metrics chan metric.Metric) {
	for metric := range collector.Channel() {
		metric.AddDimension("collector", collector.Name())
		metrics <- metric
	}
}
示例#10
0
// Collect produces some random test metrics.
func (t Test) Collect() {
	metric := metric.New("TestMetric")
	metric.Value = rand.Float64()
	metric.AddDimension("testing", "yes")
	t.Channel() <- metric
}