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