as seen on the screenshot above, I want to get the number 8 on a specific moment in the script. e.g. tracking the vus count before request and after request.
var activeUser = new Trend('activeUser');
export default function() {
var data,
userCountBefore,
userCountAfter,
res = ws.connect(wsUrl, params, socket => {
socket.on('open', () => {
userCountBefore = __VUSCOUNT; // assume this is how to get the vus count
activeUser.add(userCountBefore, {time: 'before'});
socket.on('message', msg => {
data = JSON.parse(msg)
switch (data.type) {
case 'connected':
return socket.send(JSON.stringify({type: 'find'}));
case 'found':
userCountAfter = __VUSCOUNT;
activeUser.add(userCountAfter, {time: 'after'});
socket.close();
}
});
});
});
}
Also there’s another case that as far I know, I cannot do it because it’s not possible to get the custom metrics value from the script. Initially I want to get the maximum waiting user count for response at a time. It can be done if custom metrics is accessible by using gauge and counter.
I’m not sure I grok your use case exactly, but given the fact you’re using an arrival-rate executor, you should be able to use customMetric.add(+1) at the start of your iteration, and customMetric.add(-1) at its end. That would give you the amount of currently running VUs at any given point in time, if you use some external output. Then you should be able to correlate that with any script logic you want, I think…