Beispiel #1
0
func info(address string, name string, config configuration.Configuration) {
	// Transform selected metrics slice to map
	metricsSet := util.NewSet()
	metricsSet.AppendAll(config.Metrics)

	// Create a map to store only matching metrics
	replies := make(map[string]float64, len(config.Metrics))

	infoRequest := redis.NewInfoRequest(address)
	infoResponse, err := infoRequest.Send()
	if err != nil {
		log.Printf("Error getting redis info: %v", err)
		return
	}

	for metric, value := range infoResponse.Metrics {
		if metricsSet.Contains(metric) {
			metricName := fmt.Sprintf("%s.%s", name, metric)
			replies[metricName] = value
		}
	}

	s := statsd.NewStatsd(config.Statsd.Host, config.Statsd.Port)
	s.BulkGauge(replies)
}
Beispiel #2
0
func Test_Append_NoExisting_IncludeAElement(t *testing.T) {
	set := util.NewSet()
	set.Append(ELEMENT)
	if !set.Contains(ELEMENT) {
		t.Fail()
	}
}
Beispiel #3
0
func Test_Remove_Existing_RemoveTheElement(t *testing.T) {
	set := util.NewSet()
	set.Append(ELEMENT)
	set.Remove(ELEMENT)
	if set.Contains(ELEMENT) {
		t.Fail()
	}
}
Beispiel #4
0
func Test_AppendAll_NoExistingSlice_IncludeAllElements(t *testing.T) {
	set := util.NewSet()
	set.AppendAll(ELEMENT_SLICE)
	for _, element := range ELEMENT_SLICE {
		if !set.Contains(element) {
			t.Fail()
		}
	}
}
Beispiel #5
0
func Test_AppendAll_SimpleElement_Panic(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			if r != "AppendAll only takes Slices or Arrays." {
				t.Fail()
			}
		}
	}()
	set := util.NewSet()
	set.AppendAll(ELEMENT)
	t.Fail()
}