prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Support Queue timing in Python agent
  Checking the request headers for officially supported frameworks like Django and Flask should be straight forward.
  
  We should also have a generic API interface for recording Queue time in other cases.
  
  --- 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/core/cli/core_agent_manager.py`
  Content:
  ```
  1 # coding=utf-8
  2 from __future__ import absolute_import, division, print_function, unicode_literals
  3 
  4 import argparse
  5 import logging
  6 
  7 
  8 def download(**kwargs):
  9     from scout_apm.core import CoreAgentManager
  10 
  11     core_agent_manager = CoreAgentManager()
  12     core_agent_manager.download()
  13 
  14 
  15 def launch(**kwargs):
  16     from scout_apm.core import CoreAgentManager
  17 
  18     core_agent_manager = CoreAgentManager()
  19     core_agent_manager.launch()
  20 
  21 
  22 def main(**kwargs):
  23     parser = argparse.ArgumentParser()
  24     parser.add_argument(
  25         "-v", "--verbose", help="increase output verbosity", action="count"
  26     )
  27 
  28     subparsers = parser.add_subparsers(dest="subparser")
  29     subparsers.add_parser("download")
  30     subparsers.add_parser("launch")
  31 
  32     args = parser.parse_args()
  33 
  34     if args.verbose is not None:
  35         if args.verbose >= 2:
  36             logging.basicConfig(level=getattr(logging, "DEBUG", None))
  37         elif args.verbose == 1:
  38             logging.basicConfig(level=getattr(logging, "INFO", None))
  39 
  40     kwargs = vars(args)
  41     globals()[kwargs.pop("subparser")](**kwargs)
  42
  ```
  --- 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/core/cli/core_agent_manager.py b/src/scout_apm/core/cli/core_agent_manager.py
  --- a/src/scout_apm/core/cli/core_agent_manager.py
  +++ b/src/scout_apm/core/cli/core_agent_manager.py
  @@ -4,38 +4,31 @@
   import argparse
   import logging
   
  +from scout_apm.core import AgentContext, CoreAgentManager
   
  -def download(**kwargs):
  -    from scout_apm.core import CoreAgentManager
  -
  -    core_agent_manager = CoreAgentManager()
  -    core_agent_manager.download()
  -
  -
  -def launch(**kwargs):
  -    from scout_apm.core import CoreAgentManager
  -
  -    core_agent_manager = CoreAgentManager()
  -    core_agent_manager.launch()
  +logger = logging.getLogger(__name__)
   
   
  -def main(**kwargs):
  +def main(argv=None):
       parser = argparse.ArgumentParser()
       parser.add_argument(
           "-v", "--verbose", help="increase output verbosity", action="count"
       )
   
  -    subparsers = parser.add_subparsers(dest="subparser")
  +    subparsers = parser.add_subparsers(
  +        title="subcommands", description="valid subcommands", dest="subparser"
  +    )
       subparsers.add_parser("download")
       subparsers.add_parser("launch")
   
  -    args = parser.parse_args()
  +    args = parser.parse_args(argv)
   
       if args.verbose is not None:
           if args.verbose >= 2:
  -            logging.basicConfig(level=getattr(logging, "DEBUG", None))
  -        elif args.verbose == 1:
  -            logging.basicConfig(level=getattr(logging, "INFO", None))
  +            logging.basicConfig(level=logging.DEBUG)
  +        else:
  +            logging.basicConfig(level=logging.INFO)
   
  -    kwargs = vars(args)
  -    globals()[kwargs.pop("subparser")](**kwargs)
  +    AgentContext.build()
  +    core_agent_manager = CoreAgentManager()
  +    getattr(core_agent_manager, args.subparser)()
  
verification_info: {"golden_diff": "diff --git a/src/scout_apm/core/cli/core_agent_manager.py b/src/scout_apm/core/cli/core_agent_manager.py\n--- a/src/scout_apm/core/cli/core_agent_manager.py\n+++ b/src/scout_apm/core/cli/core_agent_manager.py\n@@ -4,38 +4,31 @@\n import argparse\n import logging\n \n+from scout_apm.core import AgentContext, CoreAgentManager\n \n-def download(**kwargs):\n-    from scout_apm.core import CoreAgentManager\n-\n-    core_agent_manager = CoreAgentManager()\n-    core_agent_manager.download()\n-\n-\n-def launch(**kwargs):\n-    from scout_apm.core import CoreAgentManager\n-\n-    core_agent_manager = CoreAgentManager()\n-    core_agent_manager.launch()\n+logger = logging.getLogger(__name__)\n \n \n-def main(**kwargs):\n+def main(argv=None):\n     parser = argparse.ArgumentParser()\n     parser.add_argument(\n         \"-v\", \"--verbose\", help=\"increase output verbosity\", action=\"count\"\n     )\n \n-    subparsers = parser.add_subparsers(dest=\"subparser\")\n+    subparsers = parser.add_subparsers(\n+        title=\"subcommands\", description=\"valid subcommands\", dest=\"subparser\"\n+    )\n     subparsers.add_parser(\"download\")\n     subparsers.add_parser(\"launch\")\n \n-    args = parser.parse_args()\n+    args = parser.parse_args(argv)\n \n     if args.verbose is not None:\n         if args.verbose >= 2:\n-            logging.basicConfig(level=getattr(logging, \"DEBUG\", None))\n-        elif args.verbose == 1:\n-            logging.basicConfig(level=getattr(logging, \"INFO\", None))\n+            logging.basicConfig(level=logging.DEBUG)\n+        else:\n+            logging.basicConfig(level=logging.INFO)\n \n-    kwargs = vars(args)\n-    globals()[kwargs.pop(\"subparser\")](**kwargs)\n+    AgentContext.build()\n+    core_agent_manager = CoreAgentManager()\n+    getattr(core_agent_manager, args.subparser)()\n", "issue": "Support Queue timing in Python agent\nChecking the request headers for officially supported frameworks like Django and Flask should be straight forward.\r\n\r\nWe should also have a generic API interface for recording Queue time in other cases.\n", "before_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport argparse\nimport logging\n\n\ndef download(**kwargs):\n    from scout_apm.core import CoreAgentManager\n\n    core_agent_manager = CoreAgentManager()\n    core_agent_manager.download()\n\n\ndef launch(**kwargs):\n    from scout_apm.core import CoreAgentManager\n\n    core_agent_manager = CoreAgentManager()\n    core_agent_manager.launch()\n\n\ndef main(**kwargs):\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        \"-v\", \"--verbose\", help=\"increase output verbosity\", action=\"count\"\n    )\n\n    subparsers = parser.add_subparsers(dest=\"subparser\")\n    subparsers.add_parser(\"download\")\n    subparsers.add_parser(\"launch\")\n\n    args = parser.parse_args()\n\n    if args.verbose is not None:\n        if args.verbose >= 2:\n            logging.basicConfig(level=getattr(logging, \"DEBUG\", None))\n        elif args.verbose == 1:\n            logging.basicConfig(level=getattr(logging, \"INFO\", None))\n\n    kwargs = vars(args)\n    globals()[kwargs.pop(\"subparser\")](**kwargs)\n", "path": "src/scout_apm/core/cli/core_agent_manager.py"}], "after_files": [{"content": "# coding=utf-8\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport argparse\nimport logging\n\nfrom scout_apm.core import AgentContext, CoreAgentManager\n\nlogger = logging.getLogger(__name__)\n\n\ndef main(argv=None):\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        \"-v\", \"--verbose\", help=\"increase output verbosity\", action=\"count\"\n    )\n\n    subparsers = parser.add_subparsers(\n        title=\"subcommands\", description=\"valid subcommands\", dest=\"subparser\"\n    )\n    subparsers.add_parser(\"download\")\n    subparsers.add_parser(\"launch\")\n\n    args = parser.parse_args(argv)\n\n    if args.verbose is not None:\n        if args.verbose >= 2:\n            logging.basicConfig(level=logging.DEBUG)\n        else:\n            logging.basicConfig(level=logging.INFO)\n\n    AgentContext.build()\n    core_agent_manager = CoreAgentManager()\n    getattr(core_agent_manager, args.subparser)()\n", "path": "src/scout_apm/core/cli/core_agent_manager.py"}]}