Skip to content

Commit

Permalink
Merge pull request #128 from m-lab/sandbox-soltesz
Browse files Browse the repository at this point in the history
Add new monitoring for requested tests and submitted meta values
  • Loading branch information
stephen-soltesz authored May 31, 2019
2 parents 9758c7f + 71dc4d2 commit 3b42eb0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
14 changes: 13 additions & 1 deletion legacy/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,28 @@ func handleControlChannel(conn protocol.Connection, s ndt.Server) {
runC2s := (tests & cTestC2S) != 0
runS2c := (tests & cTestS2C) != 0
runMeta := (tests & cTestMETA) != 0
// TODO: count cTestSFW & cTestMID requests.
runSFW := (tests & cTestSFW) != 0
runMID := (tests & cTestMID) != 0

legacymetrics.ClientRequestedTestSuites.WithLabelValues(fmt.Sprintf("%d", 0xff&tests)).Inc()

if runMID {
legacymetrics.ClientRequestedTests.WithLabelValues("mid").Inc()
}
if runC2s {
testsToRun = append(testsToRun, strconv.Itoa(cTestC2S))
legacymetrics.ClientRequestedTests.WithLabelValues("c2s").Inc()
}
if runS2c {
testsToRun = append(testsToRun, strconv.Itoa(cTestS2C))
legacymetrics.ClientRequestedTests.WithLabelValues("s2c").Inc()
}
if runSFW {
legacymetrics.ClientRequestedTests.WithLabelValues("sfw").Inc()
}
if runMeta {
testsToRun = append(testsToRun, strconv.Itoa(cTestMETA))
legacymetrics.ClientRequestedTests.WithLabelValues("meta").Inc()
}

m := conn.Messager()
Expand Down
5 changes: 3 additions & 2 deletions legacy/meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"strings"
"time"

"github.com/m-lab/ndt-server/legacy/metrics"
"github.com/m-lab/ndt-server/legacy/protocol"
)

// maxClientMessages is the maximum allowed messages we will accept from a client.
// TODO: add histogram (1-20) counting number of messages per client.
var maxClientMessages = 20

// ArchivalData contains all meta data reported by the client.
Expand Down Expand Up @@ -43,7 +43,6 @@ func ManageTest(ctx context.Context, m protocol.Messager) (ArchivalData, error)
}
count++

log.Println("Meta message: ", string(message))
s := strings.SplitN(string(message), ":", 2)
if len(s) != 2 {
continue
Expand All @@ -66,6 +65,8 @@ func ManageTest(ctx context.Context, m protocol.Messager) (ArchivalData, error)
log.Println("Error reading JSON message:", err)
return nil, err
}
// Count the number meta values sent by the client (when there are no errors).
metrics.SubmittedMetaValues.Observe(float64(count))
m.SendMessage(protocol.TestFinalize, []byte{})
return results, nil
}
23 changes: 23 additions & 0 deletions legacy/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,27 @@ var (
Help: "The number of times we sniffed-then-proxied a websocket connection on the legacy channel.",
},
)
ClientRequestedTestSuites = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ndt_legacy_client_requested_suites_total",
Help: "The number of client request test suites (the combination of all test types as an integer 0-255).",
},
[]string{"suite"},
)
ClientRequestedTests = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ndt_legacy_client_requested_tests_total",
Help: "The number of client requests for each legacy test type.",
},
[]string{"type"},
)
SubmittedMetaValues = promauto.NewHistogram(
prometheus.HistogramOpts{
Name: "ndt_legacy_submitted_meta_values",
Help: "The number of meta values submitted by clients.",
Buckets: []float64{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
},
)
)
6 changes: 4 additions & 2 deletions ndt-server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ func Test_MainIntegrationTest(t *testing.T) {
tests := []testcase{
// Legacy TLV-only clients.
{
// NOTE: we must disable the middle-box test in the legacy TLV client because it unconditionally expects
// that test to run irrespective of what the server supports.
name: "web100clt (legacy TLV)",
cmd: "timeout 45s /bin/web100clt-without-json-support --name localhost --port " + legacyAddr + " --disablemid --disablesfw",
cmd: "timeout 45s /bin/web100clt-without-json-support --name localhost --port " + legacyAddr + " --disablemid",
},
{
name: "libndt-client - legacy NDT with JSON, download test",
Expand Down Expand Up @@ -193,7 +195,7 @@ func Test_MainIntegrationTest(t *testing.T) {
// Test legacy raw JSON clients
{
name: "web100clt (with JSON), no MID or SFW",
cmd: "timeout 45s /bin/web100clt-with-json-support --name localhost --port " + legacyAddr + " --disablemid --disablesfw",
cmd: "timeout 45s /bin/web100clt-with-json-support --name localhost --port " + legacyAddr,
},
// Test legacy WS clients connected to the HTTP port
{
Expand Down

0 comments on commit 3b42eb0

Please sign in to comment.