Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b3fc67

Browse files
committed
use atomic add for total bytes value
Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parent2ebd4ae commit8b3fc67

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

‎scaletest/workspacetraffic/metrics.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package workspacetraffic
22

3-
import"github.com/prometheus/client_golang/prometheus"
3+
import (
4+
"sync/atomic"
5+
6+
"github.com/prometheus/client_golang/prometheus"
7+
)
48

59
typeMetricsstruct {
610
BytesReadTotal prometheus.CounterVec
@@ -75,7 +79,7 @@ type ConnMetrics interface {
7579
AddError(float64)
7680
ObserveLatency(float64)
7781
AddTotal(float64)
78-
GetTotal()int64
82+
GetTotalBytes()int64
7983
}
8084

8185
typeconnMetricsstruct {
@@ -94,10 +98,10 @@ func (c *connMetrics) ObserveLatency(f float64) {
9498
}
9599

96100
func (c*connMetrics)AddTotal(ffloat64) {
97-
c.total+=int64(f)
101+
atomic.AddInt64(&c.total,int64(f))
98102
c.addTotal(f)
99103
}
100104

101-
func (c*connMetrics)GetTotal()int64 {
105+
func (c*connMetrics)GetTotalBytes()int64 {
102106
returnc.total
103107
}

‎scaletest/workspacetraffic/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ func (r *Runner) Run(ctx context.Context, _ string, logs io.Writer) (err error)
211211
}
212212

213213
func (r*Runner)GetBytesTransferred() (bytesRead,bytesWrittenint64) {
214-
bytesRead=r.cfg.ReadMetrics.GetTotal()
215-
bytesWritten=r.cfg.WriteMetrics.GetTotal()
214+
bytesRead=r.cfg.ReadMetrics.GetTotalBytes()
215+
bytesWritten=r.cfg.WriteMetrics.GetTotalBytes()
216216
returnbytesRead,bytesWritten
217217
}
218218

‎scaletest/workspacetraffic/run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,6 @@ func (m *testMetrics) Latencies() []float64 {
423423
returnm.latencies
424424
}
425425

426-
func (m*testMetrics)GetTotal()int64 {
426+
func (m*testMetrics)GetTotalBytes()int64 {
427427
returnint64(m.total)
428428
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp