Repository: DataDog/dd-trace-py

Issue:
Fix __slots__ inheritance
### Which version of dd-trace-py are you using?

0.60.0

### How can we reproduce your problem?

```
>>> from ddtrace.span import Span
>>> Span.__slots__
['service', 'name', '_resource', 'span_id', 'trace_id', 'parent_id', '_meta', 'error', '_metrics', '_span_type', 'start_ns', 'duration_ns', '_tracer', 'sampled', '_context', '_local_root', '_parent', '_ignored_exceptions', '_on_finish_callbacks', '__weakref__']
>>> Span(None,"").foo = 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Span' object has no attribute 'foo'
>>> from ddtrace.sampler import DatadogSampler
>>> DatadogSampler.__slots__
('limiter', 'rules')
>>> DatadogSampler().foo = 1
```

I found this issue using [slotscheck](https://github.com/ariebovenberg/slotscheck).

### What is the result that you get?

The following errors are found by slotscheck:

```
ERROR: 'ddtrace.internal.logger:DDLogger' has slots but superclass does not.
ERROR: 'ddtrace.profiling.collector:PeriodicCollector' has slots but superclass does not.
ERROR: 'ddtrace.sampler:DatadogSampler' has slots but superclass does not.
ERROR: 'ddtrace.sampler:SamplingRule' has slots but superclass does not.
```

This error message is explained at https://slotscheck.readthedocs.io/en/latest/errors.html#superclass-has-no-slots

### What is the result that you expected?

An `AttributeError` when accessing an undefined attribute for classes with slots.

No errors in output of slotscheck.


Discussion:

Resolving patch:
diff --git a/ddtrace/internal/logger.py b/ddtrace/internal/logger.py
--- a/ddtrace/internal/logger.py
+++ b/ddtrace/internal/logger.py
@@ -87,8 +87,6 @@ class DDLogger(logging.Logger):
     log messages from within the ``ddtrace`` package.
     """
 
-    __slots__ = ("buckets", "rate_limit")
-
     # Named tuple used for keeping track of a log lines current time bucket and the number of log lines skipped
     LoggingBucket = collections.namedtuple("LoggingBucket", ("bucket", "skipped"))
 
diff --git a/ddtrace/sampler.py b/ddtrace/sampler.py
--- a/ddtrace/sampler.py
+++ b/ddtrace/sampler.py
@@ -52,12 +52,18 @@ class SamplingError(Exception):
 
 
 class BaseSampler(six.with_metaclass(abc.ABCMeta)):
+
+    __slots__ = ()
+
     @abc.abstractmethod
     def sample(self, span):
         pass
 
 
 class BasePrioritySampler(BaseSampler):
+
+    __slots__ = ()
+
     @abc.abstractmethod
     def update_rate_by_service_sample_rates(self, sample_rates):
         pass
@@ -106,6 +112,8 @@ class RateByServiceSampler(BasePrioritySampler):
     The sample rate is kept independently for each service/env tuple.
     """
 
+    __slots__ = ("sample_rate", "_by_service_samplers")
+
     _default_key = "service:,env:"
 
     @staticmethod
@@ -341,8 +349,6 @@ class SamplingRule(BaseSampler):
     Definition of a sampling rule used by :class:`DatadogSampler` for applying a sample rate on a span
     """
 
-    __slots__ = ("_sample_rate", "_sampling_id_threshold", "service", "name")
-
     NO_RULE = object()
 
     def __init__(
diff --git a/riotfile.py b/riotfile.py
--- a/riotfile.py
+++ b/riotfile.py
@@ -156,6 +156,16 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
                 ),
             ],
         ),
+        Venv(
+            pys=["3"],
+            pkgs={"slotscheck": latest},
+            venvs=[
+                Venv(
+                    name="slotscheck",
+                    command="python -m slotscheck -v ddtrace/",
+                ),
+            ],
+        ),
         Venv(
             pys=["3"],
             pkgs={"ddapm-test-agent": ">=1.2.0"},


Test patch: