docs: private void writeMetrics() throws IOException {
          if (metrics.size() > 0) {
              try {
                  byte[] payload = pickleMetrics(metrics);
                  byte[] header = ByteBuffer.allocate(4).putInt(payload.length).array();
  
                  OutputStream outputStream = socket.getOutputStream();
                  outputStream.write(header);
                  outputStream.write(payload);
                  outputStream.flush();
  
                  if (LOGGER.isDebugEnabled()) {
                      LOGGER.debug("Wrote {} metrics", metrics.size());
                  }
              } catch (IOException e) {
                  this.failures++;
                  throw e;
              } finally {
                  // if there was an error, we might miss some data. for now, drop those on the floor and
                  // try to keep going.
                  metrics.clear();
              }
  
          }
      }