How to use the @opentelemetry/core.parseTraceParent function in @opentelemetry/core

To help you get started, we’ve selected a few @opentelemetry/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-js / packages / opentelemetry-plugin-document-load / src / documentLoad.ts View on Github external
private _collectPerformance() {
    const metaElement = [...document.getElementsByTagName('meta')].find(
      e => e.getAttribute('name') === TRACE_PARENT_HEADER
    );

    const entries = this._getEntries();

    const rootSpan = this._startSpan(
      AttributeNames.DOCUMENT_LOAD,
      PTN.FETCH_START,
      entries,
      { parent: parseTraceParent((metaElement && metaElement.content) || '') }
    );
    if (!rootSpan) {
      return;
    }
    const fetchSpan = this._startSpan(
      AttributeNames.DOCUMENT_FETCH,
      PTN.FETCH_START,
      entries,
      {
        parent: rootSpan,
      }
    );
    if (fetchSpan) {
      this._addSpanNetworkEvents(fetchSpan, entries);
      this._endSpan(fetchSpan, PTN.RESPONSE_END, entries);
    }