We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
TypeError with pymongo `getMore` operations
**Describe your environment** 
Describe your environment
Mac OS Catalina 10.15.6 (19G73)
Darwin-19.6.0-x86_64-i386-64bit
Python 3.7.7
Installed packages:
```
opentelemetry-api                      0.12b0    OpenTelemetry Python API
opentelemetry-ext-honeycomb            0.5b0     Honeycomb Exporter for OpenTelemetry
opentelemetry-instrumentation          0.12b0    Instrumentation Tools & Auto Instrumentation for OpenTelemetry Python
opentelemetry-instrumentation-botocore 0.12b0    OpenTelemetry Botocore instrumentation
opentelemetry-instrumentation-pymongo  0.12b0    OpenTelemetry pymongo instrumentation
opentelemetry-instrumentation-requests 0.12b0    OpenTelemetry requests instrumentation
pymongo                                3.11.0    Python driver for MongoDB <http://www.mongodb.org>
```

**Steps to reproduce**
any find operation where the number of documents to be returned exceeds the batch size on the cursor:
```pyhton
from pymongo import MongoClient
from opentelemetry import trace
from opentelemetry.trace import TracerProvider
from opentelemetry.instrumentation.pymongo import PymongoInstrumentor

trace.set_tracer_provider(TracerProvider())

PymongoInstrumentor().instrument()
client = MongoClient()
db = client["MongoDB_Database"]
collection = db["MongoDB_Collection"]
collection.find({'batch_size': 1})
```
**What is the expected behavior?**
Spans with names like `mongodb.getMore.1`

