Last active
September 4, 2018 12:12
-
-
Save arriqaaq/047e94c083c97417868f9504fb956816 to your computer and use it in GitHub Desktop.
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
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