Created
June 28, 2018 06:22
-
-
Save sohamkamani/5aa2461cc197c3a51a169c4add5c38c7 to your computer and use it in GitHub Desktop.
sending metrics to statsd via udp in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
conn, err := net.Dial("udp", "127.0.0.1:8125") | |
if err != nil { | |
fmt.Printf("Some error %v", err) | |
return | |
} | |
for i := 0; i < 10; i++ { | |
// This is the only line of code you need to push stats to telegraf | |
fmt.Fprintf(conn, "deploys.test.myservice,from=go:1|c") | |
time.Sleep(1 * time.Second) | |
} | |
conn.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment