prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Capture Celery Queue Name
  
  
  --- 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/celery.py`
  Content:
  ```
  1 # coding=utf-8
  2 from __future__ import absolute_import, division, print_function, unicode_literals
  3 
  4 from celery.signals import task_postrun, task_prerun
  5 
  6 import scout_apm.core
  7 from scout_apm.core.tracked_request import TrackedRequest
  8 
  9 
  10 # TODO: Capture queue.
  11 # https://stackoverflow.com/questions/22385297/how-to-get-the-queue-in-which-a-task-was-run-celery?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
  12 def prerun_callback(sender=None, headers=None, body=None, **kwargs):
  13     name = kwargs["task"].name
  14 
  15     tr = TrackedRequest.instance()
  16     tr.mark_real_request()
  17     span = tr.start_span(operation=("Job/" + name))
  18     span.tag("queue", "default")
  19 
  20 
  21 def postrun_callback(sender=None, headers=None, body=None, **kwargs):
  22     tr = TrackedRequest.instance()
  23     tr.stop_span()
  24 
  25 
  26 def install():
  27     installed = scout_apm.core.install()
  28     if not installed:
  29         return
  30 
  31     task_prerun.connect(prerun_callback)
  32     task_postrun.connect(postrun_callback)
  33 
  34 
  35 def uninstall():
  36     task_prerun.disconnect(prerun_callback)
  37     task_postrun.disconnect(postrun_callback)
  38
  ```
  --- 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/celery.py b/src/scout_apm/celery.py
  --- a/src/scout_apm/celery.py
  +++ b/src/scout_apm/celery.py
  @@ -7,20 +7,22 @@
   from scout_apm.core.tracked_request import TrackedRequest
   
   
  -# TODO: Capture queue.
  -# https://stackoverflow.com/questions/22385297/how-to-get-the-queue-in-which-a-task-was-run-celery?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
  -def prerun_callback(sender=None, headers=None, body=None, **kwargs):
  -    name = kwargs["task"].name
  +def prerun_callback(task=None, **kwargs):
  +    tracked_request = TrackedRequest.instance()
  +    tracked_request.mark_real_request()
   
  -    tr = TrackedRequest.instance()
  -    tr.mark_real_request()
  -    span = tr.start_span(operation=("Job/" + name))
  -    span.tag("queue", "default")
  +    delivery_info = task.request.delivery_info
  +    tracked_request.tag("is_eager", delivery_info.get("is_eager", False))
  +    tracked_request.tag("exchange", delivery_info.get("exchange", "unknown"))
  +    tracked_request.tag("routing_key", delivery_info.get("routing_key", "unknown"))
  +    tracked_request.tag("queue", delivery_info.get("queue", "unknown"))
   
  +    tracked_request.start_span(operation=("Job/" + task.name))
   
  -def postrun_callback(sender=None, headers=None, body=None, **kwargs):
  -    tr = TrackedRequest.instance()
  -    tr.stop_span()
  +
  +def postrun_callback(task=None, **kwargs):
  +    tracked_request = TrackedRequest.instance()
  +    tracked_request.stop_span()
   
   
   def install():
  
verification_info: {"golden_diff": "diff --git a/src/scout_apm/celery.py b/src/scout_apm/celery.py\n--- a/src/scout_apm/celery.py\n+++ b/src/scout_apm/celery.py\n@@ -7,20 +7,22 @@\n from scout_apm.core.tracked_request import TrackedRequest\n \n \n-# TODO: Capture queue.\n-# https://stackoverflow.com/questions/22385297/how-to-get-the-queue-in-which-a-task-was-run-celery?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa\n-def prerun_callback(sender=None, headers=None, body=None, **kwargs):\n-    name = kwargs[\"task\"].name\n+def prerun_callback(task=None, **kwargs):\n+    tracked_request = TrackedRequest.instance()\n+    tracked_request.mark_real_request()\n \n-    tr = TrackedRequest.instance()\n-    tr.mark_real_request()\n-    span = tr.start_span(operation=(\"Job/\" + name))\n-    span.tag(\"queue\", \"default\")\n+    delivery_info = task.request.delivery_info\n+    tracked_request.tag(\"is_eager\", delivery_info.get(\"is_eager\", False))\n+    tracked_request.tag(\"exchange\", delivery_info.get(\"exchange\", \"unknown\"))\n+    tracked_request.tag(\"routing_key\", delivery_info.get(\"routing_key\", \"unknown\"))\n+    tracked_request.tag(\"queue\", delivery_info.get(\"queue\", \"unknown\"))\n \n+    tracked_request.start_span(operation=(\"Job/\" + task.name))\n \n-def postrun_callback(sender=None, headers=None, body=None, **kwargs):\n-    tr = TrackedRequest.instance()\n-    tr.stop_span()\n+\n+def postrun_callback(task=None, **kwargs):\n+    tracked_request = TrackedRequest.instance()\n+    tracked_request.stop_span()\n \n \n def install():\n", "issue": "Capture Celery Queue Name\n\n", "before_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom celery.signals import task_postrun, task_prerun\n\nimport scout_apm.core\nfrom scout_apm.core.tracked_request import TrackedRequest\n\n\n# TODO: Capture queue.\n# https://stackoverflow.com/questions/22385297/how-to-get-the-queue-in-which-a-task-was-run-celery?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa\ndef prerun_callback(sender=None, headers=None, body=None, **kwargs):\n    name = kwargs[\"task\"].name\n\n    tr = TrackedRequest.instance()\n    tr.mark_real_request()\n    span = tr.start_span(operation=(\"Job/\" + name))\n    span.tag(\"queue\", \"default\")\n\n\ndef postrun_callback(sender=None, headers=None, body=None, **kwargs):\n    tr = TrackedRequest.instance()\n    tr.stop_span()\n\n\ndef install():\n    installed = scout_apm.core.install()\n    if not installed:\n        return\n\n    task_prerun.connect(prerun_callback)\n    task_postrun.connect(postrun_callback)\n\n\ndef uninstall():\n    task_prerun.disconnect(prerun_callback)\n    task_postrun.disconnect(postrun_callback)\n", "path": "src/scout_apm/celery.py"}], "after_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom celery.signals import task_postrun, task_prerun\n\nimport scout_apm.core\nfrom scout_apm.core.tracked_request import TrackedRequest\n\n\ndef prerun_callback(task=None, **kwargs):\n    tracked_request = TrackedRequest.instance()\n    tracked_request.mark_real_request()\n\n    delivery_info = task.request.delivery_info\n    tracked_request.tag(\"is_eager\", delivery_info.get(\"is_eager\", False))\n    tracked_request.tag(\"exchange\", delivery_info.get(\"exchange\", \"unknown\"))\n    tracked_request.tag(\"routing_key\", delivery_info.get(\"routing_key\", \"unknown\"))\n    tracked_request.tag(\"queue\", delivery_info.get(\"queue\", \"unknown\"))\n\n    tracked_request.start_span(operation=(\"Job/\" + task.name))\n\n\ndef postrun_callback(task=None, **kwargs):\n    tracked_request = TrackedRequest.instance()\n    tracked_request.stop_span()\n\n\ndef install():\n    installed = scout_apm.core.install()\n    if not installed:\n        return\n\n    task_prerun.connect(prerun_callback)\n    task_postrun.connect(postrun_callback)\n\n\ndef uninstall():\n    task_prerun.disconnect(prerun_callback)\n    task_postrun.disconnect(postrun_callback)\n", "path": "src/scout_apm/celery.py"}]}