mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-24 20:00:26 +00:00
65aaa607ab
Change made by: - running "gvt fetch" on each of the packages mentioned in Godeps/Godeps.json - `rm -rf Godeps` - tweaking the build scripts to not mention Godeps - tweaking the build scripts to test `./lib/...`, `./cmd/...` explicitly (to avoid testing vendor) - tweaking the build scripts to not juggle GOPATH for Godeps and instead set GO15VENDOREXPERIMENT. This also results in some updated packages at the same time I bet. Building with Go 1.3 and 1.4 still *works* but won't use our vendored dependencies - the user needs to have the actual packages in their GOPATH then, which they'll get with a normal "go get". Building with Go 1.6+ will get our vendored dependencies by default even when not using our build script, which is nice. By doing this we gain some freedom in that we can pick and choose manually what to include in vendor, as it's not based on just dependency analysis of our own code. This is also a risk as we might pick up dependencies we are unaware of, as the build may work locally with those packages present in GOPATH. On the other hand the build server will detect this as it has no packages in it's GOPATH beyond what is included in the repo. Recommended tool to manage dependencies is github.com/FiloSottile/gvt.
79 lines
1.9 KiB
Go
79 lines
1.9 KiB
Go
// +build !windows
|
|
|
|
package metrics
|
|
|
|
import (
|
|
"fmt"
|
|
"log/syslog"
|
|
"time"
|
|
)
|
|
|
|
// Output each metric in the given registry to syslog periodically using
|
|
// the given syslogger.
|
|
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) {
|
|
case Counter:
|
|
w.Info(fmt.Sprintf("counter %s: count: %d", name, metric.Count()))
|
|
case Gauge:
|
|
w.Info(fmt.Sprintf("gauge %s: value: %d", name, metric.Value()))
|
|
case GaugeFloat64:
|
|
w.Info(fmt.Sprintf("gauge %s: value: %f", name, metric.Value()))
|
|
case Healthcheck:
|
|
metric.Check()
|
|
w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, metric.Error()))
|
|
case Histogram:
|
|
h := metric.Snapshot()
|
|
ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
|
|
w.Info(fmt.Sprintf(
|
|
"histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f",
|
|
name,
|
|
h.Count(),
|
|
h.Min(),
|
|
h.Max(),
|
|
h.Mean(),
|
|
h.StdDev(),
|
|
ps[0],
|
|
ps[1],
|
|
ps[2],
|
|
ps[3],
|
|
ps[4],
|
|
))
|
|
case Meter:
|
|
m := metric.Snapshot()
|
|
w.Info(fmt.Sprintf(
|
|
"meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f",
|
|
name,
|
|
m.Count(),
|
|
m.Rate1(),
|
|
m.Rate5(),
|
|
m.Rate15(),
|
|
m.RateMean(),
|
|
))
|
|
case Timer:
|
|
t := metric.Snapshot()
|
|
ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
|
|
w.Info(fmt.Sprintf(
|
|
"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",
|
|
name,
|
|
t.Count(),
|
|
t.Min(),
|
|
t.Max(),
|
|
t.Mean(),
|
|
t.StdDev(),
|
|
ps[0],
|
|
ps[1],
|
|
ps[2],
|
|
ps[3],
|
|
ps[4],
|
|
t.Rate1(),
|
|
t.Rate5(),
|
|
t.Rate15(),
|
|
t.RateMean(),
|
|
))
|
|
}
|
|
})
|
|
}
|
|
}
|