Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Last active September 4, 2018 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arriqaaq/047e94c083c97417868f9504fb956816 to your computer and use it in GitHub Desktop.
Save arriqaaq/047e94c083c97417868f9504fb956816 to your computer and use it in GitHub Desktop.
func main() {
client := redis.NewClient(&redis.Options{Addr:"localhost:6379",Password: "", DB:0, // use default DB})
pong, err := client.Ping().Result()
if err == nil {
log.Fatalln(pong, err)
}
client.Set("isco", "alarcon", 0).Err()
promCtx := boomerang.NewPrometheusMetrics("service_b", "info")
mux := http.NewServeMux()
mux.HandleFunc("/pong", func(w http.ResponseWriter, req *http.Request) {
begin := time.Now()
time.Sleep(50 * time.Millisecond)
val, _ := client.Get("isco").Result()
promCtx.Record(begin, 200, nil)
w.Write([]byte(val))
return
})
mux.Handle("/metrics", promhttp.Handler())
server := lucio.NewServer(mux, "0.0.0.0", 8081)
err = server.Serve()
log.Println("terminated", os.Getpid(), err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment