Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hub): Emit deprecation warnings from Hub API #3280

Merged
merged 5 commits into from
Jul 22, 2024

Conversation

szokeasaurusrex
Copy link
Member

sentry_sdk.Hub has been deprecated since Sentry SDK version 2.0.0 per our docs; however, we waited with adding deprecation warnings because the SDK itself was still using Hub APIs until recently.

Since we no longer use Hub APIs in the SDK (except in Hub APIs which are themselves deprecated), we can now start emitting deprecation warnings.

Closes #3265

@szokeasaurusrex
Copy link
Member Author

When testing this change manually, I was able to see the deprecation warnings in console when calling Hub APIs from a simple Python script.

However, when I tried calling Hub APIs from a request handler (both in Flask and FastAPI), I did not see the deprecation warning in the console, unless I manually configured a warning filter to display deprecation warnings.

Do you have any idea why this could be @sl0thentr0py? Is there anything we can do here to make sure server framework users get warned, or is this just a configuration option that the user would have to set?

Copy link

codecov bot commented Jul 11, 2024

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 13480 tests with 3 failed, 11731 passed and 1746 skipped.

View the full list of failed tests

py3.12-common

  • Class name: tests.test_utils
    Test name: test_installed_modules

    tests/test_utils.py:538: in test_installed_modules
    assert installed_distributions == importlib_distributions
    E AssertionError: assert {'asttokens': '2.4.1',\n 'attrs': '23.2.0',\n 'certifi': '2024.7.4',\n 'charset-normalizer': '3.3.2',\n 'colorama': '0.4.6',\n 'coverage': '7.6.0',\n 'docopt': '0.6.2',\n 'executing': '2.0.1',\n 'idna': '3.7',\n 'iniconfig': '2.0.0',\n 'jsonschema': '4.23.0',\n 'jsonschema-specifications': '2023.12.1',\n 'markupsafe': '2.1.5',\n 'packaging': '24.1',\n 'pip': '24.0',\n 'pluggy': '1.5.0',\n 'py': '1.11.0',\n 'pyrsistent': '0.20.0',\n 'pysocks': '1.7.1',\n 'pytest': '6.2.5',\n 'pytest-asyncio': '0.20.3',\n 'pytest-cov': '5.0.0',\n 'pytest-forked': '1.6.0',\n 'pytest-localserver': '0.8.1',\n 'pytest-watch': '4.2.0',\n 'pyyaml': '6.0.1',\n 'referencing': '0.35.1',\n 'requests': '2.32.3',\n 'responses': '0.25.3',\n 'rpds-py': '0.19.0',\n 'sentry-sdk': '2.10.0',\n 'setuptools': '71.0.3',\n 'six': '1.16.0',\n 'toml': '0.10.2',\n 'urllib3': '2.2.2',\n 'watchdog': '4.0.1',\n 'werkzeug': '3.0.3'} == {'asttokens': '2.4.1',\n 'attrs': '23.2.0',\n 'autocommand': '2.2.2',\n 'backports-tarfile': '1.2.0',\n 'certifi': '2024.7.4',\n 'charset-normalizer': '3.3.2',\n 'colorama': '0.4.6',\n 'coverage': '7.6.0',\n 'docopt': '0.6.2',\n 'executing': '2.0.1',\n 'idna': '3.7',\n 'importlib-metadata': '8.0.0',\n 'importlib-resources': '6.4.0',\n 'inflect': '7.3.1',\n 'iniconfig': '2.0.0',\n 'jaraco-context': '5.3.0',\n 'jaraco-functools': '4.0.1',\n 'jaraco-text': '3.12.1',\n 'jsonschema': '4.23.0',\n 'jsonschema-specifications': '2023.12.1',\n 'markupsafe': '2.1.5',\n 'more-itertools': '10.3.0',\n 'ordered-set': '4.1.0',\n 'packaging': '24.1',\n 'pip': '24.0',\n 'platformdirs': '4.2.2',\n 'pluggy': '1.5.0',\n 'py': '1.11.0',\n 'pyrsistent': '0.20.0',\n 'pysocks': '1.7.1',\n 'pytest': '6.2.5',\n 'pytest-asyncio': '0.20.3',\n 'pytest-cov': '5.0.0',\n 'pytest-forked': '1.6.0',\n 'pytest-localserver': '0.8.1',\n 'pytest-watch': '4.2.0',\n 'pyyaml': '6.0.1',\n 'referencing': '0.35.1',\n 'requests': '2.32.3',\n 'responses': '0.25.3',\n 'rpds-py': '0.19.0',\n 'sentry-sdk': '2.10.0',\n 'setuptools': '71.0.3',\n 'six': '1.16.0',\n 'toml': '0.10.2',\n 'tomli': '2.0.1',\n 'typeguard': '4.3.0',\n 'typing-extensions': '4.12.2',\n 'urllib3': '2.2.2',\n 'watchdog': '4.0.1',\n 'werkzeug': '3.0.3',\n 'wheel': '0.43.0',\n 'zipp': '3.19.2'}
    E Common items:
    E {'asttokens': '2.4.1',
    E 'attrs': '23.2.0',
    E 'certifi': '2024.7.4',
    E 'charset-normalizer': '3.3.2',
    E 'colorama': '0.4.6',
    E 'coverage': '7.6.0',
    E 'docopt': '0.6.2',
    E 'executing': '2.0.1',
    E 'idna': '3.7',
    E 'iniconfig': '2.0.0',
    E 'jsonschema': '4.23.0',
    E 'jsonschema-specifications': '2023.12.1',
    E 'markupsafe': '2.1.5',
    E 'packaging': '24.1',
    E 'pip': '24.0',
    E 'pluggy': '1.5.0',
    E 'py': '1.11.0',
    E 'pyrsistent': '0.20.0',
    E 'pysocks': '1.7.1',
    E 'pytest': '6.2.5',
    E 'pytest-asyncio': '0.20.3',
    E 'pytest-cov': '5.0.0',
    E 'pytest-forked': '1.6.0',
    E 'pytest-localserver': '0.8.1',
    E 'pytest-watch': '4.2.0',
    E 'pyyaml': '6.0.1',
    E 'referencing': '0.35.1',
    E 'requests': '2.32.3',
    E 'responses': '0.25.3',
    E 'rpds-py': '0.19.0',
    E 'sentry-sdk': '2.10.0',
    E 'setuptools': '71.0.3',
    E 'six': '1.16.0',
    E 'toml': '0.10.2',
    E 'urllib3': '2.2.2',
    E 'watchdog': '4.0.1',
    E 'werkzeug': '3.0.3'}
    E Right contains 16 more items:
    E {'autocommand': '2.2.2',
    E 'backports-tarfile': '1.2.0',
    E 'importlib-metadata': '8.0.0',
    E 'importlib-resources': '6.4.0',
    E 'inflect': '7.3.1',
    E 'jaraco-context': '5.3.0',
    E 'jaraco-functools': '4.0.1',
    E 'jaraco-text': '3.12.1',
    E 'more-itertools': '10.3.0',
    E 'ordered-set': '4.1.0',
    E 'platformdirs': '4.2.2',
    E 'tomli': '2.0.1',
    E 'typeguard': '4.3.0',
    E 'typing-extensions': '4.12.2',
    E 'wheel': '0.43.0',
    E 'zipp': '3.19.2'}
    E Full diff:
    E {
    E 'asttokens': '2.4.1',
    E 'attrs': '23.2.0',
    E - 'autocommand': '2.2.2',
    E - 'backports-tarfile': '1.2.0',
    E 'certifi': '2024.7.4',
    E 'charset-normalizer': '3.3.2',
    E 'colorama': '0.4.6',
    E 'coverage': '7.6.0',
    E 'docopt': '0.6.2',
    E 'executing': '2.0.1',
    E 'idna': '3.7',
    E - 'importlib-metadata': '8.0.0',
    E - 'importlib-resources': '6.4.0',
    E - 'inflect': '7.3.1',
    E 'iniconfig': '2.0.0',
    E - 'jaraco-context': '5.3.0',
    E - 'jaraco-functools': '4.0.1',
    E - 'jaraco-text': '3.12.1',
    E 'jsonschema': '4.23.0',
    E 'jsonschema-specifications': '2023.12.1',
    E 'markupsafe': '2.1.5',
    E - 'more-itertools': '10.3.0',
    E - 'ordered-set': '4.1.0',
    E 'packaging': '24.1',
    E 'pip': '24.0',
    E - 'platformdirs': '4.2.2',
    E 'pluggy': '1.5.0',
    E 'py': '1.11.0',
    E 'pyrsistent': '0.20.0',
    E 'pysocks': '1.7.1',
    E 'pytest': '6.2.5',
    E 'pytest-asyncio': '0.20.3',
    E 'pytest-cov': '5.0.0',
    E 'pytest-forked': '1.6.0',
    E 'pytest-localserver': '0.8.1',
    E 'pytest-watch': '4.2.0',
    E 'pyyaml': '6.0.1',
    E 'referencing': '0.35.1',
    E 'requests': '2.32.3',
    E 'responses': '0.25.3',
    E 'rpds-py': '0.19.0',
    E 'sentry-sdk': '2.10.0',
    E 'setuptools': '71.0.3',
    E 'six': '1.16.0',
    E 'toml': '0.10.2',
    E - 'tomli': '2.0.1',
    E - 'typeguard': '4.3.0',
    E - 'typing-extensions': '4.12.2',
    E 'urllib3': '2.2.2',
    E 'watchdog': '4.0.1',
    E 'werkzeug': '3.0.3',
    E - 'wheel': '0.43.0',
    E - 'zipp': '3.19.2',
    E }

py3.12-gevent

  • Class name: tests.test_utils
    Test name: test_installed_modules

    tests/test_utils.py:538: in test_installed_modules
    assert installed_distributions == importlib_distributions
    E AssertionError: assert {'asttokens': '2.4.1',\n 'attrs': '23.2.0',\n 'certifi': '2024.7.4',\n 'charset-normalizer': '3.3.2',\n 'colorama': '0.4.6',\n 'coverage': '7.6.0',\n 'docopt': '0.6.2',\n 'executing': '2.0.1',\n 'gevent': '24.2.1',\n 'greenlet': '3.0.3',\n 'idna': '3.7',\n 'iniconfig': '2.0.0',\n 'jsonschema': '4.23.0',\n 'jsonschema-specifications': '2023.12.1',\n 'markupsafe': '2.1.5',\n 'packaging': '24.1',\n 'pip': '24.0',\n 'pluggy': '1.5.0',\n 'py': '1.11.0',\n 'pyrsistent': '0.20.0',\n 'pysocks': '1.7.1',\n 'pytest': '6.2.5',\n 'pytest-cov': '5.0.0',\n 'pytest-forked': '1.6.0',\n 'pytest-localserver': '0.8.1',\n 'pytest-watch': '4.2.0',\n 'pyyaml': '6.0.1',\n 'referencing': '0.35.1',\n 'requests': '2.32.3',\n 'responses': '0.25.3',\n 'rpds-py': '0.19.0',\n 'sentry-sdk': '2.10.0',\n 'setuptools': '71.0.3',\n 'six': '1.16.0',\n 'toml': '0.10.2',\n 'urllib3': '2.2.2',\n 'watchdog': '4.0.1',\n 'werkzeug': '3.0.3',\n 'zope-event': '5.0',\n 'zope-interface': '6.4.post2'} == {'asttokens': '2.4.1',\n 'attrs': '23.2.0',\n 'autocommand': '2.2.2',\n 'backports-tarfile': '1.2.0',\n 'certifi': '2024.7.4',\n 'charset-normalizer': '3.3.2',\n 'colorama': '0.4.6',\n 'coverage': '7.6.0',\n 'docopt': '0.6.2',\n 'executing': '2.0.1',\n 'gevent': '24.2.1',\n 'greenlet': '3.0.3',\n 'idna': '3.7',\n 'importlib-metadata': '8.0.0',\n 'importlib-resources': '6.4.0',\n 'inflect': '7.3.1',\n 'iniconfig': '2.0.0',\n 'jaraco-context': '5.3.0',\n 'jaraco-functools': '4.0.1',\n 'jaraco-text': '3.12.1',\n 'jsonschema': '4.23.0',\n 'jsonschema-specifications': '2023.12.1',\n 'markupsafe': '2.1.5',\n 'more-itertools': '10.3.0',\n 'ordered-set': '4.1.0',\n 'packaging': '24.1',\n 'pip': '24.0',\n 'platformdirs': '4.2.2',\n 'pluggy': '1.5.0',\n 'py': '1.11.0',\n 'pyrsistent': '0.20.0',\n 'pysocks': '1.7.1',\n 'pytest': '6.2.5',\n 'pytest-cov': '5.0.0',\n 'pytest-forked': '1.6.0',\n 'pytest-localserver': '0.8.1',\n 'pytest-watch': '4.2.0',\n 'pyyaml': '6.0.1',\n 'referencing': '0.35.1',\n 'requests': '2.32.3',\n 'responses': '0.25.3',\n 'rpds-py': '0.19.0',\n 'sentry-sdk': '2.10.0',\n 'setuptools': '71.0.3',\n 'six': '1.16.0',\n 'toml': '0.10.2',\n 'tomli': '2.0.1',\n 'typeguard': '4.3.0',\n 'typing-extensions': '4.12.2',\n 'urllib3': '2.2.2',\n 'watchdog': '4.0.1',\n 'werkzeug': '3.0.3',\n 'wheel': '0.43.0',\n 'zipp': '3.19.2',\n 'zope-event': '5.0',\n 'zope-interface': '6.4.post2'}
    E Common items:
    E {'asttokens': '2.4.1',
    E 'attrs': '23.2.0',
    E 'certifi': '2024.7.4',
    E 'charset-normalizer': '3.3.2',
    E 'colorama': '0.4.6',
    E 'coverage': '7.6.0',
    E 'docopt': '0.6.2',
    E 'executing': '2.0.1',
    E 'gevent': '24.2.1',
    E 'greenlet': '3.0.3',
    E 'idna': '3.7',
    E 'iniconfig': '2.0.0',
    E 'jsonschema': '4.23.0',
    E 'jsonschema-specifications': '2023.12.1',
    E 'markupsafe': '2.1.5',
    E 'packaging': '24.1',
    E 'pip': '24.0',
    E 'pluggy': '1.5.0',
    E 'py': '1.11.0',
    E 'pyrsistent': '0.20.0',
    E 'pysocks': '1.7.1',
    E 'pytest': '6.2.5',
    E 'pytest-cov': '5.0.0',
    E 'pytest-forked': '1.6.0',
    E 'pytest-localserver': '0.8.1',
    E 'pytest-watch': '4.2.0',
    E 'pyyaml': '6.0.1',
    E 'referencing': '0.35.1',
    E 'requests': '2.32.3',
    E 'responses': '0.25.3',
    E 'rpds-py': '0.19.0',
    E 'sentry-sdk': '2.10.0',
    E 'setuptools': '71.0.3',
    E 'six': '1.16.0',
    E 'toml': '0.10.2',
    E 'urllib3': '2.2.2',
    E 'watchdog': '4.0.1',
    E 'werkzeug': '3.0.3',
    E 'zope-event': '5.0',
    E 'zope-interface': '6.4.post2'}
    E Right contains 16 more items:
    E {'autocommand': '2.2.2',
    E 'backports-tarfile': '1.2.0',
    E 'importlib-metadata': '8.0.0',
    E 'importlib-resources': '6.4.0',
    E 'inflect': '7.3.1',
    E 'jaraco-context': '5.3.0',
    E 'jaraco-functools': '4.0.1',
    E 'jaraco-text': '3.12.1',
    E 'more-itertools': '10.3.0',
    E 'ordered-set': '4.1.0',
    E 'platformdirs': '4.2.2',
    E 'tomli': '2.0.1',
    E 'typeguard': '4.3.0',
    E 'typing-extensions': '4.12.2',
    E 'wheel': '0.43.0',
    E 'zipp': '3.19.2'}
    E Full diff:
    E {
    E 'asttokens': '2.4.1',
    E 'attrs': '23.2.0',
    E - 'autocommand': '2.2.2',
    E - 'backports-tarfile': '1.2.0',
    E 'certifi': '2024.7.4',
    E 'charset-normalizer': '3.3.2',
    E 'colorama': '0.4.6',
    E 'coverage': '7.6.0',
    E 'docopt': '0.6.2',
    E 'executing': '2.0.1',
    E 'gevent': '24.2.1',
    E 'greenlet': '3.0.3',
    E 'idna': '3.7',
    E - 'importlib-metadata': '8.0.0',
    E - 'importlib-resources': '6.4.0',
    E - 'inflect': '7.3.1',
    E 'iniconfig': '2.0.0',
    E - 'jaraco-context': '5.3.0',
    E - 'jaraco-functools': '4.0.1',
    E - 'jaraco-text': '3.12.1',
    E 'jsonschema': '4.23.0',
    E 'jsonschema-specifications': '2023.12.1',
    E 'markupsafe': '2.1.5',
    E - 'more-itertools': '10.3.0',
    E - 'ordered-set': '4.1.0',
    E 'packaging': '24.1',
    E 'pip': '24.0',
    E - 'platformdirs': '4.2.2',
    E 'pluggy': '1.5.0',
    E 'py': '1.11.0',
    E 'pyrsistent': '0.20.0',
    E 'pysocks': '1.7.1',
    E 'pytest': '6.2.5',
    E 'pytest-cov': '5.0.0',
    E 'pytest-forked': '1.6.0',
    E 'pytest-localserver': '0.8.1',
    E 'pytest-watch': '4.2.0',
    E 'pyyaml': '6.0.1',
    E 'referencing': '0.35.1',
    E 'requests': '2.32.3',
    E 'responses': '0.25.3',
    E 'rpds-py': '0.19.0',
    E 'sentry-sdk': '2.10.0',
    E 'setuptools': '71.0.3',
    E 'six': '1.16.0',
    E 'toml': '0.10.2',
    E - 'tomli': '2.0.1',
    E - 'typeguard': '4.3.0',
    E - 'typing-extensions': '4.12.2',
    E 'urllib3': '2.2.2',
    E 'watchdog': '4.0.1',
    E 'werkzeug': '3.0.3',
    E - 'wheel': '0.43.0',
    E - 'zipp': '3.19.2',
    E 'zope-event': '5.0',
    E 'zope-interface': '6.4.post2',
    E }

