Skip to content

Commit 982f9fd

Browse files
committed
Fix SLO latencies + refactoring
1 parent 2a21b38 commit 982f9fd

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

tests/slo/README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ SLO is the type of test where app based on ydb-sdk is tested against falling YDB
55

66
### Implementations:
77

8-
There are two implementations:
9-
10-
- `native` - `./native`
11-
- `database/sql` - `./database/sql`
8+
- `native` - over `./native` driver
9+
- `database/sql` - over `./database/sql` driver
10+
- `gorm` - over `gorm` driver
11+
- `xorm` - over `xorm` driver
1212

1313
### Usage:
1414

@@ -21,24 +21,27 @@ It has 3 commands:
2121
### Run examples with all arguments:
2222

2323
create:
24-
`slo-go-workload create create grpcs://ydb.cool.example.com:2135 /some/folder -t tableName
25-
-min-partitions-count 6 -max-partitions-count 1000 -partition-size 1 -с 1000
24+
25+
`$APP create grpcs://ydb.cool.example.com:2135 /some/folder -t tableName
26+
-min-partitions-count 6 -max-partitions-count 1000 -partition-size 1 -с 1000
2627
-write-timeout 10000`
2728

2829
cleanup:
29-
`slo-go-workload create cleanup grpcs://ydb.cool.example.com:2135 /some/folder -t tableName`
30+
31+
`$APP cleanup grpcs://ydb.cool.example.com:2135 /some/folder -t tableName`
3032

3133
run:
32-
`slo-go-workload create run grpcs://ydb.cool.example.com:2135 /some/folder -t tableName
33-
-prom-pgw http://prometheus-pushgateway:9091 -report-period 250
34-
-read-rps 1000 -read-timeout 10000
35-
-write-rps 100 -write-timeout 10000
34+
35+
`$APP create run grpcs://ydb.cool.example.com:2135 /some/folder -t tableName
36+
-prom-pgw http://prometheus-pushgateway:9091 -report-period 250
37+
-read-rps 1000 -read-timeout 10000
38+
-write-rps 100 -write-timeout 10000
3639
-time 600 -shutdown-time 30`
3740

3841
## Arguments for commands:
3942

4043
### create
41-
`slo-go-workload create <endpoint> <db> [options]`
44+
`$APP create <endpoint> <db> [options]`
4245

4346
```
4447
Arguments:
@@ -58,7 +61,7 @@ Options:
5861
```
5962

6063
### cleanup
61-
`slo-go-workload cleanup <endpoint> <db> [options]`
64+
`$APP cleanup <endpoint> <db> [options]`
6265

6366
```
6467
Arguments:
@@ -72,7 +75,7 @@ Options:
7275
```
7376

7477
### run
75-
`slo-go-workload run <endpoint> <db> [options]`
78+
`$APP run <endpoint> <db> [options]`
7679

7780
```
7881
Arguments:
@@ -99,7 +102,7 @@ Options:
99102

100103
## Authentication
101104

102-
Workload using [ydb-go-sdk-auth-environ](https://github.com/ydb-platform/ydb-go-sdk-auth-environ) for authentication.
105+
Workload using anonymous credentials.
103106

104107
## What's inside
105108
When running `run` command, the program creates three jobs: `readJob`, `writeJob`, `metricsJob`.

tests/slo/internal/metrics/metrics.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,29 @@ func (m *Metrics) Start(name SpanName) Span {
124124
func (j Span) Stop(err error, attempts int) {
125125
j.m.inflight.WithLabelValues(j.name).Sub(1)
126126

127-
l := time.Since(j.start)
127+
latency := time.Since(j.start)
128128

129129
if attempts > 1 {
130130
fmt.Printf("more than 1 attempt for request (request_type: %q, attempts: %d, start: %s, latency: %s, err: %v)\n",
131131
j.name,
132132
attempts,
133133
j.start.Format(time.DateTime),
134-
l.String(),
134+
latency.String(),
135135
err,
136136
)
137137
}
138138

139-
latency := float64(l)
139+
var (
140+
successLabel = JobStatusOK
141+
successCounter = j.m.oks
142+
)
140143

141144
if err != nil {
142-
j.m.notOks.WithLabelValues(j.name).Add(1)
143-
j.m.latencies.WithLabelValues(JobStatusErr, j.name).Observe(latency)
144-
j.m.attempts.WithLabelValues(JobStatusErr, j.name).Observe(float64(attempts))
145-
return
145+
successLabel = JobStatusErr
146+
successCounter = j.m.notOks
146147
}
147148

148-
j.m.oks.WithLabelValues(j.name).Add(1)
149-
j.m.latencies.WithLabelValues(JobStatusOK, j.name).Observe(latency)
150-
j.m.attempts.WithLabelValues(JobStatusOK, j.name).Observe(float64(attempts))
149+
j.m.latencies.WithLabelValues(successLabel, j.name).Observe(float64(latency.Milliseconds()))
150+
j.m.attempts.WithLabelValues(successLabel, j.name).Observe(float64(attempts))
151+
successCounter.WithLabelValues(j.name).Add(1)
151152
}

0 commit comments

Comments
 (0)