7.113.0 • Published 20 hours ago

@sentry/node-experimental v7.113.0

Weekly downloads
-
License
MIT
Repository
github
Last release
20 hours ago

Official Sentry SDK for Node (EXPERIMENTAL)

npm version npm dm npm dt

This is a WIP, proof of concept implementation of a Node SDK that uses OpenTelemetry for performance instrumentation under the hood.

THIS MAY/WILL BREAK IN MANY UNEXPECTED WAYS. We may remove, add, change any of the integrations, add/remove any exports, etc. This package is NOT READY TO USE IN ANY FORM OF PRODUCTION ENVIRONMENT!

This SDK is considered experimental and in an alpha state. It may experience breaking changes, and may be discontinued at any time. Please reach out on GitHub if you have any feedback/concerns.

Installation

npm install @sentry/node-experimental

# Or yarn
yarn add @sentry/node-experimental

Usage

// CJS Syntax
const Sentry = require('@sentry/node-experimental');
// ESM Syntax
import * as Sentry from '@sentry/node-experimental';

Sentry.init({
  dsn: '__DSN__',
  // ...
});

Note that it is necessary to initialize Sentry before you import any package that may be instrumented by us.

Status of this Experiment

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

You can manual instrument using the following APIs:

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.

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:

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

Due to the way OpenTelemetry handles instrumentation, this only works out of the box for CommonJS (require) applications.

There is experimental support for running OpenTelemetry with ESM ("type": "module"):

node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ./app.js

See OpenTelemetry Instrumentation Docs for details on this - but note that this is a) experimental, and b) does not work with all integrations.

Available (Performance) Integrations

  • Http
  • Express
  • Fastify
  • Nest
  • Mysql
  • Mysql2
  • GraphQL
  • Mongo
  • Mongoose
  • Postgres
  • Prisma

All of these are auto-discovered, you don't need to configure anything for performance. You still need to register middlewares etc. for error capturing. Other, non-performance integrations from @sentry/node are also available (except for Undici).

Links

7.113.0

20 hours ago

7.112.2

9 days ago

7.112.0

10 days ago

7.112.1

10 days ago

7.111.0

15 days ago

7.110.1

18 days ago

7.110.0

22 days ago

7.109.0

1 month ago

8.0.0-alpha.7

1 month ago

8.0.0-alpha.5

1 month ago

7.108.0

1 month ago

8.0.0-alpha.4

2 months ago

7.107.0

2 months ago

7.106.1

2 months ago

7.106.0

2 months ago

8.0.0-alpha.2

2 months ago

7.105.0

2 months ago

7.104.0

2 months ago

7.103.0

2 months ago

7.102.1

2 months ago

7.102.0

2 months ago

7.101.1

3 months ago

7.101.0

3 months ago

7.100.1

3 months ago

7.100.0

3 months ago

7.99.0

3 months ago

7.97.0

3 months ago

7.98.0

3 months ago

7.95.0

3 months ago

7.94.1

3 months ago

7.93.0

4 months ago

7.92.0

4 months ago

7.91.0

4 months ago

7.90.0

4 months ago

7.89.0

5 months ago

7.88.0

5 months ago

7.87.0

5 months ago

7.86.0

5 months ago

7.85.0

5 months ago

7.84.0

5 months ago

7.83.0

5 months ago

7.82.0

5 months ago

7.81.1

5 months ago

7.81.0

5 months ago

7.80.2-alpha.1

6 months ago

7.80.2-alpha.0

6 months ago

7.80.1

6 months ago

7.80.0

6 months ago

7.79.0

6 months ago

7.78.0

6 months ago

7.77.0

6 months ago

7.76.0

6 months ago

7.75.1

6 months ago

7.75.0

6 months ago

7.74.2-alpha.1

6 months ago

7.74.1

7 months ago

7.74.0

7 months ago

7.73.0

7 months ago

7.72.0

7 months ago

7.71.0

7 months ago

7.70.0

8 months ago

7.70.0-beta.1

8 months ago

7.70.0-beta.0

8 months ago

7.69.0

8 months ago

7.68.0

8 months ago

7.67.0

8 months ago

7.67.0-beta.0

8 months ago

7.66.0

8 months ago

7.66.0-alpha.0

8 months ago

7.65.0

8 months ago

7.65.0-alpha.0

9 months ago

7.64.0

9 months ago

7.64.0-alpha.0

9 months ago

7.63.0

9 months ago

7.62.0

9 months ago

7.61.1

9 months ago

7.61.0

9 months ago