Skip to content

Commit

Permalink
Report metrics on all connection states
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed Nov 1, 2016
1 parent 2b4da35 commit b6df61a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion prog/weaver/http.go
Expand Up @@ -19,6 +19,8 @@ import (
weave "github.com/weaveworks/weave/router"
)

var allConnectionStates = []string{"established", "pending", "retrying", "failed", "connecting"}

var rootTemplate = template.New("root").Funcs(map[string]interface{}{
"countDNSEntries": countDNSEntries,
"printList": func(list []string) string {
Expand Down Expand Up @@ -87,7 +89,7 @@ var rootTemplate = template.New("root").Funcs(map[string]interface{}{
for _, conn := range conns {
counts[conn.State]++
}
return printCounts(counts, []string{"established", "pending", "retrying", "failed", "connecting"})
return printCounts(counts, allConnectionStates)
},
"printPeerConnectionCounts": func(peers []mesh.PeerStatus) string {
counts := make(map[string]int)
Expand Down
12 changes: 5 additions & 7 deletions prog/weaver/metrics.go
Expand Up @@ -46,15 +46,13 @@ func uint64Counter(desc *prometheus.Desc, val uint64, labels ...string) promethe
var metrics []metric = []metric{
{desc("weave_connections", "Number of peer-to-peer connections.", "state"),
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
established := 0
counts := make(map[string]int)
for _, conn := range s.Router.Connections {
if conn.State == "established" {
established++
}
counts[conn.State]++
}
for _, state := range allConnectionStates {
ch <- intGauge(desc, counts[state], state)
}

ch <- intGauge(desc, len(s.Router.Connections)-established, "non-established")
ch <- intGauge(desc, established, "established")
}},
{desc("weave_connection_terminations_total", "Number of peer-to-peer connections terminated."),
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
Expand Down

0 comments on commit b6df61a

Please sign in to comment.