Send metrics and events from Ruby and Rails apps to Honeybadger Insights
Logs
Sending your logs to Insights is a quick way to get some visibility into your app. There are two good options:
- Use the rails_semantic_logger gem and enable the
HoneybadgerInsights
appender by addingconfig.semantic_logger.add_appender(appender: :honeybadger_insights)
toconfig/application.rb
. Outside of Rails, you can use the same appender with the semantic_logger gem. - Use Lograge to emit JSON-formatted output to your log files and Vector to forward them to Insights. If you go this route, be sure to disable the log tagging in your Rails environment config (
config/environments/production.rb
) by commenting out theconfig.log_tags
line, as that will mess with the JSON output.
Metrics
You can get more details about what's happening in your application by enabling our gem's automatic instrumentation, which will report information about every SQL query, HTTP request, etc. to Insights. This will consume more Insights quota than the logging approach, but you will get much more data to use for analyzing your app's performance, and this will populate our ready-made Rails dashboard, which includes charts for request duration, SQL query counts, and more. More information can be found here.
Alternatively, you can use Yabeda and our Yabeda integration to collect and report metrics in your Ruby and Rails apps. Several default metrics, such as request counts, request duration, etc., will be reported automatically once you've added and configured the gems.
Events
If you have custom events you'd like to track, use Honeybadger#event
to report those events to Insights:
# app/controllers/accounts_controller.rb
class AccountsController < ApplicationController
def create
# Account.create(...)
Honeybadger.event("Created account", account_id: account.id, account_name: account.name, plan: account.subscription.name)
end
end
More information about sending events to Insights from your Ruby and Rails apps can be found here.