Пример #1
0
func ExampleMultiSender() {
	// Create an expvar sender
	s1 := expvar.New("stats")

	// Create the stats sender
	statsdWriter, _ := net.Dial("udp", "127.0.0.1:8126")
	s2 := dogstatsd.New(statsdWriter, 5*time.Second)

	// Create a xstats with a sender composed of the previous two.
	// You may also create a NewHandler() the same way.
	s := xstats.New(xstats.MultiSender{s1, s2})

	// Send some observations
	s.Count("requests", 1, "tag")
	s.Timing("something", 5*time.Millisecond, "tag")
}
Пример #2
0
func ExampleNew() {
	// Defines interval between flushes to statsd server
	flushInterval := 5 * time.Second

	// Connection to the statsd server
	statsdWriter, err := net.Dial("udp", "127.0.0.1:8126")
	if err != nil {
		log.Fatal(err)
	}

	// Create the stats client
	s := xstats.New(dogstatsd.New(statsdWriter, flushInterval))

	// Global tags sent with all metrics (only with supported clients like datadog's)
	s.AddTags("role:my-service", "dc:sv6")

	// Send some observations
	s.Count("requests", 1, "tag")
	s.Timing("something", 5*time.Millisecond, "tag")
}