Last active
December 15, 2015 13:59
-
-
Save jimiray/5271144 to your computer and use it in GitHub Desktop.
Submitting to instrumental via Go
This file contains 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
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") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! Also I updated the endpoint host in my fork https://gist.github.com/jqr/5468956