Esempio n. 1
0
func NewPeriodicReporter(registry metrics.Registry, interval time.Duration, alignInterval, latched bool, reporter Reporter) *PeriodicReporter {
	return &PeriodicReporter{
		registry:      registry,
		interval:      interval,
		alignInterval: alignInterval,
		reporter:      reporter,
		snapshot:      metrics.NewRegistrySnapshot(latched),
	}
}
func TestCloudWatch(t *testing.T) {
	accessKey := os.Getenv("AWS_ACCESS_KEY")
	secretKey := os.Getenv("AWS_SECRET_KEY")
	if accessKey == "" || secretKey == "" {
		t.Skip("Missing AWS_ACCESS_KEY or AWS_SECRET_KEY environment variable")
	}
	registry := metrics.NewRegistry()
	hist := metrics.NewUnbiasedHistogram()
	hist.Update(100)
	hist.Update(120)
	hist.Update(300)
	hist.Update(50)
	hist.Update(123)
	registry.Add("Test", hist)
	auth := func() (string, string, string) {
		return accessKey, secretKey, ""
	}
	snapshot := metrics.NewRegistrySnapshot(true)
	snapshot.Snapshot(registry)
	reporter := newCloudWatchReporter(time.Minute, "us-east-1", auth, "Test", map[string]string{"Test": "go-metrics"}, time.Second*10)
	reporter.Report(snapshot)
}