prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add RQ subclass of HerokuWorker
  The "Using RQ on Heroku" docs section ( https://python-rq.org/patterns/ ) shows using a subclass of `Worker` specialized for Heroku. Unfortunateely using that, rather than the Scout RQ Worker subclass means that scout isn't instrumented. We should also provide a `ScoutHerokuWorker` class.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/scout_apm/rq.py`
  Content:
  ```
  1 # coding=utf-8
  2 from __future__ import absolute_import, division, print_function, unicode_literals
  3 
  4 import datetime as dt
  5 
  6 import wrapt
  7 from rq import SimpleWorker as RqSimpleWorker
  8 from rq import Worker as RqWorker
  9 from rq.job import Job
  10 
  11 import scout_apm.core
  12 from scout_apm.core.tracked_request import TrackedRequest
  13 
  14 install_attempted = False
  15 installed = None
  16 
  17 
  18 def ensure_scout_installed():
  19     global install_attempted, installed
  20 
  21     if not install_attempted:
  22         install_attempted = True
  23         installed = scout_apm.core.install()
  24 
  25 
  26 class WorkerMixin(object):
  27     def __init__(self, *args, **kwargs):
  28         global installed
  29         ensure_scout_installed()
  30         if installed:
  31             ensure_job_instrumented()
  32         super(WorkerMixin, self).__init__(*args, **kwargs)
  33 
  34 
  35 class Worker(WorkerMixin, RqWorker):
  36     pass
  37 
  38 
  39 class SimpleWorker(WorkerMixin, RqSimpleWorker):
  40     pass
  41 
  42 
  43 job_instrumented = False
  44 
  45 
  46 def ensure_job_instrumented():
  47     global job_instrumented
  48     if job_instrumented:
  49         return
  50     job_instrumented = True
  51     Job.perform = wrap_perform(Job.perform)
  52 
  53 
  54 @wrapt.decorator
  55 def wrap_perform(wrapped, instance, args, kwargs):
  56     global installed
  57     if not installed:
  58         return wrapped(*args, **kwargs)
  59 
  60     tracked_request = TrackedRequest.instance()
  61     tracked_request.is_real_request = True
  62     tracked_request.tag("task_id", instance.get_id())
  63     tracked_request.tag("queue", instance.origin)
  64     queue_time = (dt.datetime.utcnow() - instance.enqueued_at).total_seconds()
  65     tracked_request.tag("queue_time", queue_time)
  66     tracked_request.start_span(operation="Job/{}".format(instance.func_name))
  67     try:
  68         return wrapped(*args, **kwargs)
  69     except Exception:
  70         tracked_request.tag("error", "true")
  71         raise
  72     finally:
  73         tracked_request.stop_span()
  74
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/scout_apm/rq.py b/src/scout_apm/rq.py
  --- a/src/scout_apm/rq.py
  +++ b/src/scout_apm/rq.py
  @@ -7,6 +7,7 @@
   from rq import SimpleWorker as RqSimpleWorker
   from rq import Worker as RqWorker
   from rq.job import Job
  +from rq.worker import HerokuWorker as RqHerokuWorker
   
   import scout_apm.core
   from scout_apm.core.tracked_request import TrackedRequest
  @@ -40,6 +41,10 @@
       pass
   
   
  +class HerokuWorker(WorkerMixin, RqHerokuWorker):
  +    pass
  +
  +
   job_instrumented = False
  
verification_info: {"golden_diff": "diff --git a/src/scout_apm/rq.py b/src/scout_apm/rq.py\n--- a/src/scout_apm/rq.py\n+++ b/src/scout_apm/rq.py\n@@ -7,6 +7,7 @@\n from rq import SimpleWorker as RqSimpleWorker\n from rq import Worker as RqWorker\n from rq.job import Job\n+from rq.worker import HerokuWorker as RqHerokuWorker\n \n import scout_apm.core\n from scout_apm.core.tracked_request import TrackedRequest\n@@ -40,6 +41,10 @@\n     pass\n \n \n+class HerokuWorker(WorkerMixin, RqHerokuWorker):\n+    pass\n+\n+\n job_instrumented = False\n", "issue": "Add RQ subclass of HerokuWorker\nThe \"Using RQ on Heroku\" docs section ( https://python-rq.org/patterns/ ) shows using a subclass of `Worker` specialized for Heroku. Unfortunateely using that, rather than the Scout RQ Worker subclass means that scout isn't instrumented. We should also provide a `ScoutHerokuWorker` class.\n", "before_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport datetime as dt\n\nimport wrapt\nfrom rq import SimpleWorker as RqSimpleWorker\nfrom rq import Worker as RqWorker\nfrom rq.job import Job\n\nimport scout_apm.core\nfrom scout_apm.core.tracked_request import TrackedRequest\n\ninstall_attempted = False\ninstalled = None\n\n\ndef ensure_scout_installed():\n    global install_attempted, installed\n\n    if not install_attempted:\n        install_attempted = True\n        installed = scout_apm.core.install()\n\n\nclass WorkerMixin(object):\n    def __init__(self, *args, **kwargs):\n        global installed\n        ensure_scout_installed()\n        if installed:\n            ensure_job_instrumented()\n        super(WorkerMixin, self).__init__(*args, **kwargs)\n\n\nclass Worker(WorkerMixin, RqWorker):\n    pass\n\n\nclass SimpleWorker(WorkerMixin, RqSimpleWorker):\n    pass\n\n\njob_instrumented = False\n\n\ndef ensure_job_instrumented():\n    global job_instrumented\n    if job_instrumented:\n        return\n    job_instrumented = True\n    Job.perform = wrap_perform(Job.perform)\n\n\n@wrapt.decorator\ndef wrap_perform(wrapped, instance, args, kwargs):\n    global installed\n    if not installed:\n        return wrapped(*args, **kwargs)\n\n    tracked_request = TrackedRequest.instance()\n    tracked_request.is_real_request = True\n    tracked_request.tag(\"task_id\", instance.get_id())\n    tracked_request.tag(\"queue\", instance.origin)\n    queue_time = (dt.datetime.utcnow() - instance.enqueued_at).total_seconds()\n    tracked_request.tag(\"queue_time\", queue_time)\n    tracked_request.start_span(operation=\"Job/{}\".format(instance.func_name))\n    try:\n        return wrapped(*args, **kwargs)\n    except Exception:\n        tracked_request.tag(\"error\", \"true\")\n        raise\n    finally:\n        tracked_request.stop_span()\n", "path": "src/scout_apm/rq.py"}], "after_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport datetime as dt\n\nimport wrapt\nfrom rq import SimpleWorker as RqSimpleWorker\nfrom rq import Worker as RqWorker\nfrom rq.job import Job\nfrom rq.worker import HerokuWorker as RqHerokuWorker\n\nimport scout_apm.core\nfrom scout_apm.core.tracked_request import TrackedRequest\n\ninstall_attempted = False\ninstalled = None\n\n\ndef ensure_scout_installed():\n    global install_attempted, installed\n\n    if not install_attempted:\n        install_attempted = True\n        installed = scout_apm.core.install()\n\n\nclass WorkerMixin(object):\n    def __init__(self, *args, **kwargs):\n        global installed\n        ensure_scout_installed()\n        if installed:\n            ensure_job_instrumented()\n        super(WorkerMixin, self).__init__(*args, **kwargs)\n\n\nclass Worker(WorkerMixin, RqWorker):\n    pass\n\n\nclass SimpleWorker(WorkerMixin, RqSimpleWorker):\n    pass\n\n\nclass HerokuWorker(WorkerMixin, RqHerokuWorker):\n    pass\n\n\njob_instrumented = False\n\n\ndef ensure_job_instrumented():\n    global job_instrumented\n    if job_instrumented:\n        return\n    job_instrumented = True\n    Job.perform = wrap_perform(Job.perform)\n\n\n@wrapt.decorator\ndef wrap_perform(wrapped, instance, args, kwargs):\n    global installed\n    if not installed:\n        return wrapped(*args, **kwargs)\n\n    tracked_request = TrackedRequest.instance()\n    tracked_request.is_real_request = True\n    tracked_request.tag(\"task_id\", instance.get_id())\n    tracked_request.tag(\"queue\", instance.origin)\n    queue_time = (dt.datetime.utcnow() - instance.enqueued_at).total_seconds()\n    tracked_request.tag(\"queue_time\", queue_time)\n    tracked_request.start_span(operation=\"Job/{}\".format(instance.func_name))\n    try:\n        return wrapped(*args, **kwargs)\n    except Exception:\n        tracked_request.tag(\"error\", \"true\")\n        raise\n    finally:\n        tracked_request.stop_span()\n", "path": "src/scout_apm/rq.py"}]}