**What is the actual behavior?**
```
Traceback (most recent call last):
  File "/Users/drubin/cargurus/analytics/snowblower/.venv/lib/python3.7/site-packages/pymongo/monitoring.py", line 1266, in publish_command_start
    subscriber.started(event)
  File "/Users/drubin/cargurus/analytics/snowblower/.venv/lib/python3.7/site-packages/opentelemetry/instrumentation/pymongo/__init__.py", line 69, in started
    name += "." + command
TypeError: can only concatenate str (not "int") to str
```




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.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 """
16 The integration with MongoDB supports the `pymongo`_ library, it can be
17 enabled using the ``PymongoInstrumentor``.
18 
19 .. _pymongo: https://pypi.org/project/pymongo
20 
21 Usage
22 -----
23 
24 .. code:: python
25 
26     from pymongo import MongoClient
27     from opentelemetry import trace
28     from opentelemetry.trace import TracerProvider
29     from opentelemetry.instrumentation.pymongo import PymongoInstrumentor
30 
31     trace.set_tracer_provider(TracerProvider())
32 
33     PymongoInstrumentor().instrument()
34     client = MongoClient()
35     db = client["MongoDB_Database"]
36     collection = db["MongoDB_Collection"]
37     collection.find_one()
38 
39 API
40 ---
41 """
42 
43 from pymongo import monitoring
44 
45 from opentelemetry import trace
46 from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
47 from opentelemetry.instrumentation.pymongo.version import __version__
48 from opentelemetry.trace import SpanKind, get_tracer
49 from opentelemetry.trace.status import Status, StatusCanonicalCode
50 
51 DATABASE_TYPE = "mongodb"
52 COMMAND_ATTRIBUTES = ["filter", "sort", "skip", "limit", "pipeline"]
53 
54 
55 class CommandTracer(monitoring.CommandListener):
56     def __init__(self, tracer):
57         self._tracer = tracer
58         self._span_dict = {}
59         self.is_enabled = True
60 
61     def started(self, event: monitoring.CommandStartedEvent):
62         """ Method to handle a pymongo CommandStartedEvent """
63         if not self.is_enabled:
64             return
65         command = event.command.get(event.command_name, "")
66         name = DATABASE_TYPE + "." + event.command_name
67         statement = event.command_name
68         if command:
69             name += "." + command
70             statement += " " + command
71 
72         try:
73             span = self._tracer.start_span(name, kind=SpanKind.CLIENT)
74             span.set_attribute("component", DATABASE_TYPE)
75             span.set_attribute("db.type", DATABASE_TYPE)
76             span.set_attribute("db.instance", event.database_name)
77             span.set_attribute("db.statement", statement)
78             if event.connection_id is not None:
79                 span.set_attribute("net.peer.name", event.connection_id[0])
80                 span.set_attribute("net.peer.port", event.connection_id[1])
81 
82             # pymongo specific, not specified by spec
83             span.set_attribute("db.mongo.operation_id", event.operation_id)
84             span.set_attribute("db.mongo.request_id", event.request_id)
85 
86             for attr in COMMAND_ATTRIBUTES:
87                 _attr = event.command.get(attr)
88                 if _attr is not None:
89                     span.set_attribute("db.mongo." + attr, str(_attr))
90 
91             # Add Span to dictionary
92             self._span_dict[_get_span_dict_key(event)] = span
93         except Exception as ex:  # noqa pylint: disable=broad-except
94             if span is not None:
95                 span.set_status(Status(StatusCanonicalCode.INTERNAL, str(ex)))
96                 span.end()
97                 self._pop_span(event)
98 
99     def succeeded(self, event: monitoring.CommandSucceededEvent):
100         """ Method to handle a pymongo CommandSucceededEvent """
101         if not self.is_enabled:
102             return
103         span = self._pop_span(event)
104         if span is None:
105             return
106         span.set_attribute("db.mongo.duration_micros", event.duration_micros)
107         span.set_status(Status(StatusCanonicalCode.OK, event.reply))
108         span.end()
109 
110     def failed(self, event: monitoring.CommandFailedEvent):
111         """ Method to handle a pymongo CommandFailedEvent """
112         if not self.is_enabled:
113             return
114         span = self._pop_span(event)
115         if span is None:
116             return
117         span.set_attribute("db.mongo.duration_micros", event.duration_micros)
118         span.set_status(Status(StatusCanonicalCode.UNKNOWN, event.failure))
119         span.end()
120 
121     def _pop_span(self, event):
122         return self._span_dict.pop(_get_span_dict_key(event), None)
123 
124 
125 def _get_span_dict_key(event):
126     if event.connection_id is not None:
127         return (event.request_id, event.connection_id)
128     return event.request_id
129 
130 
131 class PymongoInstrumentor(BaseInstrumentor):
132     _commandtracer_instance = None  # type CommandTracer
133     # The instrumentation for PyMongo is based on the event listener interface
134     # https://api.mongodb.com/python/current/api/pymongo/monitoring.html.
135     # This interface only allows to register listeners and does not provide
136     # an unregister API. In order to provide a mechanishm to disable
137     # instrumentation an enabled flag is implemented in CommandTracer,
138     # it's checked in the different listeners.
139 
140     def _instrument(self, **kwargs):
141         """Integrate with pymongo to trace it using event listener.
142         https://api.mongodb.com/python/current/api/pymongo/monitoring.html
143 
144         Args:
145             tracer_provider: The `TracerProvider` to use. If none is passed the
146                 current configured one is used.
147         """
148 
149         tracer_provider = kwargs.get("tracer_provider")
150 
151         # Create and register a CommandTracer only the first time
152         if self._commandtracer_instance is None:
153             tracer = get_tracer(__name__, __version__, tracer_provider)
154 
155             self._commandtracer_instance = CommandTracer(tracer)
156             monitoring.register(self._commandtracer_instance)
157 
158         # If already created, just enable it
159         self._commandtracer_instance.is_enabled = True
160 
161     def _uninstrument(self, **kwargs):
162         if self._commandtracer_instance is not None:
163             self._commandtracer_instance.is_enabled = False
164
```
--- 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/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py
--- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py
+++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py
@@ -66,8 +66,8 @@
         name = DATABASE_TYPE + "." + event.command_name
         statement = event.command_name
         if command:
-            name += "." + command
-            statement += " " + command
+            name += "." + str(command)
+            statement += " " + str(command)
 
         try:
             span = self._tracer.start_span(name, kind=SpanKind.CLIENT)

{"golden_diff": "diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py\n--- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py\n+++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py\n@@ -66,8 +66,8 @@\n         name = DATABASE_TYPE + \".\" + event.command_name\n         statement = event.command_name\n         if command:\n-            name += \".\" + command\n-            statement += \" \" + command\n+            name += \".\" + str(command)\n+            statement += \" \" + str(command)\n \n         try:\n             span = self._tracer.start_span(name, kind=SpanKind.CLIENT)\n", "issue": "TypeError with pymongo `getMore` operations\n**Describe your environment** \r\nDescribe your environment\r\nMac OS Catalina 10.15.6 (19G73)\r\nDarwin-19.6.0-x86_64-i386-64bit\r\nPython 3.7.7\r\nInstalled packages:\r\n```\r\nopentelemetry-api                      0.12b0    OpenTelemetry Python API\r\nopentelemetry-ext-honeycomb            0.5b0     Honeycomb Exporter for OpenTelemetry\r\nopentelemetry-instrumentation          0.12b0    Instrumentation Tools & Auto Instrumentation for OpenTelemetry Python\r\nopentelemetry-instrumentation-botocore 0.12b0    OpenTelemetry Botocore instrumentation\r\nopentelemetry-instrumentation-pymongo  0.12b0    OpenTelemetry pymongo instrumentation\r\nopentelemetry-instrumentation-requests 0.12b0    OpenTelemetry requests instrumentation\r\npymongo                                3.11.0    Python driver for MongoDB <http://www.mongodb.org>\r\n```\r\n\r\n**Steps to reproduce**\r\nany find operation where the number of documents to be returned exceeds the batch size on the cursor:\r\n```pyhton\r\nfrom pymongo import MongoClient\r\nfrom opentelemetry import trace\r\nfrom opentelemetry.trace import TracerProvider\r\nfrom opentelemetry.instrumentation.pymongo import PymongoInstrumentor\r\n\r\ntrace.set_tracer_provider(TracerProvider())\r\n\r\nPymongoInstrumentor().instrument()\r\nclient = MongoClient()\r\ndb = client[\"MongoDB_Database\"]\r\ncollection = db[\"MongoDB_Collection\"]\r\ncollection.find({'batch_size': 1})\r\n```\r\n**What is the expected behavior?**\r\nSpans with names like `mongodb.getMore.1`\r\n\r\n**What is the actual behavior?**\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/drubin/cargurus/analytics/snowblower/.venv/lib/python3.7/site-packages/pymongo/monitoring.py\", line 1266, in publish_command_start\r\n    subscriber.started(event)\r\n  File \"/Users/drubin/cargurus/analytics/snowblower/.venv/lib/python3.7/site-packages/opentelemetry/instrumentation/pymongo/__init__.py\", line 69, in started\r\n    name += \".\" + command\r\nTypeError: can only concatenate str (not \"int\") to str\r\n```\r\n\r\n\r\n\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\n\"\"\"\nThe integration with MongoDB supports the `pymongo`_ library, it can be\nenabled using the ``PymongoInstrumentor``.\n\n.. _pymongo: https://pypi.org/project/pymongo\n\nUsage\n-----\n\n.. code:: python\n\n    from pymongo import MongoClient\n    from opentelemetry import trace\n    from opentelemetry.trace import TracerProvider\n    from opentelemetry.instrumentation.pymongo import PymongoInstrumentor\n\n    trace.set_tracer_provider(TracerProvider())\n\n    PymongoInstrumentor().instrument()\n    client = MongoClient()\n    db = client[\"MongoDB_Database\"]\n    collection = db[\"MongoDB_Collection\"]\n    collection.find_one()\n\nAPI\n---\n\"\"\"\n\nfrom pymongo import monitoring\n\nfrom opentelemetry import trace\nfrom opentelemetry.instrumentation.instrumentor import BaseInstrumentor\nfrom opentelemetry.instrumentation.pymongo.version import __version__\nfrom opentelemetry.trace import SpanKind, get_tracer\nfrom opentelemetry.trace.status import Status, StatusCanonicalCode\n\nDATABASE_TYPE = \"mongodb\"\nCOMMAND_ATTRIBUTES = [\"filter\", \"sort\", \"skip\", \"limit\", \"pipeline\"]\n\n\nclass CommandTracer(monitoring.CommandListener):\n    def __init__(self, tracer):\n        self._tracer = tracer\n        self._span_dict = {}\n        self.is_enabled = True\n\n    def started(self, event: monitoring.CommandStartedEvent):\n        \"\"\" Method to handle a pymongo CommandStartedEvent \"\"\"\n        if not self.is_enabled:\n            return\n        command = event.command.get(event.command_name, \"\")\n        name = DATABASE_TYPE + \".\" + event.command_name\n        statement = event.command_name\n        if command:\n            name += \".\" + command\n            statement += \" \" + command\n\n        try:\n            span = self._tracer.start_span(name, kind=SpanKind.CLIENT)\n            span.set_attribute(\"component\", DATABASE_TYPE)\n            span.set_attribute(\"db.type\", DATABASE_TYPE)\n            span.set_attribute(\"db.instance\", event.database_name)\n            span.set_attribute(\"db.statement\", statement)\n            if event.connection_id is not None:\n                span.set_attribute(\"net.peer.name\", event.connection_id[0])\n                span.set_attribute(\"net.peer.port\", event.connection_id[1])\n\n            # pymongo specific, not specified by spec\n            span.set_attribute(\"db.mongo.operation_id\", event.operation_id)\n            span.set_attribute(\"db.mongo.request_id\", event.request_id)\n\n            for attr in COMMAND_ATTRIBUTES:\n                _attr = event.command.get(attr)\n                if _attr is not None:\n                    span.set_attribute(\"db.mongo.\" + attr, str(_attr))\n\n            # Add Span to dictionary\n            self._span_dict[_get_span_dict_key(event)] = span\n        except Exception as ex:  # noqa pylint: disable=broad-except\n            if span is not None:\n                span.set_status(Status(StatusCanonicalCode.INTERNAL, str(ex)))\n                span.end()\n                self._pop_span(event)\n\n    def succeeded(self, event: monitoring.CommandSucceededEvent):\n        \"\"\" Method to handle a pymongo CommandSucceededEvent \"\"\"\n        if not self.is_enabled:\n            return\n        span = self._pop_span(event)\n        if span is None:\n            return\n        span.set_attribute(\"db.mongo.duration_micros\", event.duration_micros)\n        span.set_status(Status(StatusCanonicalCode.OK, event.reply))\n        span.end()\n\n    def failed(self, event: monitoring.CommandFailedEvent):\n        \"\"\" Method to handle a pymongo CommandFailedEvent \"\"\"\n        if not self.is_enabled:\n            return\n        span = self._pop_span(event)\n        if span is None:\n            return\n        span.set_attribute(\"db.mongo.duration_micros\", event.duration_micros)\n        span.set_status(Status(StatusCanonicalCode.UNKNOWN, event.failure))\n        span.end()\n\n    def _pop_span(self, event):\n        return self._span_dict.pop(_get_span_dict_key(event), None)\n\n\ndef _get_span_dict_key(event):\n    if event.connection_id is not None:\n        return (event.request_id, event.connection_id)\n    return event.request_id\n\n\nclass PymongoInstrumentor(BaseInstrumentor):\n    _commandtracer_instance = None  # type CommandTracer\n    # The instrumentation for PyMongo is based on the event listener interface\n    # https://api.mongodb.com/python/current/api/pymongo/monitoring.html.\n    # This interface only allows to register listeners and does not provide\n    # an unregister API. In order to provide a mechanishm to disable\n    # instrumentation an enabled flag is implemented in CommandTracer,\n    # it's checked in the different listeners.\n\n    def _instrument(self, **kwargs):\n        \"\"\"Integrate with pymongo to trace it using event listener.\n        https://api.mongodb.com/python/current/api/pymongo/monitoring.html\n\n        Args:\n            tracer_provider: The `TracerProvider` to use. If none is passed the\n                current configured one is used.\n        \"\"\"\n\n        tracer_provider = kwargs.get(\"tracer_provider\")\n\n        # Create and register a CommandTracer only the first time\n        if self._commandtracer_instance is None:\n            tracer = get_tracer(__name__, __version__, tracer_provider)\n\n            self._commandtracer_instance = CommandTracer(tracer)\n            monitoring.register(self._commandtracer_instance)\n\n        # If already created, just enable it\n        self._commandtracer_instance.is_enabled = True\n\n    def _uninstrument(self, **kwargs):\n        if self._commandtracer_instance is not None:\n            self._commandtracer_instance.is_enabled = False\n", "path": "instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.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\n\"\"\"\nThe integration with MongoDB supports the `pymongo`_ library, it can be\nenabled using the ``PymongoInstrumentor``.\n\n.. _pymongo: https://pypi.org/project/pymongo\n\nUsage\n-----\n\n.. code:: python\n\n    from pymongo import MongoClient\n    from opentelemetry import trace\n    from opentelemetry.trace import TracerProvider\n    from opentelemetry.instrumentation.pymongo import PymongoInstrumentor\n\n    trace.set_tracer_provider(TracerProvider())\n\n    PymongoInstrumentor().instrument()\n    client = MongoClient()\n    db = client[\"MongoDB_Database\"]\n    collection = db[\"MongoDB_Collection\"]\n    collection.find_one()\n\nAPI\n---\n\"\"\"\n\nfrom pymongo import monitoring\n\nfrom opentelemetry import trace\nfrom opentelemetry.instrumentation.instrumentor import BaseInstrumentor\nfrom opentelemetry.instrumentation.pymongo.version import __version__\nfrom opentelemetry.trace import SpanKind, get_tracer\nfrom opentelemetry.trace.status import Status, StatusCanonicalCode\n\nDATABASE_TYPE = \"mongodb\"\nCOMMAND_ATTRIBUTES = [\"filter\", \"sort\", \"skip\", \"limit\", \"pipeline\"]\n\n\nclass CommandTracer(monitoring.CommandListener):\n    def __init__(self, tracer):\n        self._tracer = tracer\n        self._span_dict = {}\n        self.is_enabled = True\n\n    def started(self, event: monitoring.CommandStartedEvent):\n        \"\"\" Method to handle a pymongo CommandStartedEvent \"\"\"\n        if not self.is_enabled:\n            return\n        command = event.command.get(event.command_name, \"\")\n        name = DATABASE_TYPE + \".\" + event.command_name\n        statement = event.command_name\n        if command:\n            name += \".\" + str(command)\n            statement += \" \" + str(command)\n\n        try:\n            span = self._tracer.start_span(name, kind=SpanKind.CLIENT)\n            span.set_attribute(\"component\", DATABASE_TYPE)\n            span.set_attribute(\"db.type\", DATABASE_TYPE)\n            span.set_attribute(\"db.instance\", event.database_name)\n            span.set_attribute(\"db.statement\", statement)\n            if event.connection_id is not None:\n                span.set_attribute(\"net.peer.name\", event.connection_id[0])\n                span.set_attribute(\"net.peer.port\", event.connection_id[1])\n\n            # pymongo specific, not specified by spec\n            span.set_attribute(\"db.mongo.operation_id\", event.operation_id)\n            span.set_attribute(\"db.mongo.request_id\", event.request_id)\n\n            for attr in COMMAND_ATTRIBUTES:\n                _attr = event.command.get(attr)\n                if _attr is not None:\n                    span.set_attribute(\"db.mongo.\" + attr, str(_attr))\n\n            # Add Span to dictionary\n            self._span_dict[_get_span_dict_key(event)] = span\n        except Exception as ex:  # noqa pylint: disable=broad-except\n            if span is not None:\n                span.set_status(Status(StatusCanonicalCode.INTERNAL, str(ex)))\n                span.end()\n                self._pop_span(event)\n\n    def succeeded(self, event: monitoring.CommandSucceededEvent):\n        \"\"\" Method to handle a pymongo CommandSucceededEvent \"\"\"\n        if not self.is_enabled:\n            return\n        span = self._pop_span(event)\n        if span is None:\n            return\n        span.set_attribute(\"db.mongo.duration_micros\", event.duration_micros)\n        span.set_status(Status(StatusCanonicalCode.OK, event.reply))\n        span.end()\n\n    def failed(self, event: monitoring.CommandFailedEvent):\n        \"\"\" Method to handle a pymongo CommandFailedEvent \"\"\"\n        if not self.is_enabled:\n            return\n        span = self._pop_span(event)\n        if span is None:\n            return\n        span.set_attribute(\"db.mongo.duration_micros\", event.duration_micros)\n        span.set_status(Status(StatusCanonicalCode.UNKNOWN, event.failure))\n        span.end()\n\n    def _pop_span(self, event):\n        return self._span_dict.pop(_get_span_dict_key(event), None)\n\n\ndef _get_span_dict_key(event):\n    if event.connection_id is not None:\n        return (event.request_id, event.connection_id)\n    return event.request_id\n\n\nclass PymongoInstrumentor(BaseInstrumentor):\n    _commandtracer_instance = None  # type CommandTracer\n    # The instrumentation for PyMongo is based on the event listener interface\n    # https://api.mongodb.com/python/current/api/pymongo/monitoring.html.\n    # This interface only allows to register listeners and does not provide\n    # an unregister API. In order to provide a mechanishm to disable\n    # instrumentation an enabled flag is implemented in CommandTracer,\n    # it's checked in the different listeners.\n\n    def _instrument(self, **kwargs):\n        \"\"\"Integrate with pymongo to trace it using event listener.\n        https://api.mongodb.com/python/current/api/pymongo/monitoring.html\n\n        Args:\n            tracer_provider: The `TracerProvider` to use. If none is passed the\n                current configured one is used.\n        \"\"\"\n\n        tracer_provider = kwargs.get(\"tracer_provider\")\n\n        # Create and register a CommandTracer only the first time\n        if self._commandtracer_instance is None:\n            tracer = get_tracer(__name__, __version__, tracer_provider)\n\n            self._commandtracer_instance = CommandTracer(tracer)\n            monitoring.register(self._commandtracer_instance)\n\n        # If already created, just enable it\n        self._commandtracer_instance.is_enabled = True\n\n    def _uninstrument(self, **kwargs):\n        if self._commandtracer_instance is not None:\n            self._commandtracer_instance.is_enabled = False\n", "path": "instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py"}]}