Repository: DataDog/dd-trace-py

Issue:
`ddtrace.opentracer.span.Span` method return types not compliant with `opentracing.span.Span`
I'll be happy to submit a PR for this--it should be a small fix--but wanted to make sure this isn't a known issue first.

### Which version of dd-trace-py are you using?

0.59.0

### Which version of pip are you using?

22.0.3

### Explanation

`opentracing.span.Span` defines a handful of methods that return `self` for the instance their invoked on, in order to support call chaining.

`ddtrace.opentracer.span.Span` does not implement this interface for `set_tag` or `set_operation_name`.

https://github.com/DataDog/dd-trace-py/blob/1a6bad3ec2cbfffab0f83ebf5b72fe786b76dbed/ddtrace/opentracer/span.py#L137-L138
https://github.com/DataDog/dd-trace-py/blob/1a6bad3ec2cbfffab0f83ebf5b72fe786b76dbed/ddtrace/opentracer/span.py#L98-L99

See the `opentracing` interfaces for [set_tag](https://github.com/opentracing/opentracing-python/blob/1d495f7b1c89e3577c0ce4911ed2962c8dcf1482/opentracing/span.py#L120-L139) and [set_operation_name](https://github.com/opentracing/opentracing-python/blob/1d495f7b1c89e3577c0ce4911ed2962c8dcf1482/opentracing/span.py#L95-L104).



Discussion:

Resolving patch:
diff --git a/ddtrace/opentracer/span.py b/ddtrace/opentracer/span.py
--- a/ddtrace/opentracer/span.py
+++ b/ddtrace/opentracer/span.py
@@ -94,9 +94,10 @@ def get_baggage_item(self, key):
         return self.context.get_baggage_item(key)
 
     def set_operation_name(self, operation_name):
-        # type: (str) -> None
+        # type: (str) -> Span
         """Set the operation name."""
         self._dd_span.name = operation_name
+        return self
 
     def log_kv(self, key_values, timestamp=None):
         # type: (Dict[_TagNameType, Any], Optional[float]) -> Span
@@ -133,7 +134,7 @@ def log_kv(self, key_values, timestamp=None):
         return self
 
     def set_tag(self, key, value):
-        # type: (_TagNameType, Any) -> None
+        # type: (_TagNameType, Any) -> Span
         """Set a tag on the span.
 
         This sets the tag on the underlying datadog span.
@@ -152,6 +153,7 @@ def set_tag(self, key, value):
             self._dd_span.context.sampling_priority = value
         else:
             self._dd_span.set_tag(key, value)
+        return self
 
     def _get_tag(self, key):
         # type: (_TagNameType) -> Optional[Text]


Test patch:
diff --git a/tests/opentracer/core/test_span.py b/tests/opentracer/core/test_span.py
--- a/tests/opentracer/core/test_span.py
+++ b/tests/opentracer/core/test_span.py
@@ -37,8 +37,9 @@ def test_init(self, nop_tracer, nop_span_ctx):
 
     def test_tags(self, nop_span):
         """Set a tag and get it back."""
-        nop_span.set_tag("test", 23)
+        r = nop_span.set_tag("test", 23)
         assert nop_span._get_metric("test") == 23
+        assert r is nop_span
 
     def test_set_baggage(self, nop_span):
         """Test setting baggage."""
@@ -96,8 +97,9 @@ def test_log_dd_kv(self, nop_span):
     def test_operation_name(self, nop_span):
         """Sanity check for setting the operation name."""
         # just try setting the operation name
-        nop_span.set_operation_name("new_op_name")
+        r = nop_span.set_operation_name("new_op_name")
         assert nop_span._dd_span.name == "new_op_name"
+        assert r is nop_span
 
     def test_context_manager(self, nop_span):
         """Test the span context manager."""