Skip to content

Commit 223df75

Browse files
authored
feat(js): Update OTEL docs for OTEL v2 (#13011)
1 parent aadacba commit 223df75

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

docs/platforms/javascript/common/opentelemetry/custom-setup.mdx

+5-3
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ const provider = new NodeTracerProvider({
5858
// Ensure the correct subset of traces is sent to Sentry
5959
// This also ensures trace propagation works as expected
6060
sampler: sentryClient ? new SentrySampler(sentryClient) : undefined,
61+
spanProcessors: [
62+
// Ensure spans are correctly linked & sent to Sentry
63+
new SentrySpanProcessor(),
64+
// Add additional processors here
65+
],
6166
});
6267

63-
// Ensure spans are correctly linked & sent to Sentry
64-
provider.addSpanProcessor(new SentrySpanProcessor());
65-
6668
provider.register({
6769
// Ensure trace propagation works
6870
// This relies on the SentrySampler for correct propagation

docs/platforms/javascript/common/opentelemetry/using-opentelemetry-apis.mdx

+19-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,28 @@ You can also use any other tracer. All OpenTelemetry spans will be picked up by
7878
7979
## Modifying the default OpenTelemetry TracerProvider
8080
81-
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.
81+
You can access the tracer provider set up by Sentry when using Sentry's default OpenTelemetry instrumentation.
8282
8383
```javascript
8484
const Sentry = require("@sentry/node");
8585

8686
const provider = Sentry.getClient()?.traceProvider;
87-
provider?.addSpanProcessor(new MySpanProcessor());
87+
```
88+
89+
## Adding Additional Span Processors
90+
91+
You can add additional span processors to the tracer provider set up by Sentry when using Sentry's default OpenTelemetry instrumentation.
92+
93+
```javascript
94+
const Sentry = require("@sentry/node");
95+
96+
Sentry.init({
97+
dsn: "___DSN___",
98+
99+
// The SentrySampler will use this to determine which traces to sample
100+
tracesSampleRate: 1.0,
101+
102+
// Add additional OpenTelemetry SpanProcessors:
103+
openTelemetrySpanProcessors: [new MySpanProcessor()],
104+
});
88105
```

0 commit comments

Comments
 (0)