We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Tornado Tracer configuration doesn't have access to settings object for Trace Filtering


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ddtrace/contrib/tornado/__init__.py`
Content:
```
1 """
2 The Tornado integration traces all ``RequestHandler`` defined in a Tornado web application.
3 Auto instrumentation is available using the ``patch`` function that **must be called before**
4 importing the tornado library. The following is an example::
5 
6     # patch before importing tornado and concurrent.futures
7     from ddtrace import tracer, patch
8     patch(tornado=True)
9 
10     import tornado.web
11     import tornado.gen
12     import tornado.ioloop
13 
14     # create your handlers
15     class MainHandler(tornado.web.RequestHandler):
16         @tornado.gen.coroutine
17         def get(self):
18             self.write("Hello, world")
19 
20     # create your application
21     app = tornado.web.Application([
22         (r'/', MainHandler),
23     ])
24 
25     # and run it as usual
26     app.listen(8888)
27     tornado.ioloop.IOLoop.current().start()
28 
29 When any type of ``RequestHandler`` is hit, a request root span is automatically created. If
30 you want to trace more parts of your application, you can use the ``wrap()`` decorator and
31 the ``trace()`` method as usual::
32 
33     class MainHandler(tornado.web.RequestHandler):
34         @tornado.gen.coroutine
35         def get(self):
36             yield self.notify()
37             yield self.blocking_method()
38             with tracer.trace('tornado.before_write') as span:
39                 # trace more work in the handler
40 
41         @tracer.wrap('tornado.executor_handler')
42         @tornado.concurrent.run_on_executor
43         def blocking_method(self):
44             # do something expensive
45 
46         @tracer.wrap('tornado.notify', service='tornado-notification')
47         @tornado.gen.coroutine
48         def notify(self):
49             # do something
50 
51 Tornado settings can be used to change some tracing configuration, like::
52 
53     settings = {
54         'datadog_trace': {
55             'default_service': 'my-tornado-app',
56             'tags': {'env': 'production'},
57             'distributed_tracing': True,
58         },
59     }
60 
61     app = tornado.web.Application([
62         (r'/', MainHandler),
63     ], **settings)
64 
65 The available settings are:
66 
67 * ``default_service`` (default: `tornado-web`): set the service name used by the tracer. Usually
68   this configuration must be updated with a meaningful name.
69 * ``tags`` (default: `{}`): set global tags that should be applied to all spans.
70 * ``enabled`` (default: `True`): define if the tracer is enabled or not. If set to `false`, the
71   code is still instrumented but no spans are sent to the APM agent.
72 * ``distributed_tracing`` (default: `False`): enable distributed tracing if this is called
73   remotely from an instrumented application.
74   We suggest to enable it only for internal services where headers are under your control.
75 * ``agent_hostname`` (default: `localhost`): define the hostname of the APM agent.
76 * ``agent_port`` (default: `8126`): define the port of the APM agent.
77 """
78 from ...utils.importlib import require_modules
79 
80 
81 required_modules = ['tornado']
82 
83 with require_modules(required_modules) as missing_modules:
84     if not missing_modules:
85         from .stack_context import run_with_trace_context, TracerStackContext
86 
87         context_provider = TracerStackContext()
88 
89         from .patch import patch, unpatch
90 
91         __all__ = [
92             'patch',
93             'unpatch',
94             'context_provider',
95             'run_with_trace_context',
96             'TracerStackContext',
97         ]
98
```

Path: `ddtrace/contrib/tornado/application.py`
Content:
```
1 import ddtrace
2 
3 from tornado import template
4 
5 from . import decorators, context_provider
6 from .constants import CONFIG_KEY
7 
8 from ...ext import AppTypes
9 
10 
11 def tracer_config(__init__, app, args, kwargs):
12     """
13     Wrap Tornado web application so that we can configure services info and
14     tracing settings after the initialization.
15     """
16     # call the Application constructor
17     __init__(*args, **kwargs)
18 
19     # default settings
20     settings = {
21         'tracer': ddtrace.tracer,
22         'default_service': 'tornado-web',
23         'distributed_tracing': False,
24     }
25 
26     # update defaults with users settings
27     user_settings = app.settings.get(CONFIG_KEY)
28     if user_settings:
29         settings.update(user_settings)
30 
31     app.settings[CONFIG_KEY] = settings
32     tracer = settings['tracer']
33     service = settings['default_service']
34 
35     # the tracer must use the right Context propagation and wrap executor;
36     # this action is done twice because the patch() method uses the
37     # global tracer while here we can have a different instance (even if
38     # this is not usual).
39     tracer.configure(
40         context_provider=context_provider,
41         wrap_executor=decorators.wrap_executor,
42         enabled=settings.get('enabled', None),
43         hostname=settings.get('agent_hostname', None),
44         port=settings.get('agent_port', None),
45     )
46 
47     # set global tags if any
48     tags = settings.get('tags', None)
49     if tags:
50         tracer.set_tags(tags)
51 
52     # configure the current service
53     tracer.set_service_info(
54         service=service,
55         app='tornado',
56         app_type=AppTypes.web,
57     )
58 
59     # configure the PIN object for template rendering
60     ddtrace.Pin(app='tornado', service=service, app_type='web', tracer=tracer).onto(template)
61
```
--- 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()

```

