By default, Sentry error events will not get trace context unless you configure the scope with the transaction, as illustrated in the example below.

For the Profiling integration to work, you must have the Sentry Node SDK package (minimum version 7.x) installed.


# Using yarn
yarn add @sentry/node @sentry/tracing @sentry/profiling-node

# Using npm
npm install --save @sentry/node @sentry/tracing @sentry/profiling-node

Enabling Profiling

In order to enable profiling, import @sentry/profiling-node and add ProfilingIntegration to your integrations. Make sure that @sentry/profiling-node is imported after @sentry/

tracingThe process of logging the events that took place during a request, often across multiple services.

const Sentry = require("@sentry/node");
// Note: You MUST import @sentry/tracing package before @sentry/profiling-node
const {ProfilingIntegration} = require("@sentry/profiling-node");

  dsn: "",
  integrations: [
    // Add our Profiling integration
    new ProfilingIntegration(),
  tracesSampleRate: 1.0,
  // Set sampling rate for profiling - this is relative to tracesSampleRate
  profilesSampleRate: 1.0,

const transaction = Sentry.startTransaction({
  op: "transaction",
  name: "My Transaction",

// Any code executed between startTransaction and transaction.finish
// will now be automatically profiled.


How Does It Work?

Under the hood, the Sentry profiler uses V8's CpuProfiler to collect stack samples. This means that sentry/profiling-node is written as a native add-on for Node and won't run in environments like Deno or Bun. Profiling enhances

tracingThe process of logging the events that took place during a request, often across multiple services.
by providing profiles for individual transactions. This allows you to look at higher level performance information like transaction and span durations before diving deeper and looking at profiles.

Runtime Flags

The Profiling package enables you to run the profiler in either eager or lazy mode. When a profile is started while no other profiles are running, the default profiling mode (lazy) sometimes causes startProfiling calls to take a long time (sometimes in the range of a couple hundred milliseconds). The benefit of lazy logging is that it doesn't add any overhead when profiles aren't running.

If this behavior is prohibitive for your use case, you can set the environment flag shown below, which will cause the profiler to run in eager mode. Eager mode improves the performance of calls to startProfiling, but the tradeoff is small, constant CPU overhead.

// Run profiler in eager mode

We recommend you have your own CPU resource-monitoring in place, because the actual resource use could be environment-dependent.

Precompiled Binaries

Starting from version 0.1.0, @sentry/profiling-node package precompiles binaries for a number of common architectures. This minimizes the tooling required to run the package and avoids compiling the package from source in most cases, which speeds up installation. The set of common architectures should cover a wide variety of use cases, but if you have feedback or experience different behavior, please open an issue on the sentry/profiling-node repository.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").