Repository: open-telemetry/opentelemetry-python

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
```





Discussion:

Resolving patch:
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 @@ def started(self, event: monitoring.CommandStartedEvent):
         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)


Test patch:
diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py b/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py
--- a/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py
+++ b/instrumentation/opentelemetry-instrumentation-pymongo/tests/test_pymongo.py
@@ -138,6 +138,23 @@ def test_multiple_commands(self):
             trace_api.status.StatusCanonicalCode.UNKNOWN,
         )
 
+    def test_int_command(self):
+        command_attrs = {
+            "command_name": 123,
+        }
+        mock_event = MockEvent(command_attrs)
+
+        command_tracer = CommandTracer(self.tracer)
+        command_tracer.started(event=mock_event)
+        command_tracer.succeeded(event=mock_event)
+
+        spans_list = self.memory_exporter.get_finished_spans()
+
+        self.assertEqual(len(spans_list), 1)
+        span = spans_list[0]
+
+        self.assertEqual(span.name, "mongodb.command_name.123")
+
 
 class MockCommand:
     def __init__(self, command_attrs):