In addition to your web application itself, the New Relic Ruby agent (version 3.6.0 or higher) can automatically instrument your Sidekiq jobs. You do not need to include an instrumentation library in your worker.
The Ruby agent will instrument the
perform method on all Sidekiq workers. Data for background jobs appears in New Relic APM's Transactions page, complete with transaction traces and errors, by selecting Non-web transactions as the transaction type.
Capture job arguments
Starting with Ruby agent version 3.6.9, you can optionally configure the Ruby agent to capture Sidekiq job arguments in transaction traces and traced errors. This can be especially useful in attempting to reproduce failed jobs.
By default this feature is off in case your job arguments contain sensitive information. To enable this feature, edit your newrelic.yml as appropriate for your agent version:
- newrelic_rpm 3.12.0 or higher:
- newrelic_rpm 3.6.9 to 3.11.x:
This feature is distinct from the generic
capture_params top-level setting, which controls whether HTTP request parameters are captured on transaction traces and traced errors for web requests. You can configure these two settings independently.
Troubleshoot Sidekiq jobs
If it appears that jobs are not being monitored, review your newrelic_agent.log file generated when the worker starts. It should indicate whether the agent detects Sidekiq and communicates with the server. If you need support, note the exact command line that you used to start Sidekiq.