コード例 #1
1
func BenchmarkAlexcesaro(b *testing.B) {
	s := newServer()
	c, err := alexcesaro.New(addr, alexcesaro.WithPrefix(prefix), alexcesaro.WithFlushPeriod(flushPeriod))
	if err != nil {
		b.Fatal(err)
	}
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		c.Increment(counterKey)
		c.Gauge(gaugeKey, gaugeValue)
		c.Timing(timingKey, tValInt, 1)
	}
	c.Close()
	b.StopTimer()
	s.Close()
}
コード例 #2
0
ファイル: main.go プロジェクト: nicholasjackson/sorcery
func createStatsDClient() logging.StatsD {
	statsDClient, err := statsd.New(statsd.Address(global.Config.StatsDServerIP)) // reference to a statsd client
	if err != nil {
		panic(fmt.Sprintln("Unable to create StatsD Client: ", err))
	}
	return statsDClient
}
コード例 #3
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleMute() {
	c, err := statsd.New(":8125", statsd.Mute(true))
	if err != nil {
		panic(err)
	}
	c.Increment("foo.bar") // Does nothing.
}
コード例 #4
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleWithPrefix() {
	c, err := statsd.New(":8125", statsd.WithPrefix("my_app."))
	if err != nil {
		panic(err)
	}
	c.Increment("foo.bar") // Increments "my_app.foo.bar".
}
コード例 #5
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func Example() {
	c, err := statsd.New(":8125")
	if err != nil {
		panic(err)
	}

	c.Increment("foo.counter")
	c.Gauge("num_goroutine", runtime.NumGoroutine())

	t := c.NewTiming()
	http.Get("http://example.com/")
	t.Send("homepage.response_time", 1)
	// Can also be used as a one-liner in a function:
	// func PingHomepage() {
	// 	defer c.NewTiming().Send("homepage.response_time", 1)
	// 	http.Get("http://example.com/")
	// }

	c.Close()
}
コード例 #6
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleWithNetwork() {
	// Send metrics using a TCP connection.
	statsd.New(":8125", statsd.WithNetwork("tcp"))
}
コード例 #7
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleWithMaxPacketSize() {
	statsd.New(":8125", statsd.WithMaxPacketSize(512))
}
コード例 #8
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleWithInfluxDBTags() {
	statsd.New(":8125", statsd.WithInfluxDBTags("region", "us", "app", "my_app"))
}
コード例 #9
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleWithFlushPeriod() {
	statsd.New(":8125", statsd.WithFlushPeriod(10*time.Millisecond))
}
コード例 #10
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleWithErrorHandler() {
	statsd.New(":8125", statsd.WithErrorHandler(func(err error) {
		log.Print(err)
	}))
}
コード例 #11
0
ファイル: examples_test.go プロジェクト: abourget/statsd
func ExampleWithDatadogTags() {
	statsd.New(":8125", statsd.WithDatadogTags("region:us", "app:my_app"))
}