py3.13-common

  • Class name: tests.test_utils
    Test name: test_installed_modules

    tests/test_utils.py:538: in test_installed_modules
    assert installed_distributions == importlib_distributions
    E AssertionError: assert {'sentry-sdk': '2.10.0', 'rpds-py': '0.19.0', 'pysocks': '1.7.1', 'watchdog': '4.0.1', 'iniconfig': '2.0.0', 'pluggy': '1.5.0', 'executing': '2.0.1', 'idna': '3.7', 'referencing': '0.35.1', 'responses': '0.25.3', 'jsonschema': '4.23.0', 'py': '1.11.0', 'colorama': '0.4.6', 'certifi': '2024.7.4', 'packaging': '24.1', 'pytest-asyncio': '0.23.8', 'werkzeug': '3.0.3', 'pytest-localserver': '0.8.1', 'pyrsistent': '0.20.0', 'pytest-forked': '1.6.0', 'setuptools': '71.0.3', 'six': '1.16.0', 'markupsafe': '2.1.5', 'pytest': '8.2.2', 'pytest-cov': '5.0.0', 'charset-normalizer': '3.3.2', 'asttokens': '2.4.1', 'docopt': '0.6.2', 'coverage': '7.6.0', 'requests': '2.32.3', 'pip': '24.0', 'jsonschema-specifications': '2023.12.1', 'pyyaml': '6.0.1', 'urllib3': '2.2.2', 'pytest-watch': '4.2.0', 'attrs': '23.2.0'} == {'sentry-sdk': '2.10.0', 'rpds-py': '0.19.0', 'pysocks': '1.7.1', 'watchdog': '4.0.1', 'iniconfig': '2.0.0', 'pluggy': '1.5.0', 'executing': '2.0.1', 'idna': '3.7', 'referencing': '0.35.1', 'responses': '0.25.3', 'jsonschema': '4.23.0', 'py': '1.11.0', 'colorama': '0.4.6', 'certifi': '2024.7.4', 'packaging': '24.1', 'pytest-asyncio': '0.23.8', 'werkzeug': '3.0.3', 'pytest-localserver': '0.8.1', 'pyrsistent': '0.20.0', 'pytest-forked': '1.6.0', 'setuptools': '71.0.3', 'six': '1.16.0', 'markupsafe': '2.1.5', 'pytest': '8.2.2', 'pytest-cov': '5.0.0', 'charset-normalizer': '3.3.2', 'asttokens': '2.4.1', 'docopt': '0.6.2', 'coverage': '7.6.0', 'requests': '2.32.3', 'pip': '24.0', 'jsonschema-specifications': '2023.12.1', 'pyyaml': '6.0.1', 'urllib3': '2.2.2', 'pytest-watch': '4.2.0', 'attrs': '23.2.0', 'jaraco-context': '5.3.0', 'jaraco-functools': '4.0.1', 'typing-extensions': '4.12.2', 'backports-tarfile': '1.2.0', 'tomli': '2.0.1', 'inflect': '7.3.1', 'jaraco-text': '3.12.1', 'importlib-resources': '6.4.0', 'importlib-metadata': '8.0.0', 'more-itertools': '10.3.0', 'typeguard': '4.3.0', 'autocommand': '2.2.2', 'platformdirs': '4.2.2', 'ordered-set': '4.1.0', 'zipp': '3.19.2', 'wheel': '0.43.0'}
    E
    E Common items:
    E {'asttokens': '2.4.1',
    E 'attrs': '23.2.0',
    E 'certifi': '2024.7.4',
    E 'charset-normalizer': '3.3.2',
    E 'colorama': '0.4.6',
    E 'coverage': '7.6.0',
    E 'docopt': '0.6.2',
    E 'executing': '2.0.1',
    E 'idna': '3.7',
    E 'iniconfig': '2.0.0',
    E 'jsonschema': '4.23.0',
    E 'jsonschema-specifications': '2023.12.1',
    E 'markupsafe': '2.1.5',
    E 'packaging': '24.1',
    E 'pip': '24.0',
    E 'pluggy': '1.5.0',
    E 'py': '1.11.0',
    E 'pyrsistent': '0.20.0',
    E 'pysocks': '1.7.1',
    E 'pytest': '8.2.2',
    E 'pytest-asyncio': '0.23.8',
    E 'pytest-cov': '5.0.0',
    E 'pytest-forked': '1.6.0',
    E 'pytest-localserver': '0.8.1',
    E 'pytest-watch': '4.2.0',
    E 'pyyaml': '6.0.1',
    E 'referencing': '0.35.1',
    E 'requests': '2.32.3',
    E 'responses': '0.25.3',
    E 'rpds-py': '0.19.0',
    E 'sentry-sdk': '2.10.0',
    E 'setuptools': '71.0.3',
    E 'six': '1.16.0',
    E 'urllib3': '2.2.2',
    E 'watchdog': '4.0.1',
    E 'werkzeug': '3.0.3'}
    E Right contains 16 more items:
    E {'autocommand': '2.2.2',
    E 'backports-tarfile': '1.2.0',
    E 'importlib-metadata': '8.0.0',
    E 'importlib-resources': '6.4.0',
    E 'inflect': '7.3.1',
    E 'jaraco-context': '5.3.0',
    E 'jaraco-functools': '4.0.1',
    E 'jaraco-text': '3.12.1',
    E 'more-itertools': '10.3.0',
    E 'ordered-set': '4.1.0',
    E 'platformdirs': '4.2.2',
    E 'tomli': '2.0.1',
    E 'typeguard': '4.3.0',
    E 'typing-extensions': '4.12.2',
    E 'wheel': '0.43.0',
    E 'zipp': '3.19.2'}
    E
    E Full diff:
    E {
    E 'asttokens': '2.4.1',
    E 'attrs': '23.2.0',
    E - 'autocommand': '2.2.2',
    E - 'backports-tarfile': '1.2.0',
    E 'certifi': '2024.7.4',
    E 'charset-normalizer': '3.3.2',
    E 'colorama': '0.4.6',
    E 'coverage': '7.6.0',
    E 'docopt': '0.6.2',
    E 'executing': '2.0.1',
    E 'idna': '3.7',
    E - 'importlib-metadata': '8.0.0',
    E - 'importlib-resources': '6.4.0',
    E - 'inflect': '7.3.1',
    E 'iniconfig': '2.0.0',
    E - 'jaraco-context': '5.3.0',
    E - 'jaraco-functools': '4.0.1',
    E - 'jaraco-text': '3.12.1',
    E 'jsonschema': '4.23.0',
    E 'jsonschema-specifications': '2023.12.1',
    E 'markupsafe': '2.1.5',
    E - 'more-itertools': '10.3.0',
    E - 'ordered-set': '4.1.0',
    E 'packaging': '24.1',
    E 'pip': '24.0',
    E - 'platformdirs': '4.2.2',
    E 'pluggy': '1.5.0',
    E 'py': '1.11.0',
    E 'pyrsistent': '0.20.0',
    E 'pysocks': '1.7.1',
    E 'pytest': '8.2.2',
    E 'pytest-asyncio': '0.23.8',
    E 'pytest-cov': '5.0.0',
    E 'pytest-forked': '1.6.0',
    E 'pytest-localserver': '0.8.1',
    E 'pytest-watch': '4.2.0',
    E 'pyyaml': '6.0.1',
    E 'referencing': '0.35.1',
    E 'requests': '2.32.3',
    E 'responses': '0.25.3',
    E 'rpds-py': '0.19.0',
    E 'sentry-sdk': '2.10.0',
    E 'setuptools': '71.0.3',
    E 'six': '1.16.0',
    E - 'tomli': '2.0.1',
    E - 'typeguard': '4.3.0',
    E - 'typing-extensions': '4.12.2',
    E 'urllib3': '2.2.2',
    E 'watchdog': '4.0.1',
    E 'werkzeug': '3.0.3',
    E - 'wheel': '0.43.0',
    E - 'zipp': '3.19.2',
    E }

