# Jobs performance monitoring

How to manually add or ignore jobs.


Jobs are treated as the requests in the same familiar interface.

RorVsWild automatically monitors:

- Delayed::Job
- Resque
- Sidekiq
- Faktory
- Any library which follows Active::Job
   
For Resque, your job must inherit `Resque::Job` to be tracked.

## Measure any Ruby code

RorVsWild measures a lot of events such as SQL queries and HTTP requests.
But it might not be enough for you.
There is a solution to measure any section of code to help you find the most hidden bottlenecks:

```ruby
# Measure a code given as a string
RorVsWild.measure("bubble_sort(array)")

# Measure a code given as a block
RorVsWild.measure { bubble_sort(array) }

# Measure a code given as a block with an optional description
RorVsWild.measure("Optional description") { bubble_sort(array) }
```

It's also possible to monitor code even if it's not inside a job or a request.
For example, you would like to monitor a task from a crontab or a console.
You just have to wrap them in `RorVsWild.measure` as follow:

```ruby
RorVsWild.measure("User.all.do_something_great")

# or
RorVsWild.measure("A great job name") { User.all.do_something_great }
```

A `User.all.do_something_great` and `A great job name` will be listed in the jobs tab.
However, if it's already inside a job or a request, it will appear as a section inside of it.

## Ignore controllers and actions

Sometimes, you just don't want to know.
You can either exclude jobs with their name or with a regex to exclude many at once:


```yaml
# config/rorvswild.yml
production:
  api_key: YOUR_API_KEY
    ignore_jobs:
      - SecretJob
      - !ruby/regexp /Secret/ # Skip all jobs containing Secret
```

## Sample jobs

If your application handles a lot of background jobs, you can sample them to lower your monitoring bill. (version >= 1.7.0)


```yaml
  # config/rorvswild.yml
  production:
    api_key: API_KEY
    job_sampling_rate: 0.5 # 50% of jobs are sent
    request_sampling_rate: 0.25 # 25% of requests are sent
```
