Merge pull request #1732 from fach/master
Adding backlog/current queue length to qdisc collector
This commit is contained in:
commit
5d42d4d99f
|
@ -2497,10 +2497,18 @@ node_procs_blocked 0
|
|||
# HELP node_procs_running Number of processes in runnable state.
|
||||
# TYPE node_procs_running gauge
|
||||
node_procs_running 2
|
||||
# HELP node_qdisc_backlog Number of bytes currently in queue to be sent.
|
||||
# TYPE node_qdisc_backlog gauge
|
||||
node_qdisc_backlog{device="eth0",kind="pfifo_fast"} 0
|
||||
node_qdisc_backlog{device="wlan0",kind="fq"} 0
|
||||
# HELP node_qdisc_bytes_total Number of bytes sent.
|
||||
# TYPE node_qdisc_bytes_total counter
|
||||
node_qdisc_bytes_total{device="eth0",kind="pfifo_fast"} 83
|
||||
node_qdisc_bytes_total{device="wlan0",kind="fq"} 42
|
||||
# HELP node_qdisc_current_queue_length Number of packets currently in queue to be sent.
|
||||
# TYPE node_qdisc_current_queue_length gauge
|
||||
node_qdisc_current_queue_length{device="eth0",kind="pfifo_fast"} 0
|
||||
node_qdisc_current_queue_length{device="wlan0",kind="fq"} 0
|
||||
# HELP node_qdisc_drops_total Number of packets dropped.
|
||||
# TYPE node_qdisc_drops_total counter
|
||||
node_qdisc_drops_total{device="eth0",kind="pfifo_fast"} 0
|
||||
|
|
|
@ -2566,10 +2566,18 @@ node_procs_blocked 0
|
|||
# HELP node_procs_running Number of processes in runnable state.
|
||||
# TYPE node_procs_running gauge
|
||||
node_procs_running 2
|
||||
# HELP node_qdisc_backlog Number of bytes currently in queue to be sent.
|
||||
# TYPE node_qdisc_backlog gauge
|
||||
node_qdisc_backlog{device="eth0",kind="pfifo_fast"} 0
|
||||
node_qdisc_backlog{device="wlan0",kind="fq"} 0
|
||||
# HELP node_qdisc_bytes_total Number of bytes sent.
|
||||
# TYPE node_qdisc_bytes_total counter
|
||||
node_qdisc_bytes_total{device="eth0",kind="pfifo_fast"} 83
|
||||
node_qdisc_bytes_total{device="wlan0",kind="fq"} 42
|
||||
# HELP node_qdisc_current_queue_length Number of packets currently in queue to be sent.
|
||||
# TYPE node_qdisc_current_queue_length gauge
|
||||
node_qdisc_current_queue_length{device="eth0",kind="pfifo_fast"} 0
|
||||
node_qdisc_current_queue_length{device="wlan0",kind="fq"} 0
|
||||
# HELP node_qdisc_drops_total Number of packets dropped.
|
||||
# TYPE node_qdisc_drops_total counter
|
||||
node_qdisc_drops_total{device="eth0",kind="pfifo_fast"} 0
|
||||
|
|
|
@ -32,6 +32,8 @@ type qdiscStatCollector struct {
|
|||
drops typedDesc
|
||||
requeues typedDesc
|
||||
overlimits typedDesc
|
||||
qlength typedDesc
|
||||
backlog typedDesc
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
|
@ -71,6 +73,16 @@ func NewQdiscStatCollector(logger log.Logger) (Collector, error) {
|
|||
"Number of overlimit packets.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.CounterValue},
|
||||
qlength: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "qdisc", "current_queue_length"),
|
||||
"Number of packets currently in queue to be sent.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.GaugeValue},
|
||||
backlog: typedDesc{prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "qdisc", "backlog"),
|
||||
"Number of bytes currently in queue to be sent.",
|
||||
[]string{"device", "kind"}, nil,
|
||||
), prometheus.GaugeValue},
|
||||
logger: logger,
|
||||
}, nil
|
||||
}
|
||||
|
@ -114,6 +126,8 @@ func (c *qdiscStatCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
ch <- c.drops.mustNewConstMetric(float64(msg.Drops), msg.IfaceName, msg.Kind)
|
||||
ch <- c.requeues.mustNewConstMetric(float64(msg.Requeues), msg.IfaceName, msg.Kind)
|
||||
ch <- c.overlimits.mustNewConstMetric(float64(msg.Overlimits), msg.IfaceName, msg.Kind)
|
||||
ch <- c.qlength.mustNewConstMetric(float64(msg.Qlen), msg.IfaceName, msg.Kind)
|
||||
ch <- c.backlog.mustNewConstMetric(float64(msg.Backlog), msg.IfaceName, msg.Kind)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
4
go.mod
4
go.mod
|
@ -4,7 +4,7 @@ require (
|
|||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
|
||||
github.com/beevik/ntp v0.3.0
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
|
||||
github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043
|
||||
github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00
|
||||
github.com/go-kit/kit v0.10.0
|
||||
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968
|
||||
github.com/golang/protobuf v1.4.1 // indirect
|
||||
|
@ -26,7 +26,7 @@ require (
|
|||
go.uber.org/multierr v1.5.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 // indirect
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 // indirect
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect
|
||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980
|
||||
golang.org/x/tools v0.0.0-20200513201620-d5fe73897c97 // indirect
|
||||
|
|
8
go.sum
8
go.sum
|
@ -60,8 +60,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m
|
|||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043 h1:I3hLsM87FSASssIrIOGwJCio31dvLkvpYDKn2+r31ec=
|
||||
github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043/go.mod h1:ix4kG2zvdUd8kEKSW0ZTr1XLks0epFpI4j745DXxlNE=
|
||||
github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00 h1:0GHzegkDz/zSrt+Zph1OueNImPdUxoToypnkhhRYTjI=
|
||||
github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00/go.mod h1:ix4kG2zvdUd8kEKSW0ZTr1XLks0epFpI4j745DXxlNE=
|
||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
|
@ -394,8 +394,8 @@ golang.org/x/net v0.0.0-20191007182048-72f939374954/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
|
|
@ -86,6 +86,8 @@ type QdiscInfo struct {
|
|||
GcFlows uint64
|
||||
Throttled uint64
|
||||
FlowsPlimit uint64
|
||||
Qlen uint32
|
||||
Backlog uint32
|
||||
}
|
||||
|
||||
func parseTCAStats(attr netlink.Attribute) TC_Stats {
|
||||
|
@ -237,6 +239,8 @@ func parseMessage(msg netlink.Message) (QdiscInfo, error) {
|
|||
// requeues only available in TCA_STATS2, not in TCA_STATS
|
||||
m.Requeues = s2.Requeues
|
||||
m.Overlimits = s2.Overlimits
|
||||
m.Qlen = s2.Qlen
|
||||
m.Backlog = s2.Backlog
|
||||
case TCA_STATS:
|
||||
// Legacy
|
||||
s = parseTCAStats(attr)
|
||||
|
@ -244,6 +248,8 @@ func parseMessage(msg netlink.Message) (QdiscInfo, error) {
|
|||
m.Packets = s.Packets
|
||||
m.Drops = s.Drops
|
||||
m.Overlimits = s.Overlimits
|
||||
m.Qlen = s.Qlen
|
||||
m.Backlog = s.Backlog
|
||||
default:
|
||||
// TODO: TCA_OPTIONS and TCA_XSTATS
|
||||
}
|
||||
|
|
|
@ -108,6 +108,19 @@ type Transport struct {
|
|||
// waiting for their turn.
|
||||
StrictMaxConcurrentStreams bool
|
||||
|
||||
// ReadIdleTimeout is the timeout after which a health check using ping
|
||||
// frame will be carried out if no frame is received on the connection.
|
||||
// Note that a ping response will is considered a received frame, so if
|
||||
// there is no other traffic on the connection, the health check will
|
||||
// be performed every ReadIdleTimeout interval.
|
||||
// If zero, no health check is performed.
|
||||
ReadIdleTimeout time.Duration
|
||||
|
||||
// PingTimeout is the timeout after which the connection will be closed
|
||||
// if a response to Ping is not received.
|
||||
// Defaults to 15s.
|
||||
PingTimeout time.Duration
|
||||
|
||||
// t1, if non-nil, is the standard library Transport using
|
||||
// this transport. Its settings are used (but not its
|
||||
// RoundTrip method, etc).
|
||||
|
@ -131,6 +144,14 @@ func (t *Transport) disableCompression() bool {
|
|||
return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
|
||||
}
|
||||
|
||||
func (t *Transport) pingTimeout() time.Duration {
|
||||
if t.PingTimeout == 0 {
|
||||
return 15 * time.Second
|
||||
}
|
||||
return t.PingTimeout
|
||||
|
||||
}
|
||||
|
||||
// ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2.
|
||||
// It returns an error if t1 has already been HTTP/2-enabled.
|
||||
func ConfigureTransport(t1 *http.Transport) error {
|
||||
|
@ -675,6 +696,20 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
|||
return cc, nil
|
||||
}
|
||||
|
||||
func (cc *ClientConn) healthCheck() {
|
||||
pingTimeout := cc.t.pingTimeout()
|
||||
// We don't need to periodically ping in the health check, because the readLoop of ClientConn will
|
||||
// trigger the healthCheck again if there is no frame received.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), pingTimeout)
|
||||
defer cancel()
|
||||
err := cc.Ping(ctx)
|
||||
if err != nil {
|
||||
cc.closeForLostPing()
|
||||
cc.t.connPool().MarkDead(cc)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (cc *ClientConn) setGoAway(f *GoAwayFrame) {
|
||||
cc.mu.Lock()
|
||||
defer cc.mu.Unlock()
|
||||
|
@ -846,14 +881,12 @@ func (cc *ClientConn) sendGoAway() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Close closes the client connection immediately.
|
||||
//
|
||||
// In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead.
|
||||
func (cc *ClientConn) Close() error {
|
||||
// closes the client connection immediately. In-flight requests are interrupted.
|
||||
// err is sent to streams.
|
||||
func (cc *ClientConn) closeForError(err error) error {
|
||||
cc.mu.Lock()
|
||||
defer cc.cond.Broadcast()
|
||||
defer cc.mu.Unlock()
|
||||
err := errors.New("http2: client connection force closed via ClientConn.Close")
|
||||
for id, cs := range cc.streams {
|
||||
select {
|
||||
case cs.resc <- resAndError{err: err}:
|
||||
|
@ -866,6 +899,20 @@ func (cc *ClientConn) Close() error {
|
|||
return cc.tconn.Close()
|
||||
}
|
||||
|
||||
// Close closes the client connection immediately.
|
||||
//
|
||||
// In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead.
|
||||
func (cc *ClientConn) Close() error {
|
||||
err := errors.New("http2: client connection force closed via ClientConn.Close")
|
||||
return cc.closeForError(err)
|
||||
}
|
||||
|
||||
// closes the client connection immediately. In-flight requests are interrupted.
|
||||
func (cc *ClientConn) closeForLostPing() error {
|
||||
err := errors.New("http2: client connection lost")
|
||||
return cc.closeForError(err)
|
||||
}
|
||||
|
||||
const maxAllocFrameSize = 512 << 10
|
||||
|
||||
// frameBuffer returns a scratch buffer suitable for writing DATA frames.
|
||||
|
@ -1737,8 +1784,17 @@ func (rl *clientConnReadLoop) run() error {
|
|||
rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse
|
||||
gotReply := false // ever saw a HEADERS reply
|
||||
gotSettings := false
|
||||
readIdleTimeout := cc.t.ReadIdleTimeout
|
||||
var t *time.Timer
|
||||
if readIdleTimeout != 0 {
|
||||
t = time.AfterFunc(readIdleTimeout, cc.healthCheck)
|
||||
defer t.Stop()
|
||||
}
|
||||
for {
|
||||
f, err := cc.fr.ReadFrame()
|
||||
if t != nil {
|
||||
t.Reset(readIdleTimeout)
|
||||
}
|
||||
if err != nil {
|
||||
cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ github.com/cespare/xxhash/v2
|
|||
# github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
|
||||
## explicit
|
||||
github.com/coreos/go-systemd/dbus
|
||||
# github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043
|
||||
# github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00
|
||||
## explicit
|
||||
github.com/ema/qdisc
|
||||
# github.com/go-kit/kit v0.10.0
|
||||
|
@ -108,7 +108,7 @@ golang.org/x/crypto/bcrypt
|
|||
golang.org/x/crypto/blowfish
|
||||
# golang.org/x/lint v0.0.0-20200302205851-738671d3881b
|
||||
## explicit
|
||||
# golang.org/x/net v0.0.0-20200513185701-a91f0712d120
|
||||
# golang.org/x/net v0.0.0-20200602114024-627f9648deb9
|
||||
## explicit
|
||||
golang.org/x/net/bpf
|
||||
golang.org/x/net/http/httpguts
|
||||
|
|
Loading…
Reference in New Issue