prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  RuntimeError: Set changed size during iteration
  Python Version: 3.7.7
  
  Error:
  ```
  RuntimeError: Set changed size during iteration
    File "django/core/handlers/wsgi.py", line 141, in __call__
      response = self.get_response(request)
    File "ddtrace/contrib/django/patch.py", line 82, in wrapper
      return func(mod, pin, wrapped, instance, args, kwargs)
    File "ddtrace/contrib/django/patch.py", line 406, in traced_get_response
      span_type=SpanTypes.HTTP,
    File "ddtrace/tracer.py", line 638, in trace
      span_type=span_type,
    File "ddtrace/tracer.py", line 389, in start_span
      new_ctx = self._check_new_process()
    File "ddtrace/tracer.py", line 570, in _check_new_process
      self._update_dogstatsd_constant_tags()
    File "ddtrace/tracer.py", line 525, in _update_dogstatsd_constant_tags
      for k, v in RuntimeTags()
    File "ddtrace/tracer.py", line 524, in <listcomp>
      '{}:{}'.format(k, v)
    File "ddtrace/internal/runtime/runtime_metrics.py", line 29, in <genexpr>
      collected = (collector.collect(self._enabled) for collector in self._collectors)
    File "ddtrace/internal/runtime/collector.py", line 67, in collect
      self.value = self.collect_fn(keys)
    File "ddtrace/internal/runtime/tag_collectors.py", line 25, in collect_fn
      tags = [(SERVICE, service) for service in ddtrace.tracer._services]
    File "ddtrace/internal/runtime/tag_collectors.py", line 25, in <listcomp>
      tags = [(SERVICE, service) for service in ddtrace.tracer._services]
  ```
  
  ### Which version of dd-trace-py are you using?
  ```
  0.42.0
  ```
  
  ### Which version of the libraries are you using?
  ```
  django==2.2.14
  ddtrace==0.42.0
  gunicorn==20.0.4
  ```
  
  ### How can we reproduce your problem?
  It's not clear if there's anything specific about the WSGI requests that triggers this condition. 
  
  ### What is the result that you get?
  -
  
  ### What is the result that you expected?
  -
  
  --- 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/internal/runtime/tag_collectors.py`
  Content:
  ```
  1 from .collector import ValueCollector
  2 from .constants import (
  3     SERVICE,
  4     LANG_INTERPRETER,
  5     LANG_VERSION,
  6     LANG,
  7     TRACER_VERSION,
  8 )
  9 from ...constants import ENV_KEY
  10 
  11 
  12 class RuntimeTagCollector(ValueCollector):
  13     periodic = False
  14     value = []
  15 
  16 
  17 class TracerTagCollector(RuntimeTagCollector):
  18     """Tag collector for the ddtrace Tracer"""
  19 
  20     required_modules = ["ddtrace"]
  21 
  22     def collect_fn(self, keys):
  23         ddtrace = self.modules.get("ddtrace")
  24         tags = [(SERVICE, service) for service in ddtrace.tracer._services]
  25         if ENV_KEY in ddtrace.tracer.tags:
  26             tags.append((ENV_KEY, ddtrace.tracer.tags[ENV_KEY]))
  27         return tags
  28 
  29 
  30 class PlatformTagCollector(RuntimeTagCollector):
  31     """Tag collector for the Python interpreter implementation.
  32 
  33     Tags collected:
  34     - ``lang_interpreter``:
  35 
  36       * For CPython this is 'CPython'.
  37       * For Pypy this is ``PyPy``
  38       * For Jython this is ``Jython``
  39 
  40     - `lang_version``,  eg ``2.7.10``
  41     - ``lang`` e.g. ``Python``
  42     - ``tracer_version`` e.g. ``0.29.0``
  43 
  44     """
  45 
  46     required_modules = ("platform", "ddtrace")
  47 
  48     def collect_fn(self, keys):
  49         platform = self.modules.get("platform")
  50         ddtrace = self.modules.get("ddtrace")
  51         tags = [
  52             (LANG, "python"),
  53             (LANG_INTERPRETER, platform.python_implementation()),
  54             (LANG_VERSION, platform.python_version()),
  55             (TRACER_VERSION, ddtrace.__version__),
  56         ]
  57         return tags
  58
  ```
  --- 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/ddtrace/internal/runtime/tag_collectors.py b/ddtrace/internal/runtime/tag_collectors.py
  --- a/ddtrace/internal/runtime/tag_collectors.py
  +++ b/ddtrace/internal/runtime/tag_collectors.py
  @@ -21,7 +21,8 @@
   
       def collect_fn(self, keys):
           ddtrace = self.modules.get("ddtrace")
  -        tags = [(SERVICE, service) for service in ddtrace.tracer._services]
  +        # make sure to copy _services to avoid RuntimeError: Set changed size during iteration
  +        tags = [(SERVICE, service) for service in list(ddtrace.tracer._services)]
           if ENV_KEY in ddtrace.tracer.tags:
               tags.append((ENV_KEY, ddtrace.tracer.tags[ENV_KEY]))
           return tags
  
verification_info: {"golden_diff": "diff --git a/ddtrace/internal/runtime/tag_collectors.py b/ddtrace/internal/runtime/tag_collectors.py\n--- a/ddtrace/internal/runtime/tag_collectors.py\n+++ b/ddtrace/internal/runtime/tag_collectors.py\n@@ -21,7 +21,8 @@\n \n     def collect_fn(self, keys):\n         ddtrace = self.modules.get(\"ddtrace\")\n-        tags = [(SERVICE, service) for service in ddtrace.tracer._services]\n+        # make sure to copy _services to avoid RuntimeError: Set changed size during iteration\n+        tags = [(SERVICE, service) for service in list(ddtrace.tracer._services)]\n         if ENV_KEY in ddtrace.tracer.tags:\n             tags.append((ENV_KEY, ddtrace.tracer.tags[ENV_KEY]))\n         return tags\n", "issue": "RuntimeError: Set changed size during iteration\nPython Version: 3.7.7\r\n\r\nError:\r\n```\r\nRuntimeError: Set changed size during iteration\r\n  File \"django/core/handlers/wsgi.py\", line 141, in __call__\r\n    response = self.get_response(request)\r\n  File \"ddtrace/contrib/django/patch.py\", line 82, in wrapper\r\n    return func(mod, pin, wrapped, instance, args, kwargs)\r\n  File \"ddtrace/contrib/django/patch.py\", line 406, in traced_get_response\r\n    span_type=SpanTypes.HTTP,\r\n  File \"ddtrace/tracer.py\", line 638, in trace\r\n    span_type=span_type,\r\n  File \"ddtrace/tracer.py\", line 389, in start_span\r\n    new_ctx = self._check_new_process()\r\n  File \"ddtrace/tracer.py\", line 570, in _check_new_process\r\n    self._update_dogstatsd_constant_tags()\r\n  File \"ddtrace/tracer.py\", line 525, in _update_dogstatsd_constant_tags\r\n    for k, v in RuntimeTags()\r\n  File \"ddtrace/tracer.py\", line 524, in <listcomp>\r\n    '{}:{}'.format(k, v)\r\n  File \"ddtrace/internal/runtime/runtime_metrics.py\", line 29, in <genexpr>\r\n    collected = (collector.collect(self._enabled) for collector in self._collectors)\r\n  File \"ddtrace/internal/runtime/collector.py\", line 67, in collect\r\n    self.value = self.collect_fn(keys)\r\n  File \"ddtrace/internal/runtime/tag_collectors.py\", line 25, in collect_fn\r\n    tags = [(SERVICE, service) for service in ddtrace.tracer._services]\r\n  File \"ddtrace/internal/runtime/tag_collectors.py\", line 25, in <listcomp>\r\n    tags = [(SERVICE, service) for service in ddtrace.tracer._services]\r\n```\r\n\r\n### Which version of dd-trace-py are you using?\r\n```\r\n0.42.0\r\n```\r\n\r\n### Which version of the libraries are you using?\r\n```\r\ndjango==2.2.14\r\nddtrace==0.42.0\r\ngunicorn==20.0.4\r\n```\r\n\r\n### How can we reproduce your problem?\r\nIt's not clear if there's anything specific about the WSGI requests that triggers this condition. \r\n\r\n### What is the result that you get?\r\n-\r\n\r\n### What is the result that you expected?\r\n-\n", "before_files": [{"content": "from .collector import ValueCollector\nfrom .constants import (\n    SERVICE,\n    LANG_INTERPRETER,\n    LANG_VERSION,\n    LANG,\n    TRACER_VERSION,\n)\nfrom ...constants import ENV_KEY\n\n\nclass RuntimeTagCollector(ValueCollector):\n    periodic = False\n    value = []\n\n\nclass TracerTagCollector(RuntimeTagCollector):\n    \"\"\"Tag collector for the ddtrace Tracer\"\"\"\n\n    required_modules = [\"ddtrace\"]\n\n    def collect_fn(self, keys):\n        ddtrace = self.modules.get(\"ddtrace\")\n        tags = [(SERVICE, service) for service in ddtrace.tracer._services]\n        if ENV_KEY in ddtrace.tracer.tags:\n            tags.append((ENV_KEY, ddtrace.tracer.tags[ENV_KEY]))\n        return tags\n\n\nclass PlatformTagCollector(RuntimeTagCollector):\n    \"\"\"Tag collector for the Python interpreter implementation.\n\n    Tags collected:\n    - ``lang_interpreter``:\n\n      * For CPython this is 'CPython'.\n      * For Pypy this is ``PyPy``\n      * For Jython this is ``Jython``\n\n    - `lang_version``,  eg ``2.7.10``\n    - ``lang`` e.g. ``Python``\n    - ``tracer_version`` e.g. ``0.29.0``\n\n    \"\"\"\n\n    required_modules = (\"platform\", \"ddtrace\")\n\n    def collect_fn(self, keys):\n        platform = self.modules.get(\"platform\")\n        ddtrace = self.modules.get(\"ddtrace\")\n        tags = [\n            (LANG, \"python\"),\n            (LANG_INTERPRETER, platform.python_implementation()),\n            (LANG_VERSION, platform.python_version()),\n            (TRACER_VERSION, ddtrace.__version__),\n        ]\n        return tags\n", "path": "ddtrace/internal/runtime/tag_collectors.py"}], "after_files": [{"content": "from .collector import ValueCollector\nfrom .constants import (\n    SERVICE,\n    LANG_INTERPRETER,\n    LANG_VERSION,\n    LANG,\n    TRACER_VERSION,\n)\nfrom ...constants import ENV_KEY\n\n\nclass RuntimeTagCollector(ValueCollector):\n    periodic = False\n    value = []\n\n\nclass TracerTagCollector(RuntimeTagCollector):\n    \"\"\"Tag collector for the ddtrace Tracer\"\"\"\n\n    required_modules = [\"ddtrace\"]\n\n    def collect_fn(self, keys):\n        ddtrace = self.modules.get(\"ddtrace\")\n        # make sure to copy _services to avoid RuntimeError: Set changed size during iteration\n        tags = [(SERVICE, service) for service in list(ddtrace.tracer._services)]\n        if ENV_KEY in ddtrace.tracer.tags:\n            tags.append((ENV_KEY, ddtrace.tracer.tags[ENV_KEY]))\n        return tags\n\n\nclass PlatformTagCollector(RuntimeTagCollector):\n    \"\"\"Tag collector for the Python interpreter implementation.\n\n    Tags collected:\n    - ``lang_interpreter``:\n\n      * For CPython this is 'CPython'.\n      * For Pypy this is ``PyPy``\n      * For Jython this is ``Jython``\n\n    - `lang_version``,  eg ``2.7.10``\n    - ``lang`` e.g. ``Python``\n    - ``tracer_version`` e.g. ``0.29.0``\n\n    \"\"\"\n\n    required_modules = (\"platform\", \"ddtrace\")\n\n    def collect_fn(self, keys):\n        platform = self.modules.get(\"platform\")\n        ddtrace = self.modules.get(\"ddtrace\")\n        tags = [\n            (LANG, \"python\"),\n            (LANG_INTERPRETER, platform.python_implementation()),\n            (LANG_VERSION, platform.python_version()),\n            (TRACER_VERSION, ddtrace.__version__),\n        ]\n        return tags\n", "path": "ddtrace/internal/runtime/tag_collectors.py"}]}