Skip to content

Commit

Permalink
Fix error metric increments (#301)
Browse files Browse the repository at this point in the history
* Actually increment sender error metrics
* Actually increment receiver error metrics
  • Loading branch information
stephen-soltesz committed Jun 18, 2020
1 parent 5daf100 commit 0df069c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions ndt7/download/sender/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ func Start(ctx context.Context, conn *websocket.Conn, data *model.ArchivalData)
if err != nil {
logging.Logger.WithError(err).Warn("sender: makePreparedMessage failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestDownload), "make-prepared-message")
proto, string(spec.SubtestDownload), "make-prepared-message").Inc()
return err
}
deadline := time.Now().Add(spec.MaxRuntime)
err = conn.SetWriteDeadline(deadline) // Liveness!
if err != nil {
logging.Logger.WithError(err).Warn("sender: conn.SetWriteDeadline failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestDownload), "set-write-deadline")
proto, string(spec.SubtestDownload), "set-write-deadline").Inc()
return err
}

Expand All @@ -73,29 +73,29 @@ func Start(ctx context.Context, conn *websocket.Conn, data *model.ArchivalData)
if !ok { // This means that the measurer has terminated
closer.StartClosing(conn)
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestDownload), "measurer-closed")
proto, string(spec.SubtestDownload), "measurer-closed").Inc()
return nil
}
if err := conn.WriteJSON(m); err != nil {
logging.Logger.WithError(err).Warn("sender: conn.WriteJSON failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestDownload), "write-json")
proto, string(spec.SubtestDownload), "write-json").Inc()
return err
}
// Only save measurements sent to the client.
data.ServerMeasurements = append(data.ServerMeasurements, m)
if err := ping.SendTicks(conn, deadline); err != nil {
logging.Logger.WithError(err).Warn("sender: ping.SendTicks failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestDownload), "ping-send-ticks")
proto, string(spec.SubtestDownload), "ping-send-ticks").Inc()
return err
}
default:
if err := conn.WritePreparedMessage(preparedMessage); err != nil {
logging.Logger.WithError(err).Warn(
"sender: conn.WritePreparedMessage failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestDownload), "write-prepared-message")
proto, string(spec.SubtestDownload), "write-prepared-message").Inc()
return err
}
// The following block of code implements the scaling of message size
Expand All @@ -117,7 +117,7 @@ func Start(ctx context.Context, conn *websocket.Conn, data *model.ArchivalData)
if err != nil {
logging.Logger.WithError(err).Warn("sender: makePreparedMessage failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestDownload), "make-prepared-message")
proto, string(spec.SubtestDownload), "make-prepared-message").Inc()
return err
}
}
Expand Down
12 changes: 6 additions & 6 deletions ndt7/receiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func start(
if err != nil {
logging.Logger.WithError(err).Warn("receiver: conn.SetReadDeadline failed")
ndt7metrics.ClientReceiverErrors.WithLabelValues(
proto, string(kind), "set-read-deadline")
proto, string(kind), "set-read-deadline").Inc()
return
}
conn.SetPongHandler(func(s string) error {
Expand All @@ -46,23 +46,23 @@ func start(
logging.Logger.Debugf("receiver: ApplicationLevel RTT: %d ms", rtt)
} else {
ndt7metrics.ClientReceiverErrors.WithLabelValues(
proto, string(kind), "ping-parse-ticks")
proto, string(kind), "ping-parse-ticks").Inc()
}
return err
})
for receiverctx.Err() == nil { // Liveness!
mtype, mdata, err := conn.ReadMessage()
if err != nil {
ndt7metrics.ClientReceiverErrors.WithLabelValues(
proto, string(kind), "read-message")
proto, string(kind), "read-message").Inc()
return
}
if mtype != websocket.TextMessage {
switch kind {
case downloadReceiver:
logging.Logger.Warn("receiver: got non-Text message")
ndt7metrics.ClientReceiverErrors.WithLabelValues(
proto, string(kind), "wrong-message-type")
proto, string(kind), "wrong-message-type").Inc()
return // Unexpected message type
default:
// NOTE: this is the bulk upload path. In this case, the mdata is not used.
Expand All @@ -74,13 +74,13 @@ func start(
if err != nil {
logging.Logger.WithError(err).Warn("receiver: json.Unmarshal failed")
ndt7metrics.ClientReceiverErrors.WithLabelValues(
proto, string(kind), "unmarshal-client-message")
proto, string(kind), "unmarshal-client-message").Inc()
return
}
data.ClientMeasurements = append(data.ClientMeasurements, measurement)
}
ndt7metrics.ClientReceiverErrors.WithLabelValues(
proto, string(kind), "receiver-context-expired")
proto, string(kind), "receiver-context-expired").Inc()
}

// StartDownloadReceiverAsync starts the receiver in a background goroutine and
Expand Down
8 changes: 4 additions & 4 deletions ndt7/upload/sender/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Start(ctx context.Context, conn *websocket.Conn, data *model.ArchivalData)
if err != nil {
logging.Logger.WithError(err).Warn("sender: conn.SetWriteDeadline failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestUpload), "set-write-deadline")
proto, string(spec.SubtestUpload), "set-write-deadline").Inc()
return err
}

Expand All @@ -51,21 +51,21 @@ func Start(ctx context.Context, conn *websocket.Conn, data *model.ArchivalData)
if !ok { // This means that the previous step has terminated
closer.StartClosing(conn)
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestUpload), "measurer-closed")
proto, string(spec.SubtestUpload), "measurer-closed").Inc()
return nil
}
if err := conn.WriteJSON(m); err != nil {
logging.Logger.WithError(err).Warn("sender: conn.WriteJSON failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestUpload), "write-json")
proto, string(spec.SubtestUpload), "write-json").Inc()
return err
}
// Only save measurements sent to the client.
data.ServerMeasurements = append(data.ServerMeasurements, m)
if err := ping.SendTicks(conn, deadline); err != nil {
logging.Logger.WithError(err).Warn("sender: ping.SendTicks failed")
ndt7metrics.ClientSenderErrors.WithLabelValues(
proto, string(spec.SubtestUpload), "ping-send-ticks")
proto, string(spec.SubtestUpload), "ping-send-ticks").Inc()
return err
}
}
Expand Down

0 comments on commit 0df069c

Please sign in to comment.