faro-web-sdk icon indicating copy to clipboard operation
faro-web-sdk copied to clipboard

`tracestate` headers are not propagated

Open alioshr opened this issue 2 years ago • 6 comments

Description

Based on issue #131 I have managed to get partially propagate cors trace headers. I expected to also get the tracestate header propagated, but I am only getting the traceparent header propagated.

Steps to reproduce

Initialize faro as per on #131:

import {
  initializeFaro as coreInit,
  getWebInstrumentations,
  ReactIntegration,
  ReactRouterVersion,
  Faro,
  FetchTransport,
  ConsoleTransport,
  ReactRouterHistory,
} from '@grafana/faro-react';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';
import { DocumentLoadInstrumentation } from '@opentelemetry/instrumentation-document-load';
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
import { UserInteractionInstrumentation } from '@opentelemetry/instrumentation-user-interaction';
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
import { Route } from 'react-router-dom';
import { shouldCollect } from './utils';
import { History } from 'history';

export async function initializeFaro(browserHistory: History): Promise<Faro> {
  // prevent faro from sending metrics on development
  if (!shouldCollect()) return null;

  const COLLECTOR_URL = 'some-url';
  const ignoreUrls = [COLLECTOR_URL];
  const propagateTraceHeaderCorsUrls = [new RegExp('my-apis-urls-pattern')];

  const faro = coreInit({
    instrumentations: [
      ...getWebInstrumentations({
        captureConsole: true,
      }),
      new TracingInstrumentation({
        instrumentations: [
          new DocumentLoadInstrumentation(),
          new FetchInstrumentation({
            ignoreUrls,
            propagateTraceHeaderCorsUrls,
          }),
          new XMLHttpRequestInstrumentation({
            ignoreUrls,
            propagateTraceHeaderCorsUrls,
          }),
          new UserInteractionInstrumentation(),
        ],
        resourceAttributes: {
          'service.name': config.global.FARO_SERVICE,
          'team.name': process.env.REACT_APP_FARO_TEAM,
        },
      }),
      new ReactIntegration({
        router: {
          version: ReactRouterVersion.V5,
          dependencies: {
            history: browserHistory as ReactRouterHistory,
            Route,
          },
        },
      }),
    ],
    session: (window as any).__PRELOADED_STATE__?.faro?.session,
    app: {
      name: config.global.FARO_SERVICE,
      version: process.env.REACT_APP_VERSION,
      environment: undefined,
      release: process.env.REACT_APP_FARO_TEAM,
    },
    user: {
      username: 'some-username',
    },
    transports: [
      new FetchTransport({
        url: COLLECTOR_URL,
        apiKey: config.global.FARO_SECRET,
      }),
      new ConsoleTransport(),
    ],
  });

  faro.api.pushLog(['Faro was initialized']);
  return faro;
}

Expected behavior

Would like to see tracestate header propagated, or have a documented way of doing so.

Actual behavior

With the workaround I just manage to propagate traceparent header

Environment

  • SDK version: 1.0.2
  • SDK instrumentations: React
  • Device type: desktop
  • Device name: MacBook Air M1 13"
  • **OS:**MacOS
  • **Browser:**Chrome

alioshr avatar Apr 19 '23 18:04 alioshr

Hi @alioshr thank you for the bug report.

Would you please add the following information:

  • Web-SDK version
  • OS and Browser (Vendor + Version)

codecapitano avatar Apr 20 '23 13:04 codecapitano

Hy @codecapitano ! Thanks for replying back to me once again.

I have added the environment info and also the config used to initialize faro

alioshr avatar Apr 20 '23 16:04 alioshr

Hi @codecapitano. Could you please confirm if you need more info?

alioshr avatar May 08 '23 12:05 alioshr

Hi @alioshr thanks a lot. This looks good.

codecapitano avatar May 09 '23 10:05 codecapitano

hey @codecapitano. Did you ever manage to look into this issue?

alioshr avatar Mar 06 '24 19:03 alioshr

Hi @alioshr, unfortunately not.

codecapitano avatar Mar 11 '24 08:03 codecapitano