Skip to content

Instantly share code, notes, and snippets.

@jqr
Forked from jimiray/instrumental.go
Created April 26, 2013 17:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jqr/5468956 to your computer and use it in GitHub Desktop.
Save jqr/5468956 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net"
"bufio"
"time"
)
const apiKey string = "your api key"
func main() {
fmt.Println("Starting Instrumental collection")
conn, err := net.Dial("tcp", "collector.instrumentalapp.com:8000")
if err != nil {
fmt.Println(err)
}
fmt.Println("Sending hello")
fmt.Fprintf(conn, "hello version 0.1\n")
status, err := bufio.NewReader(conn).ReadString('\n')
if err != nil {
fmt.Println(err)
}
fmt.Println("Authenticating w/ instrumental")
fmt.Fprintf(conn, "authenticate %v\n", apiKey)
authStatus, err := bufio.NewReader(conn).ReadString('\n')
if err != nil {
fmt.Println("There was an error authenticating")
}
fmt.Println("Sneding increment to test metric")
fmt.Fprintf(conn, "increment test.increment_metric 1 %v\n", time.Now().Unix())
fmt.Printf("metric submitted")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment