You need to set httpResponseCode before calling the metric.stop() method. It will fix your issue
metric.httpResponseCode = 200; // the status code returned by the server. await metric.stop();