async export()

in packages/opentelemetry-cloud-trace-exporter/src/trace.ts [76:106]


  async export(
    spans: ReadableSpan[],
    resultCallback: (result: ExportResult) => void
  ): Promise<void> {
    if (this._projectId instanceof Promise) {
      this._projectId = await this._projectId;
    }

    if (!this._projectId) {
      return resultCallback({
        code: ExportResultCode.FAILED,
        error: new Error('Was not able to determine GCP project ID'),
      });
    }

    diag.debug('Google Cloud Trace export');

    const namedSpans: NamedSpans = {
      name: `projects/${this._projectId}`,
      spans: spans.map(
        getReadableSpanTransformer(
          this._projectId,
          this._resourceFilter,
          this._stringifyArrayAttributes
        )
      ),
    };

    const result = await this._batchWriteSpans(namedSpans);
    resultCallback(result);
  }