Skip to content

Commit

Permalink
chore(otel): Update otel node installation instructions (#5837)
Browse files Browse the repository at this point in the history
1. Convert from ES modules to `require`
2. Specify to set the `instrumenter` option to turn off Sentry instrumentation
3. Clean up imports 
4. Add `sdk.start` command to match otel docs: https://opentelemetry.io/docs/instrumentation/js/getting-started/nodejs/#setup
  • Loading branch information
AbhiPrasad committed Nov 23, 2022
1 parent 97e4e99 commit 916304d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/platform-includes/performance/opentelemetry-setup/node.mdx
@@ -1,16 +1,27 @@
You need to register `SentrySpanProcessor` and `SentryPropagator` with your OpenTelemetry installation:

```js
import * as Sentry from "@sentry/node";
import { SentrySpanProcessor } from "@sentry/opentelemetry-node";
const Sentry = require("@sentry/node");
const {
SentrySpanProcessor,
SentryPropagator,
} = require("@sentry/opentelemetry-node");

import * as otelApi from "@opentelemetry/api";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
const opentelemetry = require("@opentelemetry/sdk-node");
const otelApi = require("@opentelemetry/api");
const {
getNodeAutoInstrumentations,
} = require("@opentelemetry/auto-instrumentations-node");
const {
OTLPTraceExporter,
} = require("@opentelemetry/exporter-trace-otlp-grpc");

// Make sure to call `Sentry.init` BEFORE initializing the OpenTelemetry SDK
Sentry.init({
dsn: "___PUBLIC_DSN___",
dsn: "__DSN__",
tracesSampleRate: 1.0,
// set the instrumenter to use OpenTelemetry instead of Sentry
instrumenter: "otel",
// ...
});

Expand All @@ -24,4 +35,6 @@ const sdk = new opentelemetry.NodeSDK({
});

otelApi.propagation.setGlobalPropagator(new SentryPropagator());

sdk.start();
```

1 comment on commit 916304d

@vercel
Copy link

@vercel vercel bot commented on 916304d Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs-git-master.sentry.dev
docs.sentry.io
sentry-docs.sentry.dev

Please sign in to comment.