# Backend Error Tracking and Monitoring

> Get extra visability into a backend infrastructure with Sentry. Learn how to use our backend application monitoring to resolve errors & optimize performance.

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

---

Whether you're taming Python's processing power or controlling JavaScript's flow through Node.js, backend infrastructures are as complex as they are valuable.

**Documentation:** [https://docs.sentry.io/](https://docs.sentry.io/)

## Install

### Node

Grab the [Sentry Node SDK](https://github.com/getsentry/sentry-javascript/):

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

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

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

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,
});
```

Load it before your application starts with the `--import` flag:

```bash
node --import ./instrument.js app.js
```

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

### Python

Grab the [Sentry Python SDK](https://github.com/getsentry/sentry-python):

```bash
pip install --upgrade sentry-sdk
```

Initialize the SDK as early as possible in your application:

```python
import sentry_sdk

sentry_sdk.init(
    dsn="https://<key>@sentry.io/<project>",
    # Add data like request headers and IP for users, if applicable;
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    # We recommend adjusting this value in production.
    traces_sample_rate=1.0,
)
```

See the [Python docs](https://docs.sentry.io/platforms/python/) for full setup options.

### PHP

Install the `sentry/sentry` package with Composer:

```bash
composer require sentry/sentry
```

To capture all errors, even the ones during the startup of your application, you should initialize the Sentry PHP SDK as soon as possible.

```php
\Sentry\init([
    'dsn' => 'https://<key>@sentry.io/<project>',
    // Specify a fixed sample rate for tracing:
    'traces_sample_rate' => 1.0,
]);
```

See the [PHP docs](https://docs.sentry.io/platforms/php/) for full setup options.

### Ruby

Add the `sentry-ruby` gem to your Gemfile:

```ruby
gem "sentry-ruby"
```

Configure your SDK:

```ruby
Sentry.init do |config|
  config.dsn = 'https://<key>@sentry.io/<project>'
  config.traces_sample_rate = 1.0
end
```

See the [Ruby docs](https://docs.sentry.io/platforms/ruby/) for full setup options.

### Go

Grab the Sentry Go SDK:

```bash
go get "github.com/getsentry/sentry-go"
```

Configuration should happen as early as possible in your application's lifecycle:

```go
package main

import (
	"log"
	"time"

	"github.com/getsentry/sentry-go"
)

func main() {
	err := sentry.Init(sentry.ClientOptions{
		Dsn: "https://<key>@sentry.io/<project>",
		EnableTracing: true,
		// Specify a fixed sample rate:
		// We recommend adjusting this value in production
		TracesSampleRate: 1.0,
		// Or provide a custom sample rate:
		TracesSampler: sentry.TracesSampler(func(ctx sentry.SamplingContext) float64 {
			// As an example, this does not send some
			// transactions to Sentry based on their name.
			if ctx.Span.Name == "GET /health" {
				return 0.0
			}

			return 1.0
		}),
	})
	if err != nil {
		log.Fatalf("sentry.Init: %s", err)
	}
	// Flush buffered events before the program terminates.
	// Set the timeout to the maximum duration the program can afford to wait.
	defer sentry.Flush(2 * time.Second)
}
```

See the [Go docs](https://docs.sentry.io/platforms/go/) for full setup options.

## Features

### An extra dimension of visibility.

You can't monitor what you can't see. And there's a lot you need to see in your backend infrastructure, from third-party API data to authentication middleware and data management systems. By giving you complete visibility of your systems no matter where they live, backend monitoring gives you the most complete picture of your infrastructure.

### Fix issues before they become downtime.

Your application's performance depends on how well you handle network latency. It's why monitoring how you utilize servers, networks, database instances and storage is critical toward working in a proactive — and not reactive — state.

### Translate error logs to human insights.

Humans are visual creatures. Compilers, not so much. Error monitoring captures, aggregates and deciphers your error logs in one complete view so you're able to identify key trends and implement future improvements.

## FAQ

**What is the difference between Sentry and traditional logging?**

Traditional logging provides you with a trail of events. Some of those events are errors, but many times they're simply informational. Sentry is fundamentally different because we focus on exceptions, or in other words, we capture application crashes. We discuss in more detail [here](/vs/logging/) and on our [blog](https://blog.sentry.io/lets-get-ready-to-monitor/).

**What  languages does Sentry support?**

Sentry supports every major  language, framework, and library. You can browse each of them [here](/platforms/).

**How much does Sentry cost?**

You can get started for free. Pricing depends on the number of monthly events, transactions, and attachments that you send Sentry. For more details, visit our [pricing page](/pricing/).

**How does Sentry impact the performance of my app?**

Sentry doesn't impact a web site's performance.

If you look at the configuration options for when you initialize Sentry in your code, you'll see there's nothing regarding minimizing its impact on your app's performance. This is because our team of SDK engineers already developed Sentry with this in mind.

Sentry is a listener/handler for errors that asynchronously sends out the error/event to Sentry.io. This is non-blocking. The error/event only goes out if this is an error.

Global handlers have almost no impact as well, as they are native APIs provided by the browsers.

---

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