afex / hystrix-go

Netflix's Hystrix latency and fault tolerance library, for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Export isOpen() and metrics

isaldana opened this issue · comments

We have a need to check if a circuit is open. Is there an easy way to do that? Also, we want to send some status to our metrics server and the only way I can think of is to hack the HTTP streamer. An example here (to stdout):

// This is  used to output the Hystrix stream to stdout and only used for debugging
// circuit stats
type outputResponseStdout struct {
    HeaderMap http.Header
}

func (o *outputResponseStdout) Header() http.Header {
    m := o.HeaderMap
    if m == nil {
        m = make(http.Header)
        o.HeaderMap = m
    }
    return m
}

func (o *outputResponseStdout) Write(buf []byte) (int, error) {
    return os.Stdout.Write(buf)
}

func (o *outputResponseStdout) WriteHeader(c int) {
    fmt.Println("HTTP code: ", c)
}

func OutputHystrixEvents() {
    s := hystrix.NewStreamHandler()
    s.Start()
    rh := &outputResponseStdout{}
    req, err := http.NewRequest("GET", "", nil)
    if err != nil {
        return
    }
    s.ServeHTTP(rh, req)
}
commented

@crxpandion is working on a patch introducing non-dashboard metrics (i.e. statsd)

Yeah I am working on introducing a metrics interface that will allow pluggable aggregators.

commented

statsd metrics are now possible in master, and there is a framework for your own implementation for custom solutions.