-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Profiling
You must be using Ruby 3.3+. Add Vernier to your Gemfile:
gem "vernier", "~> 1.3"- Start Sidekiq.
- Open a console.
- Pick a job type you wish to profile and kick off a job with a special option:
$ bundle exec rails console
> HardJob.set(profile: "token").perform_async("mike", 2, nil)
The purpose of token is to associate profile data to you, making it easier to find your profiles if other team members are also profiling their jobs. Typically I just use "mike" as my token. Profiling works fine with Rails and Active Jobs.
The profiler output is stored in Redis as a Hash with key "token-jid", e.g. "mike-1234567890abcdef".
#{token}-#{jid}:
{
started_at: <timestamp>,
token: <token>,
data: <gzip'd JSON>,
jid: <jid>,
type: <jobtype>,
sid: <storeid> # the profile's storage id at profiler.firefox.com
}
The profiler output data can be large so Sidekiq uses gzip to compress it for storage. Be careful not to profile every job and quickly fill up your Redis! Profiling data expires after 24 hours.
Profiling only saves data if the job is successful. Failures will retry as normal.
The Web UI provides a new Profiles tab with a listing of all profile recordings in Redis. You can click the View button and see your profile in the Firefox Viewer. You can click the Data button to see or download the profile's raw JSON.
Firefox Profiler is a complex JavaScript SPA which can't be maintained or distributed by the Sidekiq project.
Instead Sidekiq uses the public instance at profiler.firefox.com which is run and maintained by Mozilla. When you click the View button in the Web UI, your profile data is uploaded to p.f.c for viewing. Profiling data generally does not contain anything sensitive but it does contain the names of your application classes and methods. It should never contain any application data.
I'm not aware of any official data retention policy from Mozilla for your uploaded profiles. Your profiling data does not leave your system until you click View. You can use the Data button to access the raw JSON, should you wish to run your own Firefox Profiler instance locally.