A Gem of an Update: Performance Monitoring for Ruby
In order to continuously improve your Ruby application, you need to understand everything your code touches. That means visibility into how your frontend responds to the database queries that are central to your Ruby application.
Sentry’s new Ruby SDK collects and monitors the data surrounding your traces, logs, and key performance monitoring metrics. With it, you now have the context to connect backend issues to frontend performance.
Sentry’s distributed tracing not only informs you which environment the error occurred, but the deploy that caused it. Now you can link traces to its related issue (or the other way around) to help you fully understand the relationship between an issue and its impact.
Sentry.init do |config| config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0' # To activate performance monitoring, set one of these options. # We recommend adjusting the value in production: config.traces_sample_rate = 0.5 # or config.traces_sampler = lambda do |context| true end end
With distributed tracing, you can either set a uniform sample rate or control the sample rate dynamically.
Our Ruby SDK has a default integration with Rack, so you only need to use the middleware in your application:
require 'sentry-ruby' Sentry.init do |config| config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0'
Otherwise, you can always use the capture helpers manually.
Sentry.capture_message("hello world!") begin 1 / 0 rescue ZeroDivisionError => exception Sentry.capture_exception(exception)
From AirBnB to RapGenius, Ruby is enjoying a renaissance. That’s because developers are beginning to reacknowledge Ruby’s value as a mature, supported framework that can simplify common e-commerce functions. But that’s only if you modernize your approach to working with Ruby; that is, instrumenting your code to meet the demands of today’s users.