Skip to content

Commit

Permalink
chore(otel): Update installation instructions (#6262)
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 22, 2022
1 parent 3d9f0fd commit 3fbf2a2
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions packages/opentelemetry-node/README.md
Expand Up @@ -35,15 +35,27 @@ Note that `@sentry/opentelemetry-node` depends on the following peer dependencie
You need to register the `SentrySpanProcessor` and `SentryPropagator` with your OpenTelemetry installation:

```js
import * as Sentry from '@sentry/node';
import { SentrySpanProcessor } from '@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 Sentry = require("@sentry/node");
const {
SentrySpanProcessor,
SentryPropagator,
} = require("@sentry/opentelemetry-node");

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: '__DSN__',
tracesSampleRate: 1.0,
// set the instrumenter to use OpenTelemetry instead of Sentry
instrumenter: 'otel',
// ...
});

Expand All @@ -57,6 +69,8 @@ const sdk = new opentelemetry.NodeSDK({
});

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

sdk.start();
```

## Links
Expand Down

0 comments on commit 3fbf2a2

Please sign in to comment.