diff --git a/docs/platforms/ruby/common/index.mdx b/docs/platforms/ruby/common/index.mdx index 4041836fad76f..8166e10226266 100644 --- a/docs/platforms/ruby/common/index.mdx +++ b/docs/platforms/ruby/common/index.mdx @@ -2,45 +2,99 @@ -## Prerequisites + -- You need a Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) -- Ruby 2.4+ or any of the most recent JRuby versions + -## Features +## Install + + + +Installing the Sentry SDK enables core features such as **Error Monitoring**, **Logs**, and **Application Metrics** by default. We'll show you how to send logs and metrics in [Verify Your Setup](#verify-your-setup). + + + + + +Installing the Sentry SDK enables core features such as **Error Monitoring** and **Application Metrics** by default. We'll show you how to send metrics in [Verify Your Setup](#verify-your-setup). -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/profiling/). + -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. +Choose additional features you want to configure, and this guide will show you how to get set up: -## Install + + +### Install the Sentry SDK ## Configure +### Initialize the Sentry SDK Configuration should happen as early as possible in your application's lifecycle. -## Verify +### Control the Data You Send to Sentry (Optional) -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. + + + - +By default, the SDK does **not** send user identity data (IP address, ID, and similar) or other data like HTTP bodies and URL query parameters. + +To opt in and get richer debugging context, turn on individual categories using the `data_collection` option. For the full list of categories and their defaults, see the `data_collection` options. + + + + +```ruby +require 'sentry-ruby' - +Sentry.init do |config| + config.dsn = '___PUBLIC_DSN___' -Learn more about manually capturing an error or message in our Usage documentation. + config.data_collection.user_info = true + config.data_collection.http_bodies = [:incoming_request, :outgoing_request] + # other categories +end +``` - + + + -To view and resolve the recorded error, log into [sentry.io](https://sentry.io) 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. +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. + + + +### View Captured Data in Sentry + +Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear). + + ## Next Steps +At this point, you should have integrated Sentry into your application and should already be sending data to your Sentry project. + +Now's a good time to customize your setup and look into more advanced topics. +Our next recommended steps for you are: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Continue to customize your configuration + + + +- Find various topics in Troubleshooting +- [Get support](https://www.sentry.help/en/) + + + + diff --git a/docs/platforms/ruby/config.yml b/docs/platforms/ruby/config.yml index 3cc0256b644c6..3737757549b58 100644 --- a/docs/platforms/ruby/config.yml +++ b/docs/platforms/ruby/config.yml @@ -1,4 +1,5 @@ title: Ruby +description: Learn how to set up Sentry in your Ruby app, capture your first errors and traces, and view them in Sentry. caseStyle: snake_case supportLevel: production sdk: "sentry.ruby" diff --git a/docs/platforms/ruby/guides/delayed_job/config.yml b/docs/platforms/ruby/guides/delayed_job/config.yml index 028fa2260a812..a88c6ec41bb61 100644 --- a/docs/platforms/ruby/guides/delayed_job/config.yml +++ b/docs/platforms/ruby/guides/delayed_job/config.yml @@ -1,2 +1,3 @@ title: DelayedJob +description: Learn how to set up Sentry in your app, capture your first errors and traces, and view them in Sentry. sdk: "sentry.ruby.delayed_job" diff --git a/docs/platforms/ruby/guides/rack/config.yml b/docs/platforms/ruby/guides/rack/config.yml index cad2d9f78f0f5..7612516886ee0 100644 --- a/docs/platforms/ruby/guides/rack/config.yml +++ b/docs/platforms/ruby/guides/rack/config.yml @@ -1 +1,2 @@ title: Rack Middleware +description: Learn how to set up Sentry in your app, capture your first errors and traces, and view them in Sentry. diff --git a/docs/platforms/ruby/guides/rails/config.yml b/docs/platforms/ruby/guides/rails/config.yml index b447f619660a9..edfab23d7008a 100644 --- a/docs/platforms/ruby/guides/rails/config.yml +++ b/docs/platforms/ruby/guides/rails/config.yml @@ -1,2 +1,3 @@ title: Rails +description: Learn how to set up Sentry in your Ruby on Rails app, capture your first errors and traces, and view them in Sentry. sdk: "sentry.ruby.rails" diff --git a/docs/platforms/ruby/guides/resque/config.yml b/docs/platforms/ruby/guides/resque/config.yml index 2c444049f1d14..06faa2330506c 100644 --- a/docs/platforms/ruby/guides/resque/config.yml +++ b/docs/platforms/ruby/guides/resque/config.yml @@ -1,2 +1,3 @@ title: Resque +description: Learn how to set up Sentry in your app, capture your first errors and traces, and view them in Sentry. sdk: "sentry.ruby.resque" diff --git a/docs/platforms/ruby/guides/sidekiq/config.yml b/docs/platforms/ruby/guides/sidekiq/config.yml index e2647220c79d7..a5c7c2fe81360 100644 --- a/docs/platforms/ruby/guides/sidekiq/config.yml +++ b/docs/platforms/ruby/guides/sidekiq/config.yml @@ -1,2 +1,3 @@ title: Sidekiq +description: Learn how to set up Sentry in your app, capture your first errors and traces, and view them in Sentry. sdk: "sentry.ruby.sidekiq" diff --git a/includes/quick-start-features-expandable.mdx b/includes/quick-start-features-expandable.mdx index b901ff291b4f6..8ee5e2d2aef86 100644 --- a/includes/quick-start-features-expandable.mdx +++ b/includes/quick-start-features-expandable.mdx @@ -87,4 +87,22 @@ import { FeatureInfo } from "sentry-docs/components/featureInfo"; + + + + + + + + + + + + diff --git a/includes/quick-start-locate-data-expandable.mdx b/includes/quick-start-locate-data-expandable.mdx index 8cca720f1e168..db053a6c3d22a 100644 --- a/includes/quick-start-locate-data-expandable.mdx +++ b/includes/quick-start-locate-data-expandable.mdx @@ -87,4 +87,22 @@ import { FeatureInfo } from "sentry-docs/components/featureInfo"; + + + + + + + + + + + + diff --git a/platform-includes/getting-started-config/ruby.mdx b/platform-includes/getting-started-config/ruby.mdx index cc9598630f802..3470806ca5229 100644 --- a/platform-includes/getting-started-config/ruby.mdx +++ b/platform-includes/getting-started-config/ruby.mdx @@ -1,27 +1,42 @@ + + + + +Import and initialize the SDK in your app's entry point: + + + + + ```ruby require 'sentry-ruby' Sentry.init do |config| config.dsn = '___PUBLIC_DSN___' - # get breadcrumbs from logs + # Get breadcrumbs from logs + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#breadcrumbs_logger config.breadcrumbs_logger = [:sentry_logger, :http_logger] - - # To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit: - # https://docs.sentry.io/platforms/ruby/configuration/options/#data_collection - # config.data_collection.user_info = false - # config.data_collection.http_bodies = [] # ___PRODUCT_OPTION_START___ performance - # enable tracing - # we recommend adjusting this value in production + # Set tracesSampleRate to 1.0 to capture 100% + # of transactions for tracing. + # We recommend adjusting this value in production + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#traces_sample_rate config.traces_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ performance # ___PRODUCT_OPTION_START___ profiling - # enable profiling - # this is relative to traces_sample_rate + # Enable profiling for a percentage of sessions relative to traces_sample_rate. + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#profiles_sample_rate config.profiles_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ profiling end ``` + + + + diff --git a/platform-includes/getting-started-config/ruby.rack.mdx b/platform-includes/getting-started-config/ruby.rack.mdx index 3abaf5e2bc0ba..b62dc39d6c3e4 100644 --- a/platform-includes/getting-started-config/ruby.rack.mdx +++ b/platform-includes/getting-started-config/ruby.rack.mdx @@ -1,6 +1,13 @@ -### With Rackup +#### With Rackup -Add `use Sentry::Rack::CaptureExceptions` to your `config.ru` or other rackup file: + + + + +Import and initialize the SDK and add `use Sentry::Rack::CaptureExceptions` to your `config.ru` or other rackup file: + + + ```ruby {filename:config.ru} require 'sentry-ruby' @@ -8,23 +15,24 @@ require 'sentry-ruby' Sentry.init do |config| config.dsn = '___PUBLIC_DSN___' - # get breadcrumbs from logs + # Get breadcrumbs from logs + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#breadcrumbs_logger config.breadcrumbs_logger = [:sentry_logger, :http_logger] - - # To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit: - # https://docs.sentry.io/platforms/ruby/configuration/options/#data_collection - # config.data_collection.user_info = false - # config.data_collection.http_bodies = [] # ___PRODUCT_OPTION_START___ performance - # enable tracing - # we recommend adjusting this value in production + # Set tracesSampleRate to 1.0 to capture 100% + # of transactions for tracing. + # We recommend adjusting this value in production + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#traces_sample_rate config.traces_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ performance # ___PRODUCT_OPTION_START___ profiling - # enable profiling - # this is relative to traces_sample_rate + # Enable profiling for a percentage of sessions relative to traces_sample_rate. + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#profiles_sample_rate config.profiles_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ profiling end @@ -32,14 +40,20 @@ end use Sentry::Rack::CaptureExceptions ``` -### Without Rackup + + + - +#### Without Rackup -If you're not using Rackup to run your app, then Sentry initialization code **must** -be placed before your code requires Sinatra: + + + - +If you're not using Rackup to run your app, you have to place Sentry's initialization code **before** your code requires Sinatra: + + + ```ruby {filename:app.rb} require 'sentry-ruby' @@ -47,23 +61,24 @@ require 'sentry-ruby' Sentry.init do |config| config.dsn = '___PUBLIC_DSN___' - # get breadcrumbs from logs + # Get breadcrumbs from logs + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#breadcrumbs_logger config.breadcrumbs_logger = [:sentry_logger, :http_logger] - - # To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit: - # https://docs.sentry.io/platforms/ruby/configuration/options/#data_collection - # config.data_collection.user_info = false - # config.data_collection.http_bodies = [] # ___PRODUCT_OPTION_START___ performance - # enable tracing - # we recommend adjusting this value in production + # Set tracesSampleRate to 1.0 to capture 100% + # of transactions for tracing. + # We recommend adjusting this value in production + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#traces_sample_rate config.traces_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ performance # ___PRODUCT_OPTION_START___ profiling - # enable profiling - # this is relative to traces_sample_rate + # Enable profiling for a percentage of sessions relative to traces_sample_rate. + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#profiles_sample_rate config.profiles_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ profiling end @@ -76,3 +91,7 @@ get "/" do raise "foo" end ``` + + + + diff --git a/platform-includes/getting-started-config/ruby.rails.mdx b/platform-includes/getting-started-config/ruby.rails.mdx index a50fe578d188a..8a469bb649c51 100644 --- a/platform-includes/getting-started-config/ruby.rails.mdx +++ b/platform-includes/getting-started-config/ruby.rails.mdx @@ -1,27 +1,39 @@ + + + + Initialize the SDK within your `config/initializers/sentry.rb`: + + + ```ruby {filename:config/initializers/sentry.rb} Sentry.init do |config| config.dsn = '___PUBLIC_DSN___' - # get breadcrumbs from logs + # Get breadcrumbs from logs + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#breadcrumbs_logger config.breadcrumbs_logger = [:active_support_logger, :http_logger] - - # To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit: - # https://docs.sentry.io/platforms/ruby/configuration/options/#data_collection - # config.data_collection.user_info = false - # config.data_collection.http_bodies = [] # ___PRODUCT_OPTION_START___ performance - # enable tracing - # we recommend adjusting this value in production + # Set tracesSampleRate to 1.0 to capture 100% + # of transactions for tracing. + # We recommend adjusting this value in production + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#traces_sample_rate config.traces_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ performance # ___PRODUCT_OPTION_START___ profiling - # enable profiling - # this is relative to traces_sample_rate + # Enable profiling for a percentage of sessions relative to traces_sample_rate. + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#profiles_sample_rate config.profiles_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ profiling end ``` + + + + diff --git a/platform-includes/getting-started-config/ruby.resque.mdx b/platform-includes/getting-started-config/ruby.resque.mdx index 8d788e69ae750..edb95d0fe8358 100644 --- a/platform-includes/getting-started-config/ruby.resque.mdx +++ b/platform-includes/getting-started-config/ruby.resque.mdx @@ -1,33 +1,56 @@ + + + + +Import and initialize the SDK in your app's entry point: + + + + ```ruby require 'sentry-ruby' Sentry.init do |config| config.dsn = '___PUBLIC_DSN___' - # get breadcrumbs from logs + # Get breadcrumbs from logs + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#breadcrumbs_logger config.breadcrumbs_logger = [:sentry_logger, :http_logger] - - # To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit: - # https://docs.sentry.io/platforms/ruby/configuration/options/#data_collection - # config.data_collection.user_info = false - # config.data_collection.http_bodies = [] # ___PRODUCT_OPTION_START___ performance - # enable tracing - # we recommend adjusting this value in production + # Set tracesSampleRate to 1.0 to capture 100% + # of transactions for tracing. + # We recommend adjusting this value in production + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#traces_sample_rate config.traces_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ performance # ___PRODUCT_OPTION_START___ profiling - # enable profiling - # this is relative to traces_sample_rate + # Enable profiling for a percentage of sessions relative to traces_sample_rate. + # Learn more at + # https://docs.sentry.io/platforms/ruby/configuration/options/#profiles_sample_rate config.profiles_sample_rate = 1.0 # ___PRODUCT_OPTION_END___ profiling end ``` -Sentry relies on the `at_exit` hook to flush all events before the process exits. To make sure none of your events are lost, additionally please set the following environment variable when you run Resque: + + + + + + +Sentry relies on the `at_exit` hook to flush all events before the process exits. To make sure none of your events are lost, set the following environment variable when you run Resque: + + + ```bash RUN_AT_EXIT_HOOKS=1 rake resque:workers ``` + + + + diff --git a/platform-includes/getting-started-install/ruby.mdx b/platform-includes/getting-started-install/ruby.mdx index 79dd8963a4e27..42bf034e7c883 100644 --- a/platform-includes/getting-started-install/ruby.mdx +++ b/platform-includes/getting-started-install/ruby.mdx @@ -1,20 +1,42 @@ + + + + Add the `sentry-ruby` gem to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "sentry-ruby" ``` + + + + + + + + Add the `sentry-ruby` and `stackprof` gems to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "stackprof" gem "sentry-ruby" ``` + + + + diff --git a/platform-includes/getting-started-install/ruby.rails.mdx b/platform-includes/getting-started-install/ruby.rails.mdx index bc33c813ae80b..f59f399243c4f 100644 --- a/platform-includes/getting-started-install/ruby.rails.mdx +++ b/platform-includes/getting-started-install/ruby.rails.mdx @@ -1,22 +1,44 @@ + + + + Add the `sentry-ruby` and `sentry-rails` gems to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "sentry-ruby" gem "sentry-rails" ``` + + + + + + + + Add the `sentry-ruby`, `sentry-rails` and `stackprof` gems to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "stackprof" gem "sentry-ruby" gem "sentry-rails" ``` + + + + diff --git a/platform-includes/getting-started-install/ruby.resque.mdx b/platform-includes/getting-started-install/ruby.resque.mdx index e9bb2337f0b42..23344e1e5eeed 100644 --- a/platform-includes/getting-started-install/ruby.resque.mdx +++ b/platform-includes/getting-started-install/ruby.resque.mdx @@ -1,17 +1,35 @@ + + + + Add the `sentry-ruby` and `sentry-resque` gems to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "sentry-ruby" gem "sentry-resque" ``` + + + + -Add the `sentry-ruby`, `sentry-resque` and `stackprof` gems to your `Gemfile`: + + + + +Add the `sentry-ruby`, `sentry-resque`, and `stackprof` gems to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "stackprof" @@ -19,4 +37,8 @@ gem "sentry-ruby" gem "sentry-resque" ``` + + + + diff --git a/platform-includes/getting-started-install/ruby.sidekiq.mdx b/platform-includes/getting-started-install/ruby.sidekiq.mdx index 9a6741f78ee89..781f0c3b0a475 100644 --- a/platform-includes/getting-started-install/ruby.sidekiq.mdx +++ b/platform-includes/getting-started-install/ruby.sidekiq.mdx @@ -1,17 +1,35 @@ + + + + Add the `sentry-ruby` and `sentry-sidekiq` gems to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "sentry-ruby" gem "sentry-sidekiq" ``` + + + + -Add the `sentry-ruby`, `sentry-sidekiq` and `stackprof` gems to your `Gemfile`: + + + + +Add the `sentry-ruby`, `sentry-sidekiq`, and `stackprof` gems to your `Gemfile`: + + + ```ruby {filename:Gemfile} gem "stackprof" @@ -19,4 +37,8 @@ gem "sentry-ruby" gem "sentry-sidekiq" ``` + + + + diff --git a/platform-includes/getting-started-prerequisites/ruby.mdx b/platform-includes/getting-started-prerequisites/ruby.mdx new file mode 100644 index 0000000000000..6cb11c2d1925f --- /dev/null +++ b/platform-includes/getting-started-prerequisites/ruby.mdx @@ -0,0 +1,7 @@ +## Prerequisites + +You need: + +- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) +- Your application up and running +- Ruby `2.4+` or any of the most recent JRuby versions diff --git a/platform-includes/getting-started-verify/ruby.mdx b/platform-includes/getting-started-verify/ruby.mdx index 2731b0e2ceb7e..05ff645a3b077 100644 --- a/platform-includes/getting-started-verify/ruby.mdx +++ b/platform-includes/getting-started-verify/ruby.mdx @@ -1,3 +1,107 @@ +### Issues + + + + + +To verify that Sentry captures errors and creates issues in your Sentry project, add this intentional error to your application: + + + + ```ruby -Sentry.capture_message("test message") + +begin + 1 / 0 +rescue ZeroDivisionError => exception + Sentry.capture_exception(exception) +end + ``` + + + + + + + +### Tracing + + + + +To test your tracing configuration, create a custom transaction and span: + + + + +```ruby + +Sentry.start_transaction(op: "task", name: "Transaction Name") do |transaction| + Sentry.get_current_scope.set_span(transaction) + + Sentry.with_child_span(description: "Custom Span Name") do |span| + # your instrumented code here + end +end + +``` + + + + + + + + +### Logs + + + + +To verify that Sentry catches your logs, add some log statements to your application using the `Sentry.logger` APIs. + +Use Sentry's Ruby stdlib Logger integration to capture logs from all loggers that use Ruby Logger automatically. + + + + +```ruby + +Sentry.logger.info("This is an info log message") +Sentry.logger.warning("This is a warning message") +Sentry.logger.error("This is an error message") + +``` + + + + + + + + + +### Metrics + + + + +Send test metrics from your app to verify that metrics are arriving in Sentry using the `Sentry.metrics` APIs. + +You can also send Yabeda metrics to Sentry automatically using our Yabeda integration. + + + + +```ruby + +Sentry.metrics.count("checkout.failed", 1) +Sentry.metrics.gauge("queue.depth", 42) +Sentry.metrics.distribution("cart.amount_usd", 187.5) + +``` + + + +