예제 #1
0
파일: helper.go 프로젝트: 0x20h/grafana
func New(enabled bool, addr, t, service, instance string) (metric.Backend, error) {
	if t != "standard" && t != "datadog" {
		panic(fmt.Sprintf("unrecognized statsd type: '%s'", t))
	}
	if !enabled {
		// we could implement a true "null-backend"
		// but since statsd supports disabled mode, this is easier
		return statsd.New(enabled, addr, "")
	}
	if t == "standard" {
		return statsd.New(enabled, addr, fmt.Sprintf("%s.%s.", service, instance))
	} else {
		return dogstatsd.New(addr, service+".", []string{"instance:" + instance})
	}
}
예제 #2
0
func New(enabled bool, addr, t, prefix string) (metric.Backend, error) {
	if t != "standard" && t != "datadog" {
		panic(fmt.Sprintf("unrecognized statsd type: '%s'", t))
	}
	if !enabled {
		// we could implement a true "null-backend"
		// but since statsd supports disabled mode, this is easier
		return statsd.New(enabled, addr, prefix)
	}
	if t == "standard" {
		return statsd.New(enabled, addr, prefix)
	} else {
		return dogstatsd.New(addr, prefix)
	}
}