Last active
February 23, 2019 18:56
-
-
Save arriqaaq/1025b21764bbf3d9d6088e47119023f1 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
package main | |
import ( | |
"github.com/arriqaaq/boomerang" | |
lucio "github.com/arriqaaq/server" | |
"github.com/prometheus/client_golang/prometheus/promhttp" | |
"log" | |
"net/http" | |
"os" | |
"time" | |
) | |
func main() { | |
promCtx := boomerang.NewPrometheusMetrics("service_b", "service_b") | |
mux := http.NewServeMux() | |
mux.HandleFunc("/pong", func(w http.ResponseWriter, req *http.Request) { | |
begin := time.Now() | |
time.Sleep(3 * time.Millisecond) | |
promCtx.Record(begin, 200, nil) | |
w.Write([]byte("pong")) | |
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