Skip to content

Commit 5036b62

Browse files
authored
refactor: smoke test improvements (#600)
* docs: add smoke check refactor design * docs: add smoke check refactor implementation plan * test(smoke): add pure helpers resolveRLevels and countByteDiff with tests * test(smoke): cover symmetric byte-diff and empty non-nil rlevels * refactor(smoke): consolidate outcome counters and decompose run loop * fix(smoke): scope per-attempt timeout cancel to satisfy go vet * refactor(smoke): extract repeated retry log format into constant * chore: rename fail->error
1 parent f84bf70 commit 5036b62

3 files changed

Lines changed: 265 additions & 246 deletions

File tree

pkg/check/smoke/metrics.go

Lines changed: 22 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,91 +6,52 @@ import (
66
)
77

88
type metrics struct {
9-
BatchCreateErrors prometheus.Counter
10-
BatchCreateAttempts prometheus.Counter
11-
UploadErrors *prometheus.CounterVec
12-
UploadAttempts *prometheus.CounterVec
13-
UploadSuccess *prometheus.CounterVec
14-
DownloadErrors *prometheus.CounterVec
15-
DownloadMismatch *prometheus.CounterVec
16-
DownloadAttempts *prometheus.CounterVec
17-
DownloadSuccess *prometheus.CounterVec
18-
UploadDuration *prometheus.HistogramVec
19-
DownloadDuration *prometheus.HistogramVec
20-
UploadThroughput *prometheus.GaugeVec
21-
DownloadThroughput *prometheus.GaugeVec
22-
UploadedBytes *prometheus.CounterVec
23-
DownloadedBytes *prometheus.CounterVec
9+
BatchCreate *prometheus.CounterVec
10+
Upload *prometheus.CounterVec
11+
Download *prometheus.CounterVec
12+
UploadDuration *prometheus.HistogramVec
13+
DownloadDuration *prometheus.HistogramVec
14+
UploadThroughput *prometheus.GaugeVec
15+
DownloadThroughput *prometheus.GaugeVec
16+
UploadedBytes *prometheus.CounterVec
17+
DownloadedBytes *prometheus.CounterVec
2418
}
2519

2620
const (
2721
labelSizeBytes = "size_bytes"
2822
labelNodeName = "node_name"
2923
labelRedundancyLevel = "redundancy_level"
24+
labelResult = "result"
3025
)
3126

3227
func newMetrics(subsystem string) metrics {
3328
return metrics{
34-
BatchCreateAttempts: prometheus.NewCounter(
29+
BatchCreate: prometheus.NewCounterVec(
3530
prometheus.CounterOpts{
3631
Namespace: m.Namespace,
3732
Subsystem: subsystem,
38-
Name: "batch_create_attempts",
39-
Help: "Number of batch create attempts.",
33+
Name: "batch_total",
34+
Help: "Number of batch create attempts by result.",
4035
},
36+
[]string{labelResult},
4137
),
42-
BatchCreateErrors: prometheus.NewCounter(
38+
Upload: prometheus.NewCounterVec(
4339
prometheus.CounterOpts{
4440
Namespace: m.Namespace,
4541
Subsystem: subsystem,
46-
Name: "batch_create_errors",
47-
Help: "Total errors encountered while creating batches.",
42+
Name: "upload_total",
43+
Help: "Number of upload attempts by result.",
4844
},
45+
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel, labelResult},
4946
),
50-
UploadAttempts: prometheus.NewCounterVec(
47+
Download: prometheus.NewCounterVec(
5148
prometheus.CounterOpts{
5249
Namespace: m.Namespace,
5350
Subsystem: subsystem,
54-
Name: "upload_attempts",
55-
Help: "Number of upload attempts.",
51+
Name: "download_total",
52+
Help: "Number of download attempts by result.",
5653
},
57-
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
58-
),
59-
DownloadAttempts: prometheus.NewCounterVec(
60-
prometheus.CounterOpts{
61-
Namespace: m.Namespace,
62-
Subsystem: subsystem,
63-
Name: "download_attempts",
64-
Help: "Number of download attempts.",
65-
},
66-
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
67-
),
68-
UploadErrors: prometheus.NewCounterVec(
69-
prometheus.CounterOpts{
70-
Namespace: m.Namespace,
71-
Subsystem: subsystem,
72-
Name: "upload_errors_count",
73-
Help: "The total number of errors encountered before successful upload.",
74-
},
75-
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
76-
),
77-
DownloadErrors: prometheus.NewCounterVec(
78-
prometheus.CounterOpts{
79-
Namespace: m.Namespace,
80-
Subsystem: subsystem,
81-
Name: "download_errors_count",
82-
Help: "The total number of errors encountered before successful download.",
83-
},
84-
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
85-
),
86-
DownloadMismatch: prometheus.NewCounterVec(
87-
prometheus.CounterOpts{
88-
Namespace: m.Namespace,
89-
Subsystem: subsystem,
90-
Name: "download_mismatch",
91-
Help: "The total number of times uploaded data is different from downloaded data.",
92-
},
93-
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
54+
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel, labelResult},
9455
),
9556
UploadDuration: prometheus.NewHistogramVec(
9657
prometheus.HistogramOpts{
@@ -130,24 +91,6 @@ func newMetrics(subsystem string) metrics {
13091
},
13192
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
13293
),
133-
UploadSuccess: prometheus.NewCounterVec(
134-
prometheus.CounterOpts{
135-
Namespace: m.Namespace,
136-
Subsystem: subsystem,
137-
Name: "upload_success",
138-
Help: "Number of successful uploads.",
139-
},
140-
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
141-
),
142-
DownloadSuccess: prometheus.NewCounterVec(
143-
prometheus.CounterOpts{
144-
Namespace: m.Namespace,
145-
Subsystem: subsystem,
146-
Name: "download_success",
147-
Help: "Number of successful downloads with matching data.",
148-
},
149-
[]string{labelSizeBytes, labelNodeName, labelRedundancyLevel},
150-
),
15194
UploadedBytes: prometheus.NewCounterVec(
15295
prometheus.CounterOpts{
15396
Namespace: m.Namespace,

0 commit comments

Comments
 (0)