prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Tornado <6.0 still tries to instrument (and fails with cryptic warning)
  Flower version is flower==0.9.3
  elastic-apm==6.7.2
  
  Flower service is not working for elastic-apm==6.7.2. 
  Can you please suggest which version is compatible for  flower==0.9.3.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `elasticapm/instrumentation/packages/tornado.py`
  Content:
  ```
  1 #  BSD 3-Clause License
  2 #
  3 #  Copyright (c) 2019, Elasticsearch BV
  4 #  All rights reserved.
  5 #
  6 #  Redistribution and use in source and binary forms, with or without
  7 #  modification, are permitted provided that the following conditions are met:
  8 #
  9 #  * Redistributions of source code must retain the above copyright notice, this
  10 #    list of conditions and the following disclaimer.
  11 #
  12 #  * Redistributions in binary form must reproduce the above copyright notice,
  13 #    this list of conditions and the following disclaimer in the documentation
  14 #    and/or other materials provided with the distribution.
  15 #
  16 #  * Neither the name of the copyright holder nor the names of its
  17 #    contributors may be used to endorse or promote products derived from
  18 #    this software without specific prior written permission.
  19 #
  20 #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 #  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 #  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 #  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 #  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 #  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 #  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 #  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 #  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 """
  31 Instrumentation for Tornado
  32 """
  33 import elasticapm
  34 from elasticapm.conf import constants
  35 from elasticapm.instrumentation.packages.asyncio.base import AbstractInstrumentedModule, AsyncAbstractInstrumentedModule
  36 from elasticapm.traces import capture_span
  37 from elasticapm.utils.disttracing import TraceParent
  38 
  39 
  40 class TornadoRequestExecuteInstrumentation(AsyncAbstractInstrumentedModule):
  41     name = "tornado_request_execute"
  42     creates_transactions = True
  43     instrument_list = [("tornado.web", "RequestHandler._execute")]
  44 
  45     async def call(self, module, method, wrapped, instance, args, kwargs):
  46         if not hasattr(instance.application, "elasticapm_client"):
  47             # If tornado was instrumented but not as the main framework
  48             # (i.e. in Flower), we should skip it.
  49             return await wrapped(*args, **kwargs)
  50 
  51         # Late import to avoid ImportErrors
  52         from elasticapm.contrib.tornado.utils import get_data_from_request, get_data_from_response
  53 
  54         request = instance.request
  55         client = instance.application.elasticapm_client
  56         should_ignore = client.should_ignore_url(request.path)
  57         if not should_ignore:
  58             trace_parent = TraceParent.from_headers(request.headers)
  59             client.begin_transaction("request", trace_parent=trace_parent)
  60             elasticapm.set_context(
  61                 lambda: get_data_from_request(instance, request, client.config, constants.TRANSACTION), "request"
  62             )
  63             # TODO: Can we somehow incorporate the routing rule itself here?
  64             elasticapm.set_transaction_name("{} {}".format(request.method, type(instance).__name__), override=False)
  65 
  66         ret = await wrapped(*args, **kwargs)
  67 
  68         if not should_ignore:
  69             elasticapm.set_context(
  70                 lambda: get_data_from_response(instance, client.config, constants.TRANSACTION), "response"
  71             )
  72             status = instance.get_status()
  73             result = "HTTP {}xx".format(status // 100)
  74             elasticapm.set_transaction_result(result, override=False)
  75             elasticapm.set_transaction_outcome(http_status_code=status)
  76             client.end_transaction()
  77 
  78         return ret
  79 
  80 
  81 class TornadoHandleRequestExceptionInstrumentation(AbstractInstrumentedModule):
  82     name = "tornado_handle_request_exception"
  83 
  84     instrument_list = [("tornado.web", "RequestHandler._handle_request_exception")]
  85 
  86     def call(self, module, method, wrapped, instance, args, kwargs):
  87         if not hasattr(instance.application, "elasticapm_client"):
  88             # If tornado was instrumented but not as the main framework
  89             # (i.e. in Flower), we should skip it.
  90             return wrapped(*args, **kwargs)
  91 
  92         # Late import to avoid ImportErrors
  93         from tornado.web import Finish, HTTPError
  94 
  95         from elasticapm.contrib.tornado.utils import get_data_from_request
  96 
  97         e = args[0]
  98         if isinstance(e, Finish):
  99             # Not an error; Finish is an exception that ends a request without an error response
  100             return wrapped(*args, **kwargs)
  101 
  102         client = instance.application.elasticapm_client
  103         request = instance.request
  104         client.capture_exception(
  105             context={"request": get_data_from_request(instance, request, client.config, constants.ERROR)}
  106         )
  107         elasticapm.set_transaction_outcome(constants.OUTCOME.FAILURE)
  108         if isinstance(e, HTTPError):
  109             elasticapm.set_transaction_result("HTTP {}xx".format(int(e.status_code / 100)), override=False)
  110             elasticapm.set_context({"status_code": e.status_code}, "response")
  111         else:
  112             elasticapm.set_transaction_result("HTTP 5xx", override=False)
  113             elasticapm.set_context({"status_code": 500}, "response")
  114 
  115         return wrapped(*args, **kwargs)
  116 
  117 
  118 class TornadoRenderInstrumentation(AbstractInstrumentedModule):
  119     name = "tornado_render"
  120 
  121     instrument_list = [("tornado.web", "RequestHandler.render")]
  122 
  123     def call(self, module, method, wrapped, instance, args, kwargs):
  124         if "template_name" in kwargs:
  125             name = kwargs["template_name"]
  126         else:
  127             name = args[0]
  128 
  129         with capture_span(name, span_type="template", span_subtype="tornado", span_action="render"):
  130             return wrapped(*args, **kwargs)
  131
  ```
  --- 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/elasticapm/instrumentation/packages/tornado.py b/elasticapm/instrumentation/packages/tornado.py
  --- a/elasticapm/instrumentation/packages/tornado.py
  +++ b/elasticapm/instrumentation/packages/tornado.py
  @@ -35,9 +35,25 @@
   from elasticapm.instrumentation.packages.asyncio.base import AbstractInstrumentedModule, AsyncAbstractInstrumentedModule
   from elasticapm.traces import capture_span
   from elasticapm.utils.disttracing import TraceParent
  +from elasticapm.utils.logging import get_logger
   
  +logger = get_logger("elasticapm.instrument")
   
  -class TornadoRequestExecuteInstrumentation(AsyncAbstractInstrumentedModule):
  +
  +class TornadoBaseInstrumentedModule(AbstractInstrumentedModule):
  +    def instrument(self):
  +        try:
  +            import tornado
  +
  +            if tornado.version_info[0] < 6:
  +                logger.debug("Skipping instrumentation of %s. Tornado is only supported with version 6.0+", self.name)
  +                return
  +        except ImportError:
  +            pass
  +        super().instrument()
  +
  +
  +class TornadoRequestExecuteInstrumentation(TornadoBaseInstrumentedModule, AsyncAbstractInstrumentedModule):
       name = "tornado_request_execute"
       creates_transactions = True
       instrument_list = [("tornado.web", "RequestHandler._execute")]
  @@ -78,7 +94,7 @@
           return ret
   
   
  -class TornadoHandleRequestExceptionInstrumentation(AbstractInstrumentedModule):
  +class TornadoHandleRequestExceptionInstrumentation(TornadoBaseInstrumentedModule):
       name = "tornado_handle_request_exception"
   
       instrument_list = [("tornado.web", "RequestHandler._handle_request_exception")]
  @@ -115,7 +131,7 @@
           return wrapped(*args, **kwargs)
   
   
  -class TornadoRenderInstrumentation(AbstractInstrumentedModule):
  +class TornadoRenderInstrumentation(TornadoBaseInstrumentedModule):
       name = "tornado_render"
   
       instrument_list = [("tornado.web", "RequestHandler.render")]
  
