Skip to content

Commit

Permalink
Remove Summary.ServerPort which was never populated (and not interest…
Browse files Browse the repository at this point in the history
…ing).
  • Loading branch information
fhltang committed Sep 3, 2022
1 parent 18098c4 commit 3219dcc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
8 changes: 4 additions & 4 deletions cmd/ndt7-prometheus-exporter/main.go
Expand Up @@ -154,7 +154,7 @@ func main() {
[]string{
// client IP and remote server
"client_ip",
"server",
"server_ip",
})
prometheus.MustRegister(dlThroughput)
dlLatency := prometheus.NewGaugeVec(
Expand All @@ -166,7 +166,7 @@ func main() {
[]string{
// client IP and remote server
"client_ip",
"server",
"server_ip",
})
prometheus.MustRegister(dlLatency)
ulThroughput := prometheus.NewGaugeVec(
Expand All @@ -178,7 +178,7 @@ func main() {
[]string{
// client IP and remote server
"client_ip",
"server",
"server_ip",
})
prometheus.MustRegister(ulThroughput)
ulLatency := prometheus.NewGaugeVec(
Expand All @@ -190,7 +190,7 @@ func main() {
[]string{
// client IP and remote server
"client_ip",
"server",
"server_ip",
})
prometheus.MustRegister(ulLatency)

Expand Down
19 changes: 8 additions & 11 deletions internal/emitter/prometheus.go
@@ -1,7 +1,6 @@
package emitter

import (
"fmt"
"time"

"github.com/prometheus/client_golang/prometheus"
Expand All @@ -14,19 +13,19 @@ type Prometheus struct {
emitter Emitter
// Download throughput
// Value: throughput in bits/s
// Labels: client_ip, server
// Labels: client_ip, server_ip
dlTp *prometheus.GaugeVec
// Download latency
// Value: latency in secs
// Labels: client_ip, server
// Labels: client_ip, server_ip
dlLat *prometheus.GaugeVec
// Upload throughput
// Value: throughput in bits/s
// Labels: client_ip, server
// Labels: client_ip, server_ip
ulTp *prometheus.GaugeVec
// Upload latency
// Value: latency in secs
// Labels: client_ip, server
// Labels: client_ip, server_ip
ulLat *prometheus.GaugeVec
// Last results
// Value: time in seconds since unix epoch
Expand Down Expand Up @@ -76,18 +75,16 @@ func (p Prometheus) OnComplete(test spec.TestKind) error {

// OnSummary handles the summary event, emitted after the test is over.
func (p *Prometheus) OnSummary(s *Summary) error {
server := fmt.Sprintf("%s:%s", s.ServerIP, s.ServerPort)

// Note this assumes download and upload throughput units are Mbit/s
// and latency units are msecs.
p.dlTp.Reset()
p.dlTp.WithLabelValues(s.ClientIP, server).Set(s.Download.Throughput.Value * 1000.0 * 1000.0)
p.dlTp.WithLabelValues(s.ClientIP, s.ServerIP).Set(s.Download.Throughput.Value * 1000.0 * 1000.0)
p.dlLat.Reset()
p.dlLat.WithLabelValues(s.ClientIP, server).Set(s.Download.Latency.Value / 1000.0)
p.dlLat.WithLabelValues(s.ClientIP, s.ServerIP).Set(s.Download.Latency.Value / 1000.0)
p.ulTp.Reset()
p.ulTp.WithLabelValues(s.ClientIP, server).Set(s.Upload.Throughput.Value * 1000.0 * 1000.0)
p.ulTp.WithLabelValues(s.ClientIP, s.ServerIP).Set(s.Upload.Throughput.Value * 1000.0 * 1000.0)
p.ulLat.Reset()
p.ulLat.WithLabelValues(s.ClientIP, server).Set(s.Upload.Latency.Value / 1000.0)
p.ulLat.WithLabelValues(s.ClientIP, s.ServerIP).Set(s.Upload.Latency.Value / 1000.0)

return p.emitter.OnSummary(s)
}
6 changes: 0 additions & 6 deletions internal/emitter/summary.go
Expand Up @@ -29,15 +29,9 @@ type Summary struct {
// ServerIP is the (v4 or v6) IP address of the server.
ServerIP string

// ServerPort is the port of the server.
ServerPort string

// ClientIP is the (v4 or v6) IP address of the client.
ClientIP string

// ClientIP is the port of the client.
ClientPort string

// Download is a summary of the download subtest.
Download *SubtestSummary

Expand Down

0 comments on commit 3219dcc

Please sign in to comment.