diff --git a/ddtrace/contrib/tornado/__init__.py b/ddtrace/contrib/tornado/__init__.py
--- a/ddtrace/contrib/tornado/__init__.py
+++ b/ddtrace/contrib/tornado/__init__.py
@@ -55,6 +55,11 @@
             'default_service': 'my-tornado-app',
             'tags': {'env': 'production'},
             'distributed_tracing': True,
+            'settings': {
+                'FILTERS':  [
+                    FilterRequestsOnUrl(r'http://test\.example\.com'),
+                ],
+            },
         },
     }
 
@@ -74,6 +79,7 @@
   We suggest to enable it only for internal services where headers are under your control.
 * ``agent_hostname`` (default: `localhost`): define the hostname of the APM agent.
 * ``agent_port`` (default: `8126`): define the port of the APM agent.
+* ``settings`` (default: ``{}``): Tracer extra settings used to change, for instance, the filtering behavior.
 """
 from ...utils.importlib import require_modules
 
diff --git a/ddtrace/contrib/tornado/application.py b/ddtrace/contrib/tornado/application.py
--- a/ddtrace/contrib/tornado/application.py
+++ b/ddtrace/contrib/tornado/application.py
@@ -32,6 +32,9 @@
     tracer = settings['tracer']
     service = settings['default_service']
 
+    # extract extra settings
+    extra_settings = settings.get('settings', {})
+
     # the tracer must use the right Context propagation and wrap executor;
     # this action is done twice because the patch() method uses the
     # global tracer while here we can have a different instance (even if
@@ -42,6 +45,7 @@
         enabled=settings.get('enabled', None),
         hostname=settings.get('agent_hostname', None),
         port=settings.get('agent_port', None),
+        settings=extra_settings,
     )
 
     # set global tags if any

{"golden_diff": "diff --git a/ddtrace/contrib/tornado/__init__.py b/ddtrace/contrib/tornado/__init__.py\n--- a/ddtrace/contrib/tornado/__init__.py\n+++ b/ddtrace/contrib/tornado/__init__.py\n@@ -55,6 +55,11 @@\n             'default_service': 'my-tornado-app',\n             'tags': {'env': 'production'},\n             'distributed_tracing': True,\n+            'settings': {\n+                'FILTERS':  [\n+                    FilterRequestsOnUrl(r'http://test\\.example\\.com'),\n+                ],\n+            },\n         },\n     }\n \n@@ -74,6 +79,7 @@\n   We suggest to enable it only for internal services where headers are under your control.\n * ``agent_hostname`` (default: `localhost`): define the hostname of the APM agent.\n * ``agent_port`` (default: `8126`): define the port of the APM agent.\n+* ``settings`` (default: ``{}``): Tracer extra settings used to change, for instance, the filtering behavior.\n \"\"\"\n from ...utils.importlib import require_modules\n \ndiff --git a/ddtrace/contrib/tornado/application.py b/ddtrace/contrib/tornado/application.py\n--- a/ddtrace/contrib/tornado/application.py\n+++ b/ddtrace/contrib/tornado/application.py\n@@ -32,6 +32,9 @@\n     tracer = settings['tracer']\n     service = settings['default_service']\n \n+    # extract extra settings\n+    extra_settings = settings.get('settings', {})\n+\n     # the tracer must use the right Context propagation and wrap executor;\n     # this action is done twice because the patch() method uses the\n     # global tracer while here we can have a different instance (even if\n@@ -42,6 +45,7 @@\n         enabled=settings.get('enabled', None),\n         hostname=settings.get('agent_hostname', None),\n         port=settings.get('agent_port', None),\n+        settings=extra_settings,\n     )\n \n     # set global tags if any\n", "issue": "Tornado Tracer configuration doesn't have access to settings object for Trace Filtering\n\n", "before_files": [{"content": "\"\"\"\nThe Tornado integration traces all ``RequestHandler`` defined in a Tornado web application.\nAuto instrumentation is available using the ``patch`` function that **must be called before**\nimporting the tornado library. The following is an example::\n\n    # patch before importing tornado and concurrent.futures\n    from ddtrace import tracer, patch\n    patch(tornado=True)\n\n    import tornado.web\n    import tornado.gen\n    import tornado.ioloop\n\n    # create your handlers\n    class MainHandler(tornado.web.RequestHandler):\n        @tornado.gen.coroutine\n        def get(self):\n            self.write(\"Hello, world\")\n\n    # create your application\n    app = tornado.web.Application([\n        (r'/', MainHandler),\n    ])\n\n    # and run it as usual\n    app.listen(8888)\n    tornado.ioloop.IOLoop.current().start()\n\nWhen any type of ``RequestHandler`` is hit, a request root span is automatically created. If\nyou want to trace more parts of your application, you can use the ``wrap()`` decorator and\nthe ``trace()`` method as usual::\n\n    class MainHandler(tornado.web.RequestHandler):\n        @tornado.gen.coroutine\n        def get(self):\n            yield self.notify()\n            yield self.blocking_method()\n            with tracer.trace('tornado.before_write') as span:\n                # trace more work in the handler\n\n        @tracer.wrap('tornado.executor_handler')\n        @tornado.concurrent.run_on_executor\n        def blocking_method(self):\n            # do something expensive\n\n        @tracer.wrap('tornado.notify', service='tornado-notification')\n        @tornado.gen.coroutine\n        def notify(self):\n            # do something\n\nTornado settings can be used to change some tracing configuration, like::\n\n    settings = {\n        'datadog_trace': {\n            'default_service': 'my-tornado-app',\n            'tags': {'env': 'production'},\n            'distributed_tracing': True,\n        },\n    }\n\n    app = tornado.web.Application([\n        (r'/', MainHandler),\n    ], **settings)\n\nThe available settings are:\n\n* ``default_service`` (default: `tornado-web`): set the service name used by the tracer. Usually\n  this configuration must be updated with a meaningful name.\n* ``tags`` (default: `{}`): set global tags that should be applied to all spans.\n* ``enabled`` (default: `True`): define if the tracer is enabled or not. If set to `false`, the\n  code is still instrumented but no spans are sent to the APM agent.\n* ``distributed_tracing`` (default: `False`): enable distributed tracing if this is called\n  remotely from an instrumented application.\n  We suggest to enable it only for internal services where headers are under your control.\n* ``agent_hostname`` (default: `localhost`): define the hostname of the APM agent.\n* ``agent_port`` (default: `8126`): define the port of the APM agent.\n\"\"\"\nfrom ...utils.importlib import require_modules\n\n\nrequired_modules = ['tornado']\n\nwith require_modules(required_modules) as missing_modules:\n    if not missing_modules:\n        from .stack_context import run_with_trace_context, TracerStackContext\n\n        context_provider = TracerStackContext()\n\n        from .patch import patch, unpatch\n\n        __all__ = [\n            'patch',\n            'unpatch',\n            'context_provider',\n            'run_with_trace_context',\n            'TracerStackContext',\n        ]\n", "path": "ddtrace/contrib/tornado/__init__.py"}, {"content": "import ddtrace\n\nfrom tornado import template\n\nfrom . import decorators, context_provider\nfrom .constants import CONFIG_KEY\n\nfrom ...ext import AppTypes\n\n\ndef tracer_config(__init__, app, args, kwargs):\n    \"\"\"\n    Wrap Tornado web application so that we can configure services info and\n    tracing settings after the initialization.\n    \"\"\"\n    # call the Application constructor\n    __init__(*args, **kwargs)\n\n    # default settings\n    settings = {\n        'tracer': ddtrace.tracer,\n        'default_service': 'tornado-web',\n        'distributed_tracing': False,\n    }\n\n    # update defaults with users settings\n    user_settings = app.settings.get(CONFIG_KEY)\n    if user_settings:\n        settings.update(user_settings)\n\n    app.settings[CONFIG_KEY] = settings\n    tracer = settings['tracer']\n    service = settings['default_service']\n\n    # the tracer must use the right Context propagation and wrap executor;\n    # this action is done twice because the patch() method uses the\n    # global tracer while here we can have a different instance (even if\n    # this is not usual).\n    tracer.configure(\n        context_provider=context_provider,\n        wrap_executor=decorators.wrap_executor,\n        enabled=settings.get('enabled', None),\n        hostname=settings.get('agent_hostname', None),\n        port=settings.get('agent_port', None),\n    )\n\n    # set global tags if any\n    tags = settings.get('tags', None)\n    if tags:\n        tracer.set_tags(tags)\n\n    # configure the current service\n    tracer.set_service_info(\n        service=service,\n        app='tornado',\n        app_type=AppTypes.web,\n    )\n\n    # configure the PIN object for template rendering\n    ddtrace.Pin(app='tornado', service=service, app_type='web', tracer=tracer).onto(template)\n", "path": "ddtrace/contrib/tornado/application.py"}], "after_files": [{"content": "\"\"\"\nThe Tornado integration traces all ``RequestHandler`` defined in a Tornado web application.\nAuto instrumentation is available using the ``patch`` function that **must be called before**\nimporting the tornado library. The following is an example::\n\n    # patch before importing tornado and concurrent.futures\n    from ddtrace import tracer, patch\n    patch(tornado=True)\n\n    import tornado.web\n    import tornado.gen\n    import tornado.ioloop\n\n    # create your handlers\n    class MainHandler(tornado.web.RequestHandler):\n        @tornado.gen.coroutine\n        def get(self):\n            self.write(\"Hello, world\")\n\n    # create your application\n    app = tornado.web.Application([\n        (r'/', MainHandler),\n    ])\n\n    # and run it as usual\n    app.listen(8888)\n    tornado.ioloop.IOLoop.current().start()\n\nWhen any type of ``RequestHandler`` is hit, a request root span is automatically created. If\nyou want to trace more parts of your application, you can use the ``wrap()`` decorator and\nthe ``trace()`` method as usual::\n\n    class MainHandler(tornado.web.RequestHandler):\n        @tornado.gen.coroutine\n        def get(self):\n            yield self.notify()\n            yield self.blocking_method()\n            with tracer.trace('tornado.before_write') as span:\n                # trace more work in the handler\n\n        @tracer.wrap('tornado.executor_handler')\n        @tornado.concurrent.run_on_executor\n        def blocking_method(self):\n            # do something expensive\n\n        @tracer.wrap('tornado.notify', service='tornado-notification')\n        @tornado.gen.coroutine\n        def notify(self):\n            # do something\n\nTornado settings can be used to change some tracing configuration, like::\n\n    settings = {\n        'datadog_trace': {\n            'default_service': 'my-tornado-app',\n            'tags': {'env': 'production'},\n            'distributed_tracing': True,\n            'settings': {\n                'FILTERS':  [\n                    FilterRequestsOnUrl(r'http://test\\.example\\.com'),\n                ],\n            },\n        },\n    }\n\n    app = tornado.web.Application([\n        (r'/', MainHandler),\n    ], **settings)\n\nThe available settings are:\n\n* ``default_service`` (default: `tornado-web`): set the service name used by the tracer. Usually\n  this configuration must be updated with a meaningful name.\n* ``tags`` (default: `{}`): set global tags that should be applied to all spans.\n* ``enabled`` (default: `True`): define if the tracer is enabled or not. If set to `false`, the\n  code is still instrumented but no spans are sent to the APM agent.\n* ``distributed_tracing`` (default: `False`): enable distributed tracing if this is called\n  remotely from an instrumented application.\n  We suggest to enable it only for internal services where headers are under your control.\n* ``agent_hostname`` (default: `localhost`): define the hostname of the APM agent.\n* ``agent_port`` (default: `8126`): define the port of the APM agent.\n* ``settings`` (default: ``{}``): Tracer extra settings used to change, for instance, the filtering behavior.\n\"\"\"\nfrom ...utils.importlib import require_modules\n\n\nrequired_modules = ['tornado']\n\nwith require_modules(required_modules) as missing_modules:\n    if not missing_modules:\n        from .stack_context import run_with_trace_context, TracerStackContext\n\n        context_provider = TracerStackContext()\n\n        from .patch import patch, unpatch\n\n        __all__ = [\n            'patch',\n            'unpatch',\n            'context_provider',\n            'run_with_trace_context',\n            'TracerStackContext',\n        ]\n", "path": "ddtrace/contrib/tornado/__init__.py"}, {"content": "import ddtrace\n\nfrom tornado import template\n\nfrom . import decorators, context_provider\nfrom .constants import CONFIG_KEY\n\nfrom ...ext import AppTypes\n\n\ndef tracer_config(__init__, app, args, kwargs):\n    \"\"\"\n    Wrap Tornado web application so that we can configure services info and\n    tracing settings after the initialization.\n    \"\"\"\n    # call the Application constructor\n    __init__(*args, **kwargs)\n\n    # default settings\n    settings = {\n        'tracer': ddtrace.tracer,\n        'default_service': 'tornado-web',\n        'distributed_tracing': False,\n    }\n\n    # update defaults with users settings\n    user_settings = app.settings.get(CONFIG_KEY)\n    if user_settings:\n        settings.update(user_settings)\n\n    app.settings[CONFIG_KEY] = settings\n    tracer = settings['tracer']\n    service = settings['default_service']\n\n    # extract extra settings\n    extra_settings = settings.get('settings', {})\n\n    # the tracer must use the right Context propagation and wrap executor;\n    # this action is done twice because the patch() method uses the\n    # global tracer while here we can have a different instance (even if\n    # this is not usual).\n    tracer.configure(\n        context_provider=context_provider,\n        wrap_executor=decorators.wrap_executor,\n        enabled=settings.get('enabled', None),\n        hostname=settings.get('agent_hostname', None),\n        port=settings.get('agent_port', None),\n        settings=extra_settings,\n    )\n\n    # set global tags if any\n    tags = settings.get('tags', None)\n    if tags:\n        tracer.set_tags(tags)\n\n    # configure the current service\n    tracer.set_service_info(\n        service=service,\n        app='tornado',\n        app_type=AppTypes.web,\n    )\n\n    # configure the PIN object for template rendering\n    ddtrace.Pin(app='tornado', service=service, app_type='web', tracer=tracer).onto(template)\n", "path": "ddtrace/contrib/tornado/application.py"}]}