# Fastify Error Tracking and Performance Monitoring

> Error tracking that helps developers monitor and fix crashes in real time. Iterate continuously. Boost workflow efficiency. Improve user experience.

**URL:** https://sentry.io/for/fastify/

---

**Documentation:** [https://docs.sentry.io/platforms/javascript/guides/fastify/](https://docs.sentry.io/platforms/javascript/guides/fastify/)

## Install

Add `@sentry/node` as a dependency:

```bash
npm install --save @sentry/node
```

Create an `instrument.js` file that initializes Sentry:

```javascript
const Sentry = require("@sentry/node");

// Ensure to call this before requiring any other modules!
Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",

  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for tracing.
  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,
});
```

Require `instrument.js` before any other modules. Errors from your routes and hooks are captured automatically, so you don't need to register a Sentry error handler:

```javascript
// Require this first!
require("./instrument");

// Now require other modules
const Fastify = require("fastify");

const app = Fastify();

// Add your routes, etc.

app.listen({ port: 3030 });
```

See the [Fastify docs](https://docs.sentry.io/platforms/javascript/guides/fastify/) for full setup options.

## Features

### Works With OpenTelemetry

Sentry traces your app out of the box, with rich distributed tracing context across the libraries and frameworks you use. Already running OpenTelemetry? Sentry runs alongside your existing setup without taking it over, and can capture spans from `@opentelemetry/api` when you turn it on.

### Fastify Performance Monitoring

Quickly identify Fastify [performance](/product/tracing/) issues and view the full end-to-end distributed trace to see the exact, poor-performing API call and surface any related errors.

### Fastify Error Monitoring with Complete Stack Traces

See the Fastify source code at each frame instead of settling for just line and column numbers. Get proper asynchronous context tracking — like thread-local store — in a way that fits Node's concurrency model.

### Fill In The Blanks About Fastify Errors

See what the app was doing when the Fastify error occurred: HTTP requests, database queries, console log statements, etc.

### Fastify Application Profiling

Profiling lets you see what parts of your code are consuming the most resources, like CPU or memory, in your application— so you can optimize them before end user experience is impacted. Test your application performance in any environment, including in production, without writing manual tests or extensive troubleshooting.

---

*Source: [sentry.io/for/fastify/](https://sentry.io/for/fastify/)*
