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(js): Stop using provider.addSpanProcessor() #13011

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
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 @@ -58,11 +58,13 @@ const provider = new NodeTracerProvider({
// Ensure the correct subset of traces is sent to Sentry
// This also ensures trace propagation works as expected
sampler: sentryClient ? new SentrySampler(sentryClient) : undefined,
spanProcessors: [
// Ensure spans are correctly linked & sent to Sentry
new SentrySpanProcessor(),
// Add additional processors here
],
});

// Ensure spans are correctly linked & sent to Sentry
provider.addSpanProcessor(new SentrySpanProcessor());

provider.register({
// Ensure trace propagation works
// This relies on the SentrySampler for correct propagation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,28 @@ You can also use any other tracer. All OpenTelemetry spans will be picked up by

## Modifying the default OpenTelemetry TracerProvider

You can access the tracer provider set up by Sentry when using Sentry's default OpenTelemetry instrumentation. This enables you to easily add additional span processors, allowing you to export tracing data to various OTEL collectors or other backends.
You can access the tracer provider set up by Sentry when using Sentry's default OpenTelemetry instrumentation.

```javascript
const Sentry = require("@sentry/node");

const provider = Sentry.getClient()?.traceProvider;
provider?.addSpanProcessor(new MySpanProcessor());
```

## Adding Additional Span Processors

You can add additional span processors to the tracer provider set up by Sentry when using Sentry's default OpenTelemetry instrumentation.

```javascript
const Sentry = require("@sentry/node");

Sentry.init({
dsn: "___DSN___",

// The SentrySampler will use this to determine which traces to sample
tracesSampleRate: 1.0,

// Add additional OpenTelemetry SpanProcessors:
openTelemetrySpanProcessors: [new MySpanProcessor()],
});
```