@sl0thentr0py
Copy link
Member

sl0thentr0py commented Jul 12, 2024

@szokeasaurusrex I was wondering earlier why you guys are using the import warnings module instead of just using our logger. Maybe that's the reason?

@szokeasaurusrex
Copy link
Member Author

@sl0thentr0py I wanted to make this be raised as a DeprecationWarning and I was unsure whether this is possible to do with the logger, which is why I originally used warnings.

However, I looked into warnings vs logging a bit further, and it seems we could emit a DeprecationWarning with logging, but based on this table, it seems that using warnings is the preferred option for this situation.

Do you think using the logger would make the warnings show up any differently?

@sl0thentr0py
Copy link
Member

so far everyone else has just used logger.warning for deprecations and related stuff and I think it's better to just keep using those? Either way, just try it out and see if it makes a difference.

@szokeasaurusrex
Copy link
Member Author

@sl0thentr0py after further investigation, it looks like the reason why I was not seeing the DeprecationWarning when running with Flask is because the Flask development server (flask run) runs the server with __name__ == "main" instead of __name__ == "__main__" but does not adjust the default warnings filter, which ignores DeprecationWarnings which originate from a module other than "__main__". The warnings are visible when running the server via an app.run call within the code, since in this case, __name__ == "__main__".

Furthermore, using the logger is not really an ideal solution here, since (at least from what I can tell) there is no way that I can suppress the logger message when we intentionally call a deprecated method. For example, when Hub.current calls the deprecated Hub.__init__, I want to suppress the Hub.__init__ deprecation warning since we already warn for Hub.current. Or, when we initialize the GLOBAL_HUB at module import, I want to make sure we suppress the deprecation warning, and I am unaware of how this would be possible with the logger.

