Star us on GitHub
Star
Menu

Using highlight.io with Other Ruby Frameworks

Learn how to set up highlight.io on your non-Rails Ruby backend.

1

Configure client-side Highlight. (optional)

If you're using Highlight on the frontend for your application, make sure you've initialized it correctly and followed the fullstack mapping guide.

2

Install the Highlight Ruby SDK.

Add Highlight to your Gemfile and install with Bundler.

gem "highlight_io" bundle install
Copy
3

Initialize the Highlight Ruby SDK.

Highlight.init initializes the SDK. Setting your project ID also lets Highlight record errors for background tasks and processes that aren't associated with a frontend session.

require "highlight" Highlight.init("<YOUR_PROJECT_ID>", environment: "production") do |c| c.service_name = "my-app" c.service_version = "1.0.0" end
Copy
4

Verify your errors are being recorded.

Now that you've set up the Middleware, verify that the backend error handling works by consuming an error from traced code.

5

Record custom errors. (optional)

If you want to explicitly send an error to Highlight, you can use the error method within traced code.

Highlight.exception(e)
Copy
6

Set up and call the Highlight Logger.

Highlight::Logger can be used in place of your existing logger, and will record and send logs to Highlight.

require "highlight" Highlight.init("<YOUR_PROJECT_ID>", environment: "production") do |c| c.service_name = "my-ruby-app" c.service_version = "git-sha" end logger = Highlight::Logger.new(STDOUT) logger.info('hello, world!') logger.error('oh no!')
Copy
7

Verify your backend logs are being recorded.

Visit the highlight logs portal and check that backend logs are coming in.

8

Add Highlight tracing.

start_span will automatically record raised exceptions and send them to Highlight.

require "highlight" Highlight.start_span('my-span') do span.add_attribute({ key: "value" }) # your code here end
Copy
9

Verify your backend traces are being recorded.

Visit the highlight traces portal and check that backend traces are coming in.