gjbae1212 / prometheus-hystrix-go

prometheus collector for hystrix-go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prometheus-hystrix-go

license Go Report Card

OVERVIEW

prometheus-hystrix-go is metric collector of prometheus for hystrix-go.

HOW TO USE

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.

LICENSE

This project is following The MIT.

About

prometheus collector for hystrix-go.

License:MIT License


Languages

Language:Go 95.3%Language:Shell 4.7%