Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Include web-tracing into the default instrumentations #958

Closed
wants to merge 5 commits into from

Conversation

codecapitano
Copy link
Collaborator

@codecapitano codecapitano commented Feb 12, 2025

Why

Work in process

For easy of use include the web-tracing instrumentation in the default instrumentations.

For existing users we need to ensure that Faro takes up their already configured
Faro detects duplicated instrumentations and ensures that only one is initialized.
But it uses the first instrument it finds, so it would always pick up the default instrument.
-> Ensure that the user configured instrument takes precedence.

This how the config changes:**

new way with web-tracing auto instrumentation if no customization is needed

  const faro = coreInit({
    url: `http://localhost:${env.faro.portAppReceiver}/collect`,
    apiKey: env.faro.apiKey,
    trackWebVitalsAttribution: true,
    app: {
      name: env.client.packageName,
      namespace: env.client.packageNamespace,
      version: env.package.version,
      environment: env.mode.name,
    },
  });

New way, with web-tracing auto instrumentation and additional tracing configuration

initializeFaro({
    url: `http://localhost:${env.faro.portAppReceiver}/collect`,
    apiKey: env.faro.apiKey,
    trackWebVitalsAttribution: true,
    app: {
      name: env.client.packageName,
      namespace: env.client.packageNamespace,
      version: env.package.version,
      environment: env.mode.name,
    },

    webTracingInstrumentation: {
      enabled: true, // default true
      instrumentationOptions: {
        propagateTraceHeaderCorsUrls: ['...'],
        fetchInstrumentationOptions: {
          ignoreNetworkEvents: true,
        },
      },
    },
  });

Current state

initializeFaro({
    url: `http://localhost:${env.faro.portAppReceiver}/collect`,
    apiKey: env.faro.apiKey,
    trackWebVitalsAttribution: true,
    instrumentations: [
      ...getWebInstrumentations({
        captureConsole: true,
      }),

      new TracingInstrumentation({
        instrumentationOptions: {
          propagateTraceHeaderCorsUrls: ['...'],
          fetchInstrumentationOptions: {
            ignoreNetworkEvents: true,
          },
        },
      }),
    ],
    app: {
      name: env.client.packageName,
      namespace: env.client.packageNamespace,
      version: env.package.version,
      environment: env.mode.name,
    },
  });

What

Links

Checklist

  • Tests added
  • Changelog updated
  • Documentation updated

@codecapitano codecapitano changed the title Include-web-tracing-in-the-web-sdk feat: Include web-tracing into the default instrumentations Feb 12, 2025
@codecapitano
Copy link
Collaborator Author

Starting a new PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant