Spans are sent after custom transaction is closed (Node.js APM agent)

To be crystal clear - I do promisify the flush call :slight_smile:

apmWrapper.flush() stands for:

  /**
   * @return {Promise}
   */
  flush() {
    return new Promise((resolve, reject) =>
      this.agent.flush(err => err ? reject(err) : resolve()));
  }

As for my use-case - I have a relatively small script (as one of the components of my system), which is run periodically by cron. So once it's done its work, it exits (until the next cron run).

I'm trying to gather some metrics from it via Elastic APM to have it all in one place.