sentry-docs icon indicating copy to clipboard operation
sentry-docs copied to clipboard

Update migration docs custom OTEL example

Open mydea opened this issue 1 year ago • 0 comments

@mydea thanks for updating this documentation it was pretty confusing before. However, it is still out of date in the v7 -> v8 migration guide as well: https://docs.sentry.io/platforms/javascript/guides/node/migration/v7-to-v8/v8-opentelemetry/

// Make sure Sentry is initialized before OpenTelemetry
Sentry.init({
  dsn: 'https://[email protected]/6664202',
  // Make sure to set this to disable the automatic OpenTelemetry setup
  skipOpenTelemetrySetup: true,
});

const { SentrySpanProcessor, SentryPropagator, SentryContextManager, SentrySampler } = require('@sentry/opentelemetry');

// We need to add a span processor to send spans to Sentry
provider.addSpanProcessor(new SentrySpanProcessor());

// We need a custom propagator and context manager
// This enables distributed tracing and context isolation
provier.register({
  propagator: new SentryPropagator(),
  contextManager: new SentryContextManager(),
});

// Optionally, if you want to use the `tracesSamplingRate` or sampling related options from Sentry,
// you also need to use a custom sampler when you set up your provider
const provider = new BasicTracerProvider({
  sampler: new SentrySampler(Sentry.getClient()),
});

There is also a typo there: provier.register({

Originally posted by @thebanjomatic in https://github.com/getsentry/sentry-docs/issues/10530#issuecomment-2195133122

mydea avatar Jun 28 '24 06:06 mydea