# Koa Error Tracking and Performance Monitoring

> Identify the exact, poor-performing API call and related errors with Koa performance monitoring by Sentry. Get started today for free.

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

---

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

## 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://<key>@sentry.io/<project>",

  // 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. The Koa integration registers an error handler when your app starts, so errors are captured automatically:

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

// Now require other modules
const Koa = require("koa");

const app = new Koa();

// Add your middleware here.

app.listen(3000);
```

See the [Koa docs](https://docs.sentry.io/platforms/javascript/guides/koa/) 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.

### Koa Performance Monitoring

Quickly identify Koa [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.

### Koa Error Monitoring with Complete Stack Traces

See the Koa 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 Koa Errors

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

### Koa 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/koa/](https://sentry.io/for/koa/)*
