How to access response tags

The tags don’t seem to be a part of the response object, so how can I access these after I set them?

response = http.get(`http://${tenant}.${environment}.${domain}/`, {
    tags: {
      name: `${stepNum} - http://${tenant}.${environment}.${domain}/`
    },
  });

Hi there,

you’re right, there’s no way to access tags from the response object. Tags are really a concept for metrics emitted for the request and it wouldn’t make sense for them to be defined on the response, but I suppose they could be exposed as response.request.tags, just like headers and cookies are accessible now.

In the meantime, you could workaround this with a small wrapper around k6/http that returns them for you. Something like:

function getWithTags(url) {
  let tags = {name: `${stepNum} - http://${tenant}.${environment}.${domain}/`};
  let res = http.get(url, {tags: tags});
  return {response: res, tags: tags};
}

export default function() {
  let res = getWithTags(`http://${tenant}.${environment}.${domain}/`);
  console.log(JSON.stringify(res.tags));
}

This is a useless example, but the idea is that you can return the response along with any tags that were set on the request from a single place.