verification_info: {"golden_diff": "diff --git a/elasticapm/instrumentation/packages/tornado.py b/elasticapm/instrumentation/packages/tornado.py\n--- a/elasticapm/instrumentation/packages/tornado.py\n+++ b/elasticapm/instrumentation/packages/tornado.py\n@@ -35,9 +35,25 @@\n from elasticapm.instrumentation.packages.asyncio.base import AbstractInstrumentedModule, AsyncAbstractInstrumentedModule\n from elasticapm.traces import capture_span\n from elasticapm.utils.disttracing import TraceParent\n+from elasticapm.utils.logging import get_logger\n \n+logger = get_logger(\"elasticapm.instrument\")\n \n-class TornadoRequestExecuteInstrumentation(AsyncAbstractInstrumentedModule):\n+\n+class TornadoBaseInstrumentedModule(AbstractInstrumentedModule):\n+    def instrument(self):\n+        try:\n+            import tornado\n+\n+            if tornado.version_info[0] < 6:\n+                logger.debug(\"Skipping instrumentation of %s. Tornado is only supported with version 6.0+\", self.name)\n+                return\n+        except ImportError:\n+            pass\n+        super().instrument()\n+\n+\n+class TornadoRequestExecuteInstrumentation(TornadoBaseInstrumentedModule, AsyncAbstractInstrumentedModule):\n     name = \"tornado_request_execute\"\n     creates_transactions = True\n     instrument_list = [(\"tornado.web\", \"RequestHandler._execute\")]\n@@ -78,7 +94,7 @@\n         return ret\n \n \n-class TornadoHandleRequestExceptionInstrumentation(AbstractInstrumentedModule):\n+class TornadoHandleRequestExceptionInstrumentation(TornadoBaseInstrumentedModule):\n     name = \"tornado_handle_request_exception\"\n \n     instrument_list = [(\"tornado.web\", \"RequestHandler._handle_request_exception\")]\n@@ -115,7 +131,7 @@\n         return wrapped(*args, **kwargs)\n \n \n-class TornadoRenderInstrumentation(AbstractInstrumentedModule):\n+class TornadoRenderInstrumentation(TornadoBaseInstrumentedModule):\n     name = \"tornado_render\"\n \n     instrument_list = [(\"tornado.web\", \"RequestHandler.render\")]\n", "issue": "Tornado <6.0 still tries to instrument (and fails with cryptic warning)\nFlower version is flower==0.9.3\r\nelastic-apm==6.7.2\r\n\r\nFlower service is not working for elastic-apm==6.7.2. \r\nCan you please suggest which version is compatible for  flower==0.9.3.\n", "before_files": [{"content": "#  BSD 3-Clause License\n#\n#  Copyright (c) 2019, Elasticsearch BV\n#  All rights reserved.\n#\n#  Redistribution and use in source and binary forms, with or without\n#  modification, are permitted provided that the following conditions are met:\n#\n#  * Redistributions of source code must retain the above copyright notice, this\n#    list of conditions and the following disclaimer.\n#\n#  * Redistributions in binary form must reproduce the above copyright notice,\n#    this list of conditions and the following disclaimer in the documentation\n#    and/or other materials provided with the distribution.\n#\n#  * Neither the name of the copyright holder nor the names of its\n#    contributors may be used to endorse or promote products derived from\n#    this software without specific prior written permission.\n#\n#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\"\"\"\nInstrumentation for Tornado\n\"\"\"\nimport elasticapm\nfrom elasticapm.conf import constants\nfrom elasticapm.instrumentation.packages.asyncio.base import AbstractInstrumentedModule, AsyncAbstractInstrumentedModule\nfrom elasticapm.traces import capture_span\nfrom elasticapm.utils.disttracing import TraceParent\n\n\nclass TornadoRequestExecuteInstrumentation(AsyncAbstractInstrumentedModule):\n    name = \"tornado_request_execute\"\n    creates_transactions = True\n    instrument_list = [(\"tornado.web\", \"RequestHandler._execute\")]\n\n    async def call(self, module, method, wrapped, instance, args, kwargs):\n        if not hasattr(instance.application, \"elasticapm_client\"):\n            # If tornado was instrumented but not as the main framework\n            # (i.e. in Flower), we should skip it.\n            return await wrapped(*args, **kwargs)\n\n        # Late import to avoid ImportErrors\n        from elasticapm.contrib.tornado.utils import get_data_from_request, get_data_from_response\n\n        request = instance.request\n        client = instance.application.elasticapm_client\n        should_ignore = client.should_ignore_url(request.path)\n        if not should_ignore:\n            trace_parent = TraceParent.from_headers(request.headers)\n            client.begin_transaction(\"request\", trace_parent=trace_parent)\n            elasticapm.set_context(\n                lambda: get_data_from_request(instance, request, client.config, constants.TRANSACTION), \"request\"\n            )\n            # TODO: Can we somehow incorporate the routing rule itself here?\n            elasticapm.set_transaction_name(\"{} {}\".format(request.method, type(instance).__name__), override=False)\n\n        ret = await wrapped(*args, **kwargs)\n\n        if not should_ignore:\n            elasticapm.set_context(\n                lambda: get_data_from_response(instance, client.config, constants.TRANSACTION), \"response\"\n            )\n            status = instance.get_status()\n            result = \"HTTP {}xx\".format(status // 100)\n            elasticapm.set_transaction_result(result, override=False)\n            elasticapm.set_transaction_outcome(http_status_code=status)\n            client.end_transaction()\n\n        return ret\n\n\nclass TornadoHandleRequestExceptionInstrumentation(AbstractInstrumentedModule):\n    name = \"tornado_handle_request_exception\"\n\n    instrument_list = [(\"tornado.web\", \"RequestHandler._handle_request_exception\")]\n\n    def call(self, module, method, wrapped, instance, args, kwargs):\n        if not hasattr(instance.application, \"elasticapm_client\"):\n            # If tornado was instrumented but not as the main framework\n            # (i.e. in Flower), we should skip it.\n            return wrapped(*args, **kwargs)\n\n        # Late import to avoid ImportErrors\n        from tornado.web import Finish, HTTPError\n\n        from elasticapm.contrib.tornado.utils import get_data_from_request\n\n        e = args[0]\n        if isinstance(e, Finish):\n            # Not an error; Finish is an exception that ends a request without an error response\n            return wrapped(*args, **kwargs)\n\n        client = instance.application.elasticapm_client\n        request = instance.request\n        client.capture_exception(\n            context={\"request\": get_data_from_request(instance, request, client.config, constants.ERROR)}\n        )\n        elasticapm.set_transaction_outcome(constants.OUTCOME.FAILURE)\n        if isinstance(e, HTTPError):\n            elasticapm.set_transaction_result(\"HTTP {}xx\".format(int(e.status_code / 100)), override=False)\n            elasticapm.set_context({\"status_code\": e.status_code}, \"response\")\n        else:\n            elasticapm.set_transaction_result(\"HTTP 5xx\", override=False)\n            elasticapm.set_context({\"status_code\": 500}, \"response\")\n\n        return wrapped(*args, **kwargs)\n\n\nclass TornadoRenderInstrumentation(AbstractInstrumentedModule):\n    name = \"tornado_render\"\n\n    instrument_list = [(\"tornado.web\", \"RequestHandler.render\")]\n\n    def call(self, module, method, wrapped, instance, args, kwargs):\n        if \"template_name\" in kwargs:\n            name = kwargs[\"template_name\"]\n        else:\n            name = args[0]\n\n        with capture_span(name, span_type=\"template\", span_subtype=\"tornado\", span_action=\"render\"):\n            return wrapped(*args, **kwargs)\n", "path": "elasticapm/instrumentation/packages/tornado.py"}], "after_files": [{"content": "#  BSD 3-Clause License\n#\n#  Copyright (c) 2019, Elasticsearch BV\n#  All rights reserved.\n#\n#  Redistribution and use in source and binary forms, with or without\n#  modification, are permitted provided that the following conditions are met:\n#\n#  * Redistributions of source code must retain the above copyright notice, this\n#    list of conditions and the following disclaimer.\n#\n#  * Redistributions in binary form must reproduce the above copyright notice,\n#    this list of conditions and the following disclaimer in the documentation\n#    and/or other materials provided with the distribution.\n#\n#  * Neither the name of the copyright holder nor the names of its\n#    contributors may be used to endorse or promote products derived from\n#    this software without specific prior written permission.\n#\n#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\"\"\"\nInstrumentation for Tornado\n\"\"\"\nimport elasticapm\nfrom elasticapm.conf import constants\nfrom elasticapm.instrumentation.packages.asyncio.base import AbstractInstrumentedModule, AsyncAbstractInstrumentedModule\nfrom elasticapm.traces import capture_span\nfrom elasticapm.utils.disttracing import TraceParent\nfrom elasticapm.utils.logging import get_logger\n\nlogger = get_logger(\"elasticapm.instrument\")\n\n\nclass TornadoBaseInstrumentedModule(AbstractInstrumentedModule):\n    def instrument(self):\n        try:\n            import tornado\n\n            if tornado.version_info[0] < 6:\n                logger.debug(\"Skipping instrumentation of %s. Tornado is only supported with version 6.0+\", self.name)\n                return\n        except ImportError:\n            pass\n        super().instrument()\n\n\nclass TornadoRequestExecuteInstrumentation(TornadoBaseInstrumentedModule, AsyncAbstractInstrumentedModule):\n    name = \"tornado_request_execute\"\n    creates_transactions = True\n    instrument_list = [(\"tornado.web\", \"RequestHandler._execute\")]\n\n    async def call(self, module, method, wrapped, instance, args, kwargs):\n        if not hasattr(instance.application, \"elasticapm_client\"):\n            # If tornado was instrumented but not as the main framework\n            # (i.e. in Flower), we should skip it.\n            return await wrapped(*args, **kwargs)\n\n        # Late import to avoid ImportErrors\n        from elasticapm.contrib.tornado.utils import get_data_from_request, get_data_from_response\n\n        request = instance.request\n        client = instance.application.elasticapm_client\n        should_ignore = client.should_ignore_url(request.path)\n        if not should_ignore:\n            trace_parent = TraceParent.from_headers(request.headers)\n            client.begin_transaction(\"request\", trace_parent=trace_parent)\n            elasticapm.set_context(\n                lambda: get_data_from_request(instance, request, client.config, constants.TRANSACTION), \"request\"\n            )\n            # TODO: Can we somehow incorporate the routing rule itself here?\n            elasticapm.set_transaction_name(\"{} {}\".format(request.method, type(instance).__name__), override=False)\n\n        ret = await wrapped(*args, **kwargs)\n\n        if not should_ignore:\n            elasticapm.set_context(\n                lambda: get_data_from_response(instance, client.config, constants.TRANSACTION), \"response\"\n            )\n            status = instance.get_status()\n            result = \"HTTP {}xx\".format(status // 100)\n            elasticapm.set_transaction_result(result, override=False)\n            elasticapm.set_transaction_outcome(http_status_code=status)\n            client.end_transaction()\n\n        return ret\n\n\nclass TornadoHandleRequestExceptionInstrumentation(TornadoBaseInstrumentedModule):\n    name = \"tornado_handle_request_exception\"\n\n    instrument_list = [(\"tornado.web\", \"RequestHandler._handle_request_exception\")]\n\n    def call(self, module, method, wrapped, instance, args, kwargs):\n        if not hasattr(instance.application, \"elasticapm_client\"):\n            # If tornado was instrumented but not as the main framework\n            # (i.e. in Flower), we should skip it.\n            return wrapped(*args, **kwargs)\n\n        # Late import to avoid ImportErrors\n        from tornado.web import Finish, HTTPError\n\n        from elasticapm.contrib.tornado.utils import get_data_from_request\n\n        e = args[0]\n        if isinstance(e, Finish):\n            # Not an error; Finish is an exception that ends a request without an error response\n            return wrapped(*args, **kwargs)\n\n        client = instance.application.elasticapm_client\n        request = instance.request\n        client.capture_exception(\n            context={\"request\": get_data_from_request(instance, request, client.config, constants.ERROR)}\n        )\n        elasticapm.set_transaction_outcome(constants.OUTCOME.FAILURE)\n        if isinstance(e, HTTPError):\n            elasticapm.set_transaction_result(\"HTTP {}xx\".format(int(e.status_code / 100)), override=False)\n            elasticapm.set_context({\"status_code\": e.status_code}, \"response\")\n        else:\n            elasticapm.set_transaction_result(\"HTTP 5xx\", override=False)\n            elasticapm.set_context({\"status_code\": 500}, \"response\")\n\n        return wrapped(*args, **kwargs)\n\n\nclass TornadoRenderInstrumentation(TornadoBaseInstrumentedModule):\n    name = \"tornado_render\"\n\n    instrument_list = [(\"tornado.web\", \"RequestHandler.render\")]\n\n    def call(self, module, method, wrapped, instance, args, kwargs):\n        if \"template_name\" in kwargs:\n            name = kwargs[\"template_name\"]\n        else:\n            name = args[0]\n\n        with capture_span(name, span_type=\"template\", span_subtype=\"tornado\", span_action=\"render\"):\n            return wrapped(*args, **kwargs)\n", "path": "elasticapm/instrumentation/packages/tornado.py"}]}