Exemplo n.º 1
0
func sendOverviewStats(rabbit *rabbithole.Client, sink *sfxclient.HTTPDatapointSink, host string) {
	overview, err := rabbit.Overview()
	if err != nil {
		logger.ErrorD("overview-error", l.M{
			"error": err.Error(),
			"host":  host,
		})
		return
	}

	// collect and combine signalfx stats
	dimensions := map[string]string{
		"Hostname": host,
		"queue":    "overview",
		"env":      Environment,
		"stat":     "ready-count",
	}
	points := []*datapoint.Datapoint{
		sfxclient.Gauge("rabbitmq-messages", dimensions, int64(overview.QueueTotals.MessagesReady)),
	}
	postErr := sink.AddDatapoints(context.TODO(), points)
	if postErr != nil {
		logger.ErrorD("add-datapoints-error", l.M{
			"error": postErr.Error(),
			"host":  host,
		})
		return
	}
	logger.InfoD("stats-sent", l.M{
		"host":   host,
		"stats":  "overview",
		"queues": overview.ObjectTotals.Queues,
	})

}
Exemplo n.º 2
0
func sendQueueStats(rabbit *rabbithole.Client, sink *sfxclient.HTTPDatapointSink, host string) {
	queues, err := rabbit.ListQueues()
	if err != nil {
		logger.ErrorD("list-queues-error", l.M{
			"error": err.Error(),
			"host":  host,
		})
		return
	}

	// Collect and combine stats
	points := []*datapoint.Datapoint{}
	for _, queueInfo := range queues {
		dimensions := map[string]string{
			"Hostname": host,
			"queue":    queueInfo.Name,
			"env":      Environment,
			"stat":     "ready-count",
		}
		points = append(points, sfxclient.Gauge("rabbitmq-messages", dimensions, int64(queueInfo.MessagesReady)))
	}

	// send stats to signalfx
	postErr := sink.AddDatapoints(context.TODO(), points)
	if postErr != nil {
		logger.ErrorD("add-datapoints-error", l.M{
			"error": postErr.Error(),
			"host":  host,
		})
		return
	}
	logger.InfoD("stats-sent", l.M{
		"host":   host,
		"stats":  "queues",
		"queues": len(queues),
	})
}