def refresh_metrics(self): """ Get the latest metrics for the tunnel and update the ``metrics`` variable. """ logger.info("Refreshing metrics for tunnel: {}".format( self.public_url)) data = api_request("{}{}".format(self.api_url, self.uri), method="GET", timeout=self.pyngrok_config.request_timeout) if "metrics" not in data: raise PyngrokError( "The ngrok API did not return \"metrics\" in the response") self.data["metrics"] = data["metrics"] self.metrics = self.data["metrics"]