So in short, I think using warnings is the best solution here. If ever the warnings are not showing, that is due to how the user code has configured their warnings filter, and this is outside our control.

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/hub-deprecation-warning branch from fee1fd7 to 556a1fd Compare July 16, 2024 08:21
`sentry_sdk.Hub` has been deprecated since Sentry SDK version 2.0.0 per our docs; however, we waited with adding deprecation warnings because the SDK itself was still using `Hub` APIs until recently.

Since we no longer use `Hub` APIs in the SDK (except in `Hub` APIs which are themselves deprecated), we can now start emitting deprecation warnings.

Closes #3265
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/hub-deprecation-warning branch from 556a1fd to da15b63 Compare July 16, 2024 09:05
@szokeasaurusrex
Copy link
Member Author

szokeasaurusrex commented Jul 17, 2024

Deprecation warnings can also be set to always be shown by setting the PYTHONDEVMODE environment variable to 1. Then, even when running a Flask app with flask run, you would see the deprecation warnings.

Seems like Python is intentionally designed to limit deprecation warnings from showing in logs at runtime, which makes sense because they are not actionable for end users of an application, only for developers.

@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/hub-deprecation-warning branch from 32d1874 to 1365d2b Compare July 17, 2024 10:10
@szokeasaurusrex szokeasaurusrex force-pushed the szokeasaurusrex/hub-deprecation-warning branch from 1365d2b to 69eb0f0 Compare July 17, 2024 12:36
@szokeasaurusrex szokeasaurusrex enabled auto-merge (squash) July 19, 2024 09:34
@szokeasaurusrex szokeasaurusrex merged commit 52e4e23 into master Jul 22, 2024
123 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/hub-deprecation-warning branch July 22, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emit deprecation warnings for Hub-based APIs
2 participants