def METHOD_NAME(self):
    """Writes all metrics to directory specified in config and resets counters"""
    try:
        metrics_dict = {}
        with self.rpc_counter_lock:
            if self.predict_rpc_counter:
                metrics_dict = {
                    "timestamp": time.time(),
                    "batch_size": len(self.predict_rpc_counter),
                    "model_type_counters": Counter(self.predict_rpc_counter),
                    "container_id": self.unique_id,
                }
                self.predict_rpc_counter.clear()
                log.debug("<RUN76774004I>", "predict_rpc_counter reset")
        if metrics_dict:
            with self.write_file_lock:
                json_string = json.dumps(metrics_dict)
                with open(self.file_path, "a", encoding="utf-8") as json_file:
                    json_file.write(json_string + "\n")
            # Log the metrics dict to stdout as well for later scraping if required
            log.info("<RUN76774008I>", metrics_dict)
            log.info(
                "<RUN76774005I>",
                "Successfully written metrics file to %s",
                self.file_path,
            )
        else:
            log.info(
                "<RUN76774006I>", "No new RPCs to write, skipping metering logging"
            )
    except json.JSONDecodeError as e:
        log.info("<RUN76774007I>", "Write metrics failed with %s", str(e))
    except FileNotFoundError as e:
        log.info("<RUN76774007I>", "Write metrics failed with %s", str(e))