Skip to content

Commit bc61ed8

Browse files
authored
check-smoke: add node name label to metrics (#529)
1 parent ae823b3 commit bc61ed8

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

pkg/check/smoke/metrics.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ type metrics struct {
1919
DownloadThroughput *prometheus.GaugeVec
2020
}
2121

22-
const labelSizeBytes = "size_bytes"
22+
const (
23+
labelSizeBytes = "size_bytes"
24+
labelNodeName = "node_name"
25+
)
2326

2427
func newMetrics(subsystem string) metrics {
2528
return metrics{
@@ -46,7 +49,7 @@ func newMetrics(subsystem string) metrics {
4649
Name: "upload_attempts",
4750
Help: "Number of upload attempts.",
4851
},
49-
[]string{labelSizeBytes},
52+
[]string{labelSizeBytes, labelNodeName},
5053
),
5154
DownloadAttempts: prometheus.NewCounterVec(
5255
prometheus.CounterOpts{
@@ -55,7 +58,7 @@ func newMetrics(subsystem string) metrics {
5558
Name: "download_attempts",
5659
Help: "Number of download attempts.",
5760
},
58-
[]string{labelSizeBytes},
61+
[]string{labelSizeBytes, labelNodeName},
5962
),
6063
UploadErrors: prometheus.NewCounterVec(
6164
prometheus.CounterOpts{
@@ -64,7 +67,7 @@ func newMetrics(subsystem string) metrics {
6467
Name: "upload_errors_count",
6568
Help: "The total number of errors encountered before successful upload.",
6669
},
67-
[]string{labelSizeBytes},
70+
[]string{labelSizeBytes, labelNodeName},
6871
),
6972
DownloadErrors: prometheus.NewCounterVec(
7073
prometheus.CounterOpts{
@@ -73,7 +76,7 @@ func newMetrics(subsystem string) metrics {
7376
Name: "download_errors_count",
7477
Help: "The total number of errors encountered before successful download.",
7578
},
76-
[]string{labelSizeBytes},
79+
[]string{labelSizeBytes, labelNodeName},
7780
),
7881
DownloadMismatch: prometheus.NewCounterVec(
7982
prometheus.CounterOpts{
@@ -82,7 +85,7 @@ func newMetrics(subsystem string) metrics {
8285
Name: "download_mismatch",
8386
Help: "The total number of times uploaded data is different from downloaded data.",
8487
},
85-
[]string{labelSizeBytes},
88+
[]string{labelSizeBytes, labelNodeName},
8689
),
8790
UploadDuration: prometheus.NewHistogramVec(
8891
prometheus.HistogramOpts{
@@ -91,7 +94,7 @@ func newMetrics(subsystem string) metrics {
9194
Name: "data_upload_duration",
9295
Help: "Data upload duration through the /bytes endpoint.",
9396
},
94-
[]string{labelSizeBytes},
97+
[]string{labelSizeBytes, labelNodeName},
9598
),
9699
DownloadDuration: prometheus.NewHistogramVec(
97100
prometheus.HistogramOpts{
@@ -100,7 +103,7 @@ func newMetrics(subsystem string) metrics {
100103
Name: "data_download_duration",
101104
Help: "Data download duration through the /bytes endpoint.",
102105
},
103-
[]string{labelSizeBytes},
106+
[]string{labelSizeBytes, labelNodeName},
104107
),
105108
UploadThroughput: prometheus.NewGaugeVec(
106109
prometheus.GaugeOpts{
@@ -109,7 +112,7 @@ func newMetrics(subsystem string) metrics {
109112
Name: "upload_throughput_bytes_per_second",
110113
Help: "Upload throughput in bytes per second.",
111114
},
112-
[]string{labelSizeBytes},
115+
[]string{labelSizeBytes, labelNodeName},
113116
),
114117
DownloadThroughput: prometheus.NewGaugeVec(
115118
prometheus.GaugeOpts{
@@ -118,7 +121,7 @@ func newMetrics(subsystem string) metrics {
118121
Name: "download_throughput_bytes_per_second",
119122
Help: "Download throughput in bytes per second.",
120123
},
121-
[]string{labelSizeBytes},
124+
[]string{labelSizeBytes, labelNodeName},
122125
),
123126
}
124127
}

pkg/check/smoke/smoke.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ func (c *Check) run(ctx context.Context, cluster orchestration.Cluster, o Option
189189

190190
c.logger.WithField("batch_id", batchID).Infof("using batch for size %d", contentSize)
191191

192-
c.metrics.UploadAttempts.WithLabelValues(sizeLabel).Inc()
192+
c.metrics.UploadAttempts.WithLabelValues(sizeLabel, txName).Inc()
193193
address, txDuration, err = test.upload(txCtx, txName, txData, batchID)
194194
if err != nil {
195-
c.metrics.UploadErrors.WithLabelValues(sizeLabel).Inc()
195+
c.metrics.UploadErrors.WithLabelValues(sizeLabel, txName).Inc()
196196
c.logger.Infof("upload failed for size %d: %v", contentSize, err)
197197
c.logger.Infof("retrying in: %v", o.TxOnErrWait)
198198
} else {
@@ -206,12 +206,12 @@ func (c *Check) run(ctx context.Context, cluster orchestration.Cluster, o Option
206206
continue
207207
}
208208

209-
c.metrics.UploadDuration.WithLabelValues(sizeLabel).Observe(txDuration.Seconds())
209+
c.metrics.UploadDuration.WithLabelValues(sizeLabel, txName).Observe(txDuration.Seconds())
210210

211211
// Calculate and record upload throughput in bytes per second
212212
if txDuration.Seconds() > 0 {
213213
uploadThroughput := float64(contentSize) / txDuration.Seconds()
214-
c.metrics.UploadThroughput.WithLabelValues(sizeLabel).Set(uploadThroughput)
214+
c.metrics.UploadThroughput.WithLabelValues(sizeLabel, txName).Set(uploadThroughput)
215215
}
216216
c.logger.Infof("upload completed for size %d in %s", contentSize, txDuration)
217217

@@ -231,32 +231,32 @@ func (c *Check) run(ctx context.Context, cluster orchestration.Cluster, o Option
231231
case <-time.After(o.RxOnErrWait):
232232
}
233233

234-
c.metrics.DownloadAttempts.WithLabelValues(sizeLabel).Inc()
234+
c.metrics.DownloadAttempts.WithLabelValues(sizeLabel, rxName).Inc()
235235

236236
rxCtx, rxCancel = context.WithTimeout(ctx, o.DownloadTimeout)
237237
rxData, rxDuration, err = test.download(rxCtx, rxName, address)
238238
if err != nil {
239-
c.metrics.DownloadErrors.WithLabelValues(sizeLabel).Inc()
239+
c.metrics.DownloadErrors.WithLabelValues(sizeLabel, rxName).Inc()
240240
c.logger.Infof("download failed for size %d: %v", contentSize, err)
241241
c.logger.Infof("retrying in: %v", o.RxOnErrWait)
242242
continue
243243
}
244244

245245
// good download
246246
if bytes.Equal(rxData, txData) {
247-
c.metrics.DownloadDuration.WithLabelValues(sizeLabel).Observe(rxDuration.Seconds())
247+
c.metrics.DownloadDuration.WithLabelValues(sizeLabel, rxName).Observe(rxDuration.Seconds())
248248

249249
if rxDuration.Seconds() > 0 {
250250
downloadThroughput := float64(contentSize) / rxDuration.Seconds()
251-
c.metrics.DownloadThroughput.WithLabelValues(sizeLabel).Set(downloadThroughput)
251+
c.metrics.DownloadThroughput.WithLabelValues(sizeLabel, rxName).Set(downloadThroughput)
252252
}
253253
c.logger.Infof("download completed for size %d in %s", contentSize, rxDuration)
254254
break
255255
}
256256

257257
// bad download
258258
c.logger.Infof("uploaded data does not match downloaded data for size %d", contentSize)
259-
c.metrics.DownloadMismatch.WithLabelValues(sizeLabel).Inc()
259+
c.metrics.DownloadMismatch.WithLabelValues(sizeLabel, rxName).Inc()
260260

261261
rxLen, txLen := len(rxData), len(txData)
262262
if rxLen != txLen {

0 commit comments

Comments
 (0)