# Ruby | Sentry for Ruby

##### Using a framework?

Check out the other SDKs we support in the left-hand dropdown.

## [Prerequisites](https://docs.sentry.io/.md#prerequisites)

* You need a Sentry [account](https://sentry.io/signup.md) and [project](https://docs.sentry.io/product/projects.md)
* Ruby 2.4+ and any of the most recent JRuby versions

## [Features](https://docs.sentry.io/.md#features)

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing.md). You can also collect and analyze performance profiles from real users with [profiling](https://docs.sentry.io/product/explore/profiling.md).

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

Error Monitoring\[ ]Tracing\[ ]Profiling\[ ]Logs (Beta)

## [Install](https://docs.sentry.io/.md#install)

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

`Gemfile`

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

Add the `sentry-ruby` and `stackprof` gems to your `Gemfile`:

`Gemfile`

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

## [Configure](https://docs.sentry.io/.md#configure)

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

Error Monitoring\[ ]Tracing\[ ]Profiling\[ ]Logs (Beta)

```ruby
require 'sentry-ruby'

Sentry.init do |config|
  config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0'

  # get breadcrumbs from logs
  config.breadcrumbs_logger = [:sentry_logger, :http_logger]

  # Add data like request headers and IP for users, if applicable;
  # see https://docs.sentry.io/platforms/ruby/data-management/data-collected/ for more info
  config.send_default_pii = true
  #  performance

  # enable tracing
  # we recommend adjusting this value in production
  config.traces_sample_rate = 1.0
  #  performance
  #  profiling

  # enable profiling
  # this is relative to traces_sample_rate
  config.profiles_sample_rate = 1.0
  #  profiling
  #  logs

  # Enable logs to be sent to Sentry
  config.enable_logs = true
  #  logs
end
```

## [Verify](https://docs.sentry.io/.md#verify)

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

```ruby
Sentry.capture_message("test message")
```

Learn more about manually capturing an error or message in our [Usage documentation](https://docs.sentry.io/platforms/ruby/usage.md).

To view and resolve the recorded error, log into [sentry.io](https://sentry.io/.md) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
