Skip to content

Instantly share code, notes, and snippets.

@jimiray
Last active December 15, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jimiray/5271144 to your computer and use it in GitHub Desktop.
Save jimiray/5271144 to your computer and use it in GitHub Desktop.
Submitting to instrumental via Go
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", "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")
}
@jqr
Copy link

jqr commented Apr 26, 2013

Awesome! Also I updated the endpoint host in my fork https://gist.github.com/jqr/5468956

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment