tun2: expvar counters for each backend
This commit is contained in:
parent
0ffaa5110a
commit
b4e80a6d9c
|
@ -4,6 +4,7 @@ import (
|
|||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"expvar"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -30,6 +31,8 @@ type Connection struct {
|
|||
detector *failure.Detector
|
||||
Auth *Auth
|
||||
usable bool
|
||||
|
||||
counter *expvar.Int
|
||||
}
|
||||
|
||||
func (c *Connection) cancel() {
|
||||
|
@ -150,5 +153,7 @@ func (c *Connection) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
resp.Body = ioutil.NopCloser(bytes.NewBuffer(body))
|
||||
resp.ContentLength = int64(len(body))
|
||||
|
||||
c.counter.Add(1)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"expvar"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -308,6 +309,7 @@ func (s *Server) HandleConn(c net.Conn, isKCP bool) {
|
|||
detector: failure.New(15, 1),
|
||||
Auth: auth,
|
||||
}
|
||||
connection.counter = expvar.NewInt("http.backend." + connection.id + ".hits")
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
|
Loading…
Reference in New Issue