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

docs(node-experimental): Update readme for current status #8945

Merged
merged 1 commit into from
Sep 5, 2023
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
48 changes: 45 additions & 3 deletions packages/node-experimental/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,54 @@ Currently, this SDK:

* Will capture errors (same as @sentry/node)
* Auto-instrument for performance - see below for which performance integrations are available.
* Provide _some_ manual instrumentation APIs
* Sync OpenTelemetry Context with our Sentry Hub/Scope

### Manual Instrumentation

**Manual instrumentation is not supported!**
This is because the current Sentry-Performance-APIs like `Sentry.startTransaction()` are not compatible with the OpenTelemetry tracing model.
We may add manual tracing capabilities in a later version.
You can manual instrument using the following APIs:

```js
const Sentry = require('@sentry/node-experimental');

Sentry.startActiveSpan({ description: 'outer' }, function (span) {
span.setData(customData);
doSomethingSlow();
Sentry.startActiveSpan({ description: 'inner' }, function() {
// inner span is a child of outer span
doSomethingVerySlow();
// inner span is auto-ended when this callback ends
});
// outer span is auto-ended when this callback ends
});
```

You can also create spans without marking them as the active span.
Note that for most scenarios, we recommend the `startActiveSpan` syntax.

```js
const Sentry = require('@sentry/node-experimental');

// This will _not_ be put on the scope/set as active, so no other spans will be attached to it
const span = Sentry.startSpan({ description: 'non-active span' });

doSomethingSlow();

span?.finish();
```

Finally you can also get the currently active span, if you need to do more with it:

```js
const Sentry = require('@sentry/node-experimental');
const span = Sentry.getActiveSpan();
```

### Async Context

We leverage the OpenTelemetry context forking in order to ensure isolation of parallel requests.
This means that as long as you are using an OpenTelemetry instrumentation for your framework of choice
(currently: Express or Fastify), you do not need to setup any `requestHandler` or similar.

### ESM Support

Expand Down