prometheus-hystrix-go is metric collector of prometheus for hystrix-go.
package main
import (
"net/http"
"github.com/afex/hystrix-go/hystrix"
hystrix_metric "github.com/afex/hystrix-go/hystrix/metric_collector"
prometheus_hystrix_go "github.com/gjbae1212/prometheus-hystrix-go"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
// get hystrix wrapper
wrapper := prometheus_hystrix_go.NewPrometheusCollector("hystrix", map[string]string{"app": "myapp"})
// register and initialize to hystrix prometheus
hystrix_metric.Registry.Register(wrapper)
http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
hystrix.Do("my_command", func() error { return nil }, nil)
})
// start server
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":8080", nil)
}
This example allows you get to the prometheus metric of the hystrix when you request to /metrics
path.
This project is following The MIT.