File tree Expand file tree Collapse file tree 3 files changed +16
-18
lines changed Expand file tree Collapse file tree 3 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,13 @@ The released binary is expected to run in containers or linux-like hosts of `amd
8
8
For Windows 10+ environments you can run it in WSL2.
9
9
For other environments, please build your version from sources.
10
10
11
- ### Get the pre-build extended K6 binary
11
+ ### Build K6 binary
12
12
13
- - Find the [ latest release}(https://github.com/mdsol/xk6-output-otlp/releases ).
14
- - Download ` k6.tar.gz ` archive, and extract the ` k6 ` binary with
13
+ You should have ` Go 1.22+ ` and ` make ` installed.
15
14
16
- ``` sh
17
- tar -xvzf k6.tar.gz
18
- ```
15
+ - clone the [ repository ] ( https://github.com/mdsol/xk6-output-otlp ) using git;
16
+ - run ` make build ` ;
17
+ - the ` k6 ` binary is in the project's ` ./bin ` subfolder.
19
18
20
19
### Configuration
21
20
@@ -71,7 +70,7 @@ If `<name>` is a name of the original rate metric, it produces:
71
70
72
71
- ` k6_<name>_total ` OTLP counter which contains the total number of occurrences;
73
72
- ` k6_<name>_success_total ` OTLP counter which contains the total number of successful occurrences;
74
- - ` k6_<name>_success_rate ` OTLP Gauge, which contains the pre-computed rate.
73
+ - ` k6_<name>_success_rate ` OTLP Gauge, which contains the pre-computed rate over the whole metric family .
75
74
76
75
The latest pre-computed rate value should match appropriate K6 output.
77
76
Original file line number Diff line number Diff line change @@ -5,19 +5,19 @@ import (
5
5
)
6
6
7
7
type rate struct {
8
- sum float64
9
- count float64
8
+ sum float64
9
+ counter float64
10
10
}
11
11
12
12
func (r * rate ) value () float64 {
13
- if r .count == 0 {
13
+ if r .counter == 0 {
14
14
return 0
15
15
}
16
- return r .sum / r .count
16
+ return r .sum / r .counter
17
17
}
18
18
19
19
func (r * rate ) combine (sample * k6m.Sample ) float64 {
20
- r .count += 1.0
20
+ r .counter += 1.0
21
21
r .sum += sample .Value
22
22
return r .value ()
23
23
}
Original file line number Diff line number Diff line change 8
8
)
9
9
10
10
func newRateWrapper (id int , name string ) (Wrapper , error ) {
11
- metricTotal , err := meter .Int64Counter (name )
11
+ metricTotal , err := meter .Int64Counter (name + "_total" )
12
12
if err != nil {
13
13
return nil , err
14
14
}
@@ -42,10 +42,9 @@ type rateWrapper struct {
42
42
func (w * rateWrapper ) Record (s * k6m.Sample ) {
43
43
attrs := om .WithAttributes (attributes (s .TimeSeries .Tags )... )
44
44
45
- w . metricRate . Record ( params . ctx , w . rate . combine ( s ), attrs )
46
- w .metricTotal . Add (params .ctx , int64 ( math . Floor ( s . Value ) ))
45
+ // Here we count rate over whole metric family as we see the result in the K6 output.
46
+ w .metricRate . Record (params .ctx , w . rate . combine ( s ), om . WithAttributes ( sessionAttrs ... ))
47
47
48
- if s .Value == 1 {
49
- w .metricSuccess .Add (params .ctx , int64 (math .Floor (s .Value )), attrs )
50
- }
48
+ w .metricTotal .Add (params .ctx , 1 , attrs )
49
+ w .metricSuccess .Add (params .ctx , int64 (math .Floor (s .Value )), attrs )
51
50
}
You can’t perform that action at this time.
0 commit comments