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

fix: Update OTEL js custom instructions snippet #10519

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,24 @@ Sentry.init({
tracesSampleRate: 1.0,
});

// This e.g. sets up @opentelemetry/sdk-trace-node
const provider = manuallySetUpOpenTelemetry();
const sentryClient = Sentry.getClient();

// Note: This could be BasicTracerProvider or any other provider depending on
// how you are using the OpenTelemetry SDK
const provider = new NodeTracerProvider({
// We need our sampler to ensure the correct subset of traces is sent to Sentry
sampler: sentryClient ? new SentrySampler(sentryClient) : undefined,
});

// We need a custom span processor
provider.addSpanProcessor(new SentrySpanProcessor());

// We need a custom propagator and context manager
provider.register({
propagator: new SentryPropagator(),
contextManager: new Sentry.SentryContextManager(),
});

// We need our sampler to ensure the correct subset of traces is sent to Sentry
const provider = new BasicTracerProvider({
sampler: new SentrySampler(Sentry.getClient()),
});

// Validate that the setup is correct
Sentry.validateOpenTelemetrySetup();
```
Expand Down
Loading