prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add suppress_instrumentation flag in context for Metrics
  Similar to [logic](https://github.com/open-telemetry/opentelemetry-python/blob/master/opentelemetry-sdk/src/opentelemetry/sdk/trace/export/__init__.py#L205) in SpanProcessors, this need to be done in Metrics to avoid duplicated telemetry when using Http ext or other packages relying on this
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py`
  Content:
  ```
  1 # Copyright The OpenTelemetry Authors
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import atexit
  16 import threading
  17 
  18 
  19 class PushController(threading.Thread):
  20     """A push based controller, used for exporting.
  21 
  22     Uses a worker thread that periodically collects metrics for exporting,
  23     exports them and performs some post-processing.
  24     """
  25 
  26     daemon = True
  27 
  28     def __init__(self, meter, exporter, interval, shutdown_on_exit=True):
  29         super().__init__()
  30         self.meter = meter
  31         self.exporter = exporter
  32         self.interval = interval
  33         self.finished = threading.Event()
  34         self._atexit_handler = None
  35         if shutdown_on_exit:
  36             self._atexit_handler = atexit.register(self.shutdown)
  37         self.start()
  38 
  39     def run(self):
  40         while not self.finished.wait(self.interval):
  41             self.tick()
  42 
  43     def shutdown(self):
  44         self.finished.set()
  45         self.exporter.shutdown()
  46         if self._atexit_handler is not None:
  47             atexit.unregister(self._atexit_handler)
  48             self._atexit_handler = None
  49 
  50     def tick(self):
  51         # Collect all of the meter's metrics to be exported
  52         self.meter.collect()
  53         # Export the given metrics in the batcher
  54         self.exporter.export(self.meter.batcher.checkpoint_set())
  55         # Perform post-exporting logic based on batcher configuration
  56         self.meter.batcher.finished_collection()
  57
  ```
  --- 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/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py
  --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py
  +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py
  @@ -15,6 +15,8 @@
   import atexit
   import threading
   
  +from opentelemetry.context import attach, detach, set_value
  +
   
   class PushController(threading.Thread):
       """A push based controller, used for exporting.
  @@ -50,7 +52,9 @@
       def tick(self):
           # Collect all of the meter's metrics to be exported
           self.meter.collect()
  +        token = attach(set_value("suppress_instrumentation", True))
           # Export the given metrics in the batcher
           self.exporter.export(self.meter.batcher.checkpoint_set())
  +        detach(token)
           # Perform post-exporting logic based on batcher configuration
           self.meter.batcher.finished_collection()
  
verification_info: {"golden_diff": "diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py\n--- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py\n+++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py\n@@ -15,6 +15,8 @@\n import atexit\n import threading\n \n+from opentelemetry.context import attach, detach, set_value\n+\n \n class PushController(threading.Thread):\n     \"\"\"A push based controller, used for exporting.\n@@ -50,7 +52,9 @@\n     def tick(self):\n         # Collect all of the meter's metrics to be exported\n         self.meter.collect()\n+        token = attach(set_value(\"suppress_instrumentation\", True))\n         # Export the given metrics in the batcher\n         self.exporter.export(self.meter.batcher.checkpoint_set())\n+        detach(token)\n         # Perform post-exporting logic based on batcher configuration\n         self.meter.batcher.finished_collection()\n", "issue": "Add suppress_instrumentation flag in context for Metrics\nSimilar to [logic](https://github.com/open-telemetry/opentelemetry-python/blob/master/opentelemetry-sdk/src/opentelemetry/sdk/trace/export/__init__.py#L205) in SpanProcessors, this need to be done in Metrics to avoid duplicated telemetry when using Http ext or other packages relying on this\n", "before_files": [{"content": "# Copyright The OpenTelemetry Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport atexit\nimport threading\n\n\nclass PushController(threading.Thread):\n    \"\"\"A push based controller, used for exporting.\n\n    Uses a worker thread that periodically collects metrics for exporting,\n    exports them and performs some post-processing.\n    \"\"\"\n\n    daemon = True\n\n    def __init__(self, meter, exporter, interval, shutdown_on_exit=True):\n        super().__init__()\n        self.meter = meter\n        self.exporter = exporter\n        self.interval = interval\n        self.finished = threading.Event()\n        self._atexit_handler = None\n        if shutdown_on_exit:\n            self._atexit_handler = atexit.register(self.shutdown)\n        self.start()\n\n    def run(self):\n        while not self.finished.wait(self.interval):\n            self.tick()\n\n    def shutdown(self):\n        self.finished.set()\n        self.exporter.shutdown()\n        if self._atexit_handler is not None:\n            atexit.unregister(self._atexit_handler)\n            self._atexit_handler = None\n\n    def tick(self):\n        # Collect all of the meter's metrics to be exported\n        self.meter.collect()\n        # Export the given metrics in the batcher\n        self.exporter.export(self.meter.batcher.checkpoint_set())\n        # Perform post-exporting logic based on batcher configuration\n        self.meter.batcher.finished_collection()\n", "path": "opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py"}], "after_files": [{"content": "# Copyright The OpenTelemetry Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport atexit\nimport threading\n\nfrom opentelemetry.context import attach, detach, set_value\n\n\nclass PushController(threading.Thread):\n    \"\"\"A push based controller, used for exporting.\n\n    Uses a worker thread that periodically collects metrics for exporting,\n    exports them and performs some post-processing.\n    \"\"\"\n\n    daemon = True\n\n    def __init__(self, meter, exporter, interval, shutdown_on_exit=True):\n        super().__init__()\n        self.meter = meter\n        self.exporter = exporter\n        self.interval = interval\n        self.finished = threading.Event()\n        self._atexit_handler = None\n        if shutdown_on_exit:\n            self._atexit_handler = atexit.register(self.shutdown)\n        self.start()\n\n    def run(self):\n        while not self.finished.wait(self.interval):\n            self.tick()\n\n    def shutdown(self):\n        self.finished.set()\n        self.exporter.shutdown()\n        if self._atexit_handler is not None:\n            atexit.unregister(self._atexit_handler)\n            self._atexit_handler = None\n\n    def tick(self):\n        # Collect all of the meter's metrics to be exported\n        self.meter.collect()\n        token = attach(set_value(\"suppress_instrumentation\", True))\n        # Export the given metrics in the batcher\n        self.exporter.export(self.meter.batcher.checkpoint_set())\n        detach(token)\n        # Perform post-exporting logic based on batcher configuration\n        self.meter.batcher.finished_collection()\n", "path": "opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/controller.py"}]}