Skip to content

Commit

Permalink
Add metric to count whether enabling BBR succeeded (#363)
Browse files Browse the repository at this point in the history
* Add metric to count whether bbr enabled successfully
  • Loading branch information
stephen-soltesz authored Jul 28, 2022
1 parent 4f67067 commit 5414ef1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ndt7/measurer/measurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"time"

"github.com/gorilla/websocket"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/m-lab/go/memoryless"
"github.com/m-lab/ndt-server/logging"
Expand All @@ -15,6 +17,16 @@ import (
"github.com/m-lab/ndt-server/netx"
)

var (
BBREnabled = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ndt7_measurer_bbr_enabled",
Help: "A counter of every attempt to enable bbr.",
},
[]string{"status"},
)
)

// Measurer performs measurements
type Measurer struct {
conn *websocket.Conn
Expand All @@ -33,10 +45,13 @@ func New(conn *websocket.Conn, UUID string) *Measurer {
func (m *Measurer) getSocketAndPossiblyEnableBBR() (netx.ConnInfo, error) {
ci := netx.ToConnInfo(m.conn.UnderlyingConn())
err := ci.EnableBBR()
success := "true"
if err != nil {
success = "false"
logging.Logger.WithError(err).Warn("Cannot enable BBR")
// FALLTHROUGH
}
BBREnabled.WithLabelValues(success).Inc()
return ci, nil
}

Expand Down

0 comments on commit 5414ef1

Please sign in to comment.