| // Output each metric in the given registry to syslog periodically using |
| func Syslog(r Registry, d time.Duration, w *syslog.Writer) { |
| for _ = range time.Tick(d) { |
| r.Each(func(name string, i interface{}) { |
| switch metric := i.(type) { |
| w.Info(fmt.Sprintf("counter %s: count: %d", name, metric.Count())) |
| w.Info(fmt.Sprintf("gauge %s: value: %d", name, metric.Value())) |
| w.Info(fmt.Sprintf("gauge %s: value: %f", name, metric.Value())) |
| w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, metric.Error())) |
| ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) |
| "histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f", |
| "meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f", |
| ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) |
| "timer %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f 1-min: %.2f 5-min: %.2f 15-min: %.2f mean-rate: %.2f", |