We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
System metrics instrumentation not working with custom defined configuration
System metric instrumentation is not functional if configuration on which metrics to be exported is explicitly provided. As a minimal example, this code

```python
from opentelemetry.metrics import set_meter_provider
from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import (
    ConsoleMetricExporter,
    PeriodicExportingMetricReader,
)

exporter = ConsoleMetricExporter()
set_meter_provider(MeterProvider([PeriodicExportingMetricReader(exporter)]))

configuration = {
    "runtime.memory": ["rss", "vms"],
    "runtime.cpu.time": ["user", "system"],
}

SystemMetricsInstrumentor(config=configuration).instrument()
```

results in

```
Traceback (most recent call last):
  File ".../test.py", line 15, in <module>
    SystemMetricsInstrumentor(config=configuration).instrument()
  File ".../lib/python3.10/site-packages/opentelemetry/instrumentation/instrumentor.py", line 51, in __new__
    cls._instance = object.__new__(cls, *args, **kwargs)
TypeError: object.__new__() takes exactly one argument (the type to instantiate)
```

I am happy to look into fixing this. Removing `*args` and `**kwargs` in `opentelemetry/instrumentation/instrumentor.py:51` actually solves the issue here but I'd like to understand the implications as this implies changing the interface class.

--- 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-instrumentation/src/opentelemetry/instrumentation/instrumentor.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 # type: ignore
15 
16 """
17 OpenTelemetry Base Instrumentor
18 """
19 
20 from abc import ABC, abstractmethod
21 from logging import getLogger
22 from typing import Collection, Optional
23 
24 from opentelemetry.instrumentation.dependencies import (
25     DependencyConflict,
26     get_dependency_conflicts,
27 )
28 
29 _LOG = getLogger(__name__)
30 
31 
32 class BaseInstrumentor(ABC):
33     """An ABC for instrumentors
34 
35     Child classes of this ABC should instrument specific third
36     party libraries or frameworks either by using the
37     ``opentelemetry-instrument`` command or by calling their methods
38     directly.
39 
40     Since every third party library or framework is different and has different
41     instrumentation needs, more methods can be added to the child classes as
42     needed to provide practical instrumentation to the end user.
43     """
44 
45     _instance = None
46     _is_instrumented_by_opentelemetry = False
47 
48     def __new__(cls, *args, **kwargs):
49         if cls._instance is None:
50             cls._instance = object.__new__(cls, *args, **kwargs)
51 
52         return cls._instance
53 
54     @property
55     def is_instrumented_by_opentelemetry(self):
56         return self._is_instrumented_by_opentelemetry
57 
58     @abstractmethod
59     def instrumentation_dependencies(self) -> Collection[str]:
60         """Return a list of python packages with versions that the will be instrumented.
61 
62         The format should be the same as used in requirements.txt or pyproject.toml.
63 
64         For example, if an instrumentation instruments requests 1.x, this method should look
65         like:
66 
67             def instrumentation_dependencies(self) -> Collection[str]:
68                 return ['requests ~= 1.0']
69 
70         This will ensure that the instrumentation will only be used when the specified library
71         is present in the environment.
72         """
73 
74     def _instrument(self, **kwargs):
75         """Instrument the library"""
76 
77     @abstractmethod
78     def _uninstrument(self, **kwargs):
79         """Uninstrument the library"""
80 
81     def _check_dependency_conflicts(self) -> Optional[DependencyConflict]:
82         dependencies = self.instrumentation_dependencies()
83         return get_dependency_conflicts(dependencies)
84 
85     def instrument(self, **kwargs):
86         """Instrument the library
87 
88         This method will be called without any optional arguments by the
89         ``opentelemetry-instrument`` command.
90 
91         This means that calling this method directly without passing any
92         optional values should do the very same thing that the
93         ``opentelemetry-instrument`` command does.
94         """
95 
96         if self._is_instrumented_by_opentelemetry:
97             _LOG.warning("Attempting to instrument while already instrumented")
98             return None
99 
100         # check if instrumentor has any missing or conflicting dependencies
101         skip_dep_check = kwargs.pop("skip_dep_check", False)
102         if not skip_dep_check:
103             conflict = self._check_dependency_conflicts()
104             if conflict:
105                 _LOG.error(conflict)
106                 return None
107 
108         result = self._instrument(  # pylint: disable=assignment-from-no-return
109             **kwargs
110         )
111         self._is_instrumented_by_opentelemetry = True
112         return result
113 
114     def uninstrument(self, **kwargs):
115         """Uninstrument the library
116 
117         See ``BaseInstrumentor.instrument`` for more information regarding the
118         usage of ``kwargs``.
119         """
120 
121         if self._is_instrumented_by_opentelemetry:
122             result = self._uninstrument(**kwargs)
123             self._is_instrumented_by_opentelemetry = False
124             return result
125 
126         _LOG.warning("Attempting to uninstrument while already uninstrumented")
127 
128         return None
129 
130 
131 __all__ = ["BaseInstrumentor"]
132
```
--- 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/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py
--- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py
+++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py
@@ -47,7 +47,7 @@
 
     def __new__(cls, *args, **kwargs):
         if cls._instance is None:
-            cls._instance = object.__new__(cls, *args, **kwargs)
+            cls._instance = object.__new__(cls)
 
         return cls._instance

{"golden_diff": "diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py\n--- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py\n+++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py\n@@ -47,7 +47,7 @@\n \n     def __new__(cls, *args, **kwargs):\n         if cls._instance is None:\n-            cls._instance = object.__new__(cls, *args, **kwargs)\n+            cls._instance = object.__new__(cls)\n \n         return cls._instance\n", "issue": "System metrics instrumentation not working with custom defined configuration\nSystem metric instrumentation is not functional if configuration on which metrics to be exported is explicitly provided. As a minimal example, this code\r\n\r\n```python\r\nfrom opentelemetry.metrics import set_meter_provider\r\nfrom opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor\r\nfrom opentelemetry.sdk.metrics import MeterProvider\r\nfrom opentelemetry.sdk.metrics.export import (\r\n    ConsoleMetricExporter,\r\n    PeriodicExportingMetricReader,\r\n)\r\n\r\nexporter = ConsoleMetricExporter()\r\nset_meter_provider(MeterProvider([PeriodicExportingMetricReader(exporter)]))\r\n\r\nconfiguration = {\r\n    \"runtime.memory\": [\"rss\", \"vms\"],\r\n    \"runtime.cpu.time\": [\"user\", \"system\"],\r\n}\r\n\r\nSystemMetricsInstrumentor(config=configuration).instrument()\r\n```\r\n\r\nresults in\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \".../test.py\", line 15, in <module>\r\n    SystemMetricsInstrumentor(config=configuration).instrument()\r\n  File \".../lib/python3.10/site-packages/opentelemetry/instrumentation/instrumentor.py\", line 51, in __new__\r\n    cls._instance = object.__new__(cls, *args, **kwargs)\r\nTypeError: object.__new__() takes exactly one argument (the type to instantiate)\r\n```\r\n\r\nI am happy to look into fixing this. Removing `*args` and `**kwargs` in `opentelemetry/instrumentation/instrumentor.py:51` actually solves the issue here but I'd like to understand the implications as this implies changing the interface class.\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# type: ignore\n\n\"\"\"\nOpenTelemetry Base Instrumentor\n\"\"\"\n\nfrom abc import ABC, abstractmethod\nfrom logging import getLogger\nfrom typing import Collection, Optional\n\nfrom opentelemetry.instrumentation.dependencies import (\n    DependencyConflict,\n    get_dependency_conflicts,\n)\n\n_LOG = getLogger(__name__)\n\n\nclass BaseInstrumentor(ABC):\n    \"\"\"An ABC for instrumentors\n\n    Child classes of this ABC should instrument specific third\n    party libraries or frameworks either by using the\n    ``opentelemetry-instrument`` command or by calling their methods\n    directly.\n\n    Since every third party library or framework is different and has different\n    instrumentation needs, more methods can be added to the child classes as\n    needed to provide practical instrumentation to the end user.\n    \"\"\"\n\n    _instance = None\n    _is_instrumented_by_opentelemetry = False\n\n    def __new__(cls, *args, **kwargs):\n        if cls._instance is None:\n            cls._instance = object.__new__(cls, *args, **kwargs)\n\n        return cls._instance\n\n    @property\n    def is_instrumented_by_opentelemetry(self):\n        return self._is_instrumented_by_opentelemetry\n\n    @abstractmethod\n    def instrumentation_dependencies(self) -> Collection[str]:\n        \"\"\"Return a list of python packages with versions that the will be instrumented.\n\n        The format should be the same as used in requirements.txt or pyproject.toml.\n\n        For example, if an instrumentation instruments requests 1.x, this method should look\n        like:\n\n            def instrumentation_dependencies(self) -> Collection[str]:\n                return ['requests ~= 1.0']\n\n        This will ensure that the instrumentation will only be used when the specified library\n        is present in the environment.\n        \"\"\"\n\n    def _instrument(self, **kwargs):\n        \"\"\"Instrument the library\"\"\"\n\n    @abstractmethod\n    def _uninstrument(self, **kwargs):\n        \"\"\"Uninstrument the library\"\"\"\n\n    def _check_dependency_conflicts(self) -> Optional[DependencyConflict]:\n        dependencies = self.instrumentation_dependencies()\n        return get_dependency_conflicts(dependencies)\n\n    def instrument(self, **kwargs):\n        \"\"\"Instrument the library\n\n        This method will be called without any optional arguments by the\n        ``opentelemetry-instrument`` command.\n\n        This means that calling this method directly without passing any\n        optional values should do the very same thing that the\n        ``opentelemetry-instrument`` command does.\n        \"\"\"\n\n        if self._is_instrumented_by_opentelemetry:\n            _LOG.warning(\"Attempting to instrument while already instrumented\")\n            return None\n\n        # check if instrumentor has any missing or conflicting dependencies\n        skip_dep_check = kwargs.pop(\"skip_dep_check\", False)\n        if not skip_dep_check:\n            conflict = self._check_dependency_conflicts()\n            if conflict:\n                _LOG.error(conflict)\n                return None\n\n        result = self._instrument(  # pylint: disable=assignment-from-no-return\n            **kwargs\n        )\n        self._is_instrumented_by_opentelemetry = True\n        return result\n\n    def uninstrument(self, **kwargs):\n        \"\"\"Uninstrument the library\n\n        See ``BaseInstrumentor.instrument`` for more information regarding the\n        usage of ``kwargs``.\n        \"\"\"\n\n        if self._is_instrumented_by_opentelemetry:\n            result = self._uninstrument(**kwargs)\n            self._is_instrumented_by_opentelemetry = False\n            return result\n\n        _LOG.warning(\"Attempting to uninstrument while already uninstrumented\")\n\n        return None\n\n\n__all__ = [\"BaseInstrumentor\"]\n", "path": "opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.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# type: ignore\n\n\"\"\"\nOpenTelemetry Base Instrumentor\n\"\"\"\n\nfrom abc import ABC, abstractmethod\nfrom logging import getLogger\nfrom typing import Collection, Optional\n\nfrom opentelemetry.instrumentation.dependencies import (\n    DependencyConflict,\n    get_dependency_conflicts,\n)\n\n_LOG = getLogger(__name__)\n\n\nclass BaseInstrumentor(ABC):\n    \"\"\"An ABC for instrumentors\n\n    Child classes of this ABC should instrument specific third\n    party libraries or frameworks either by using the\n    ``opentelemetry-instrument`` command or by calling their methods\n    directly.\n\n    Since every third party library or framework is different and has different\n    instrumentation needs, more methods can be added to the child classes as\n    needed to provide practical instrumentation to the end user.\n    \"\"\"\n\n    _instance = None\n    _is_instrumented_by_opentelemetry = False\n\n    def __new__(cls, *args, **kwargs):\n        if cls._instance is None:\n            cls._instance = object.__new__(cls)\n\n        return cls._instance\n\n    @property\n    def is_instrumented_by_opentelemetry(self):\n        return self._is_instrumented_by_opentelemetry\n\n    @abstractmethod\n    def instrumentation_dependencies(self) -> Collection[str]:\n        \"\"\"Return a list of python packages with versions that the will be instrumented.\n\n        The format should be the same as used in requirements.txt or pyproject.toml.\n\n        For example, if an instrumentation instruments requests 1.x, this method should look\n        like:\n\n            def instrumentation_dependencies(self) -> Collection[str]:\n                return ['requests ~= 1.0']\n\n        This will ensure that the instrumentation will only be used when the specified library\n        is present in the environment.\n        \"\"\"\n\n    def _instrument(self, **kwargs):\n        \"\"\"Instrument the library\"\"\"\n\n    @abstractmethod\n    def _uninstrument(self, **kwargs):\n        \"\"\"Uninstrument the library\"\"\"\n\n    def _check_dependency_conflicts(self) -> Optional[DependencyConflict]:\n        dependencies = self.instrumentation_dependencies()\n        return get_dependency_conflicts(dependencies)\n\n    def instrument(self, **kwargs):\n        \"\"\"Instrument the library\n\n        This method will be called without any optional arguments by the\n        ``opentelemetry-instrument`` command.\n\n        This means that calling this method directly without passing any\n        optional values should do the very same thing that the\n        ``opentelemetry-instrument`` command does.\n        \"\"\"\n\n        if self._is_instrumented_by_opentelemetry:\n            _LOG.warning(\"Attempting to instrument while already instrumented\")\n            return None\n\n        # check if instrumentor has any missing or conflicting dependencies\n        skip_dep_check = kwargs.pop(\"skip_dep_check\", False)\n        if not skip_dep_check:\n            conflict = self._check_dependency_conflicts()\n            if conflict:\n                _LOG.error(conflict)\n                return None\n\n        result = self._instrument(  # pylint: disable=assignment-from-no-return\n            **kwargs\n        )\n        self._is_instrumented_by_opentelemetry = True\n        return result\n\n    def uninstrument(self, **kwargs):\n        \"\"\"Uninstrument the library\n\n        See ``BaseInstrumentor.instrument`` for more information regarding the\n        usage of ``kwargs``.\n        \"\"\"\n\n        if self._is_instrumented_by_opentelemetry:\n            result = self._uninstrument(**kwargs)\n            self._is_instrumented_by_opentelemetry = False\n            return result\n\n        _LOG.warning(\"Attempting to uninstrument while already uninstrumented\")\n\n        return None\n\n\n__all__ = [\"BaseInstrumentor\"]\n", "path": "opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py"}]}