How do i measure the concurrency of outgoing calls in K6?

I was trying to use metric gauge type to keep track of the concurrency , but it looks like it has only one method to add the current value , ideally i would have used it to increment and decrement the values to keep track of the concurrency.
Since gauge doesnt support it , how to achieve this when there are parallel VUs all running in their own copy of the variables ?

Hi @rahulgouthamgs !

Welcome to the community forums! :wave:

I’m unsure if I’m getting what you mean when you say you want to keep track of the concurrency. Could you please elaborate on it, maybe give more details on the case?

Cheers!

Hi @olegbespalov , I am using constant-arrival-rate executor and want to find out how many outstanding http or grpc calls are active at any point of time.

Hi @rahulgouthamgs !

Sorry for the long delay.

On top of my head, I don’t think that there is a straightforward way of doing that :thinking:

So, the workaround is to sync the values across the VU. For that, you could try using some xk6 extensions that could help to keep the value and later use Gauge metric. For that you have to bundle k6 with the extension.

For example, I just created the PoC of extension’s using so you could have counters sharable across the VUs GitHub - olegbespalov/xk6-atomic.

You can build the k6 with that (golang, xk6, git required):

xk6 build v0.47.0 --with github.com/olegbespalov/xk6-atomic

And later use, like:

import { Counter } from 'k6/x/atomic';

let counter = new Counter("some_id");

export default () => {
   // increase and store the current value
   let current = counter.inc();
   console.log("__VU:", __VU, "__ITER:", __ITER, ` current value is: ${current}`);
}

Let me know if that works for you
Cheers!