How to get HTTP request ID in the test

Hi there,

While doing HTTP test, I can see (with --http-debug switch enabled), I can see every request has a request_id. How can I use this ID in my test script? The use case is to use the same ID in the HTTP request header (i.e. X-Request-Id). Is that possible?
Thanks.

Best,
Rad

hi @riffsmalts

I believe wich you use exec.scenario.iterationInTest, solve this issue. Try this example:

import exec from 'k6/execution':

export default function () {
  const url = `https://foo.bar/${exec.scenario.iterationInTest}`;
  http.get(url)
}

Hi @riffsmalts

Unfortunately, no, there is no access to the request_id from inside the scripts, they generate & printed out only when --http-debug is enabled for the debugging purposes.

I hope that answers