static flush()

in src/trace/context/SpanContext.ts [236:246]


  static flush(): Promise<any> | null {
    // This function explicitly returns null instead of a resolved Promise in case of nothing to flush so that in this
    // case passing control back to the event loop can be avoided. Even a resolved Promise will run other things in
    // the event loop when it is awaited and before it continues.

    return !SpanContext.nTotalSegments
      ? null
      : new Promise((resolve: (value: unknown) => void) => {
          SpanContext.flushResolve.push(resolve);
        });
  }