Skip to content

Commit

Permalink
Make data_sent work on the cloud
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel González Lopes <[email protected]>
  • Loading branch information
dgzlopes committed Oct 1, 2021
1 parent 2f3ead4 commit 01b46a5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions remote_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"go.k6.io/k6/js/modules"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/metrics"
"go.k6.io/k6/lib/netext"
"go.k6.io/k6/stats"
)

Expand Down Expand Up @@ -143,11 +144,19 @@ func (c *Client) send(ctx context.Context, state *lib.State, req []byte) (http.R
Value: float64(1),
})

stats.PushIfNotDone(ctx, state.Samples, stats.Sample{
Metric: metrics.DataSent,
Time: now,
Value: float64(binary.Size(req)),
})
simpleNetTrail := netext.NetTrail{
BytesWritten: int64(binary.Size(req)),
StartTime: now.Add(-time.Minute),
EndTime: now,
Samples: []stats.Sample{
{
Time: now,
Metric: metrics.DataSent,
Value: float64(binary.Size(req)),
},
},
}
stats.PushIfNotDone(ctx, state.Samples, &simpleNetTrail)

start := time.Now()
httpResp, err := c.client.Do(httpReq)
Expand Down

0 comments on commit 01b46a5

Please sign in to comment.