jd: Had to rebase again because all objects size are different between Py2 and Py3.
diff --git a/ddtrace/utils/sizeof.py b/ddtrace/utils/sizeof.py
index 1b4e56132..4fcb0e675 100644
--- a/ddtrace/utils/sizeof.py
+++ b/ddtrace/utils/sizeof.py
@@ -2,10 +2,16 @@ import collections
 import sys
 from itertools import chain
 
+_UNSET = object()
+
 
 def iter_object(o):
     if hasattr(o, '__slots__'):
-        return (getattr(o, slot) for slot in o.__slots__)
+        return (
+            s
+            for s in (getattr(o, slot, _UNSET) for slot in o.__slots__)
+            if s != _UNSET
+        )
     elif hasattr(o, '__dict__'):
         return list(o.__dict__.items())
     elif isinstance(o, dict):

Exception raised with sizeof of some spans
With `master`:

```
Exception in thread AgentWriter:
Traceback (most recent call last):
  File "/opt/dogweb/pyenv/versions/2.7.12/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/opt/dogweb/pyenv/versions/2.7.12/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/_worker.py", line 67, in _target
    self.run_periodic()
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/internal/writer.py", line 65, in flush_queue
    traces_queue_size = sum(map(sizeof.sizeof, traces))
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/utils/sizeof.py", line 31, in sizeof
    return _sizeof(o)
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/utils/sizeof.py", line 29, in _sizeof
    return sys.getsizeof(o) + sum(map(_sizeof, iter_object(o)))
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/utils/sizeof.py", line 29, in _sizeof
    return sys.getsizeof(o) + sum(map(_sizeof, iter_object(o)))
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/utils/sizeof.py", line 29, in _sizeof
    return sys.getsizeof(o) + sum(map(_sizeof, iter_object(o)))
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/utils/sizeof.py", line 29, in _sizeof
    return sys.getsizeof(o) + sum(map(_sizeof, iter_object(o)))
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/utils/sizeof.py", line 29, in _sizeof
    return sys.getsizeof(o) + sum(map(_sizeof, iter_object(o)))
  File "/opt/dogweb/lib/python2.7/site-packages/ddtrace/utils/sizeof.py", line 8, in <genexpr>
    return (getattr(o, slot) for slot in o.__slots__)
AttributeError: rate_limit
```

Might be an issue where the attribute is declared in `__slots__` but not set.
diff --git a/tests/test_utils.py b/tests/test_utils.py
index a7d1a9ab7..bad0b72b9 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -106,3 +106,25 @@ def test_sizeof():
     assert one_three > sizeof_list
     x = {'a': 1}
     assert sizeof.sizeof([x, x]) < sizeof.sizeof([{'a': 1}, {'a': 1}])
+
+
+class Slots(object):
+
+    __slots__ = ('foobar',)
+
+    def __init__(self):
+        self.foobar = 123
+
+
+def test_sizeof_slots():
+    assert sizeof.sizeof(Slots()) >= 1
+
+
+class BrokenSlots(object):
+
+    __slots__ = ('foobar',)
+
+
+def test_sizeof_broken_slots():
+    """https://github.com/DataDog/dd-trace-py/issues/1079"""
+    assert sizeof.sizeof(BrokenSlots()) >= 1

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-benchmark pytest-django pytest-mock
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
coverage==6.2
-e git+https://github.com/DataDog/dd-trace-py.git@1f84908909070e9ae75f97a21a159e7de1063edb#egg=ddtrace
importlib-metadata==4.8.3
iniconfig==1.1.1
packaging==21.3
pluggy==1.0.0
psutil==7.0.0
py==1.11.0
py-cpuinfo==9.0.0
pyparsing==3.1.4
pytest==7.0.1
pytest-benchmark==3.4.1
pytest-cov==4.0.0
pytest-django==4.5.2
pytest-mock==3.6.1
tomli==1.2.3
typing_extensions==4.1.1
zipp==3.6.0

name: dd-trace-py
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - coverage==6.2
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - packaging==21.3
      - pluggy==1.0.0
      - psutil==7.0.0
      - py==1.11.0
      - py-cpuinfo==9.0.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-benchmark==3.4.1
      - pytest-cov==4.0.0
      - pytest-django==4.5.2
      - pytest-mock==3.6.1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/dd-trace-py

tests/test_utils.py::test_sizeof_broken_slots
tests/test_utils.py::TestUtils::test_asbool tests/test_utils.py::TestUtils::test_deprecated_decorator tests/test_utils.py::TestUtils::test_deprecation tests/test_utils.py::TestUtils::test_deprecation_formatter tests/test_utils.py::TestUtils::test_flatten_dict tests/test_utils.py::TestUtils::test_get_env tests/test_utils.py::TestUtils::test_get_env_found tests/test_utils.py::TestUtils::test_get_env_found_legacy tests/test_utils.py::TestUtils::test_get_env_key_priority tests/test_utils.py::test_sizeof tests/test_utils.py::test_sizeof_slots
ddtrace/utils/sizeof.py
ddtrace/utils/sizeof.py