Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Last active February 23, 2019 18:56
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/1025b21764bbf3d9d6088e47119023f1 to your computer and use it in GitHub Desktop.
Save arriqaaq/1025b21764bbf3d9d6088e47119023f1 to your computer and use it in GitHub Desktop.
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