code: private void writeToWithMetrics(final OutputStream outstream) throws IOException {
          if (outstream == null) {
              throw new IllegalArgumentException("Output stream may not be null");
          }
          final InputStream content = getContent();
          final long length = getContentLength();
          InputStream instream = content;
          try {
              byte[] buffer = new byte[BUFFER_SIZE];
              int l;
              if (length < 0) {
                  // consume until EOF
                  while ((l = instream.read(buffer)) != -1) {
                      long startNano = helper.startTiming();
                      outstream.write(buffer, 0, l);
                      helper.increment(l, startNano);
                  }
              } else {
                  // consume no more than length
                  long remaining = length;
                  while (remaining > 0) {
                      l = instream.read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
                      if (l == -1) {
                          break;
                      }
                      long startNano = helper.startTiming();
                      outstream.write(buffer, 0, l);
                      helper.increment(l, startNano);
                      remaining -= l;
                  }
              }
          } finally {
              helper.reportMetrics();
              instream.close();
          }
      }
docs: Copied from {{@link InputStreamEntity#writeTo(OutputStream)} but modified
  to capture metrics for the output stream.