示例#1
0
func (d *MongodbData) add(acc plugins.Accumulator, key string, val interface{}) {
	acc.AddFieldsWithTime(
		key,
		map[string]interface{}{
			"value": val,
		},
		d.Tags,
		d.StatLine.Time,
	)
}
示例#2
0
func emitMetrics(k *Kafka, acc plugins.Accumulator, metricConsumer <-chan []byte) error {
	timeout := time.After(1 * time.Second)

	for {
		select {
		case batch := <-metricConsumer:
			var points []tsdb.Point
			var err error
			if points, err = tsdb.ParsePoints(batch); err != nil {
				return err
			}

			for _, point := range points {
				acc.AddFieldsWithTime(point.Name(), point.Fields(), point.Tags(), point.Time())
			}
		case <-timeout:
			return nil
		}
	}
}