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

chore(integrations): remove required_modules from integrations #11719

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mabdinur
Copy link
Contributor

@mabdinur mabdinur commented Dec 12, 2024

Since ddtrace v1.9.0 modules are only patched after import. There is no need to check whether a module exists in ddtrace.contrib.integration_name.__init__. If a library is not installed, it won't be patched.

require_modules should only be used when a ddtrace integration requires additional libraries (for example the web3 integration can only be enabled if web3_driver is also installed). Right now there is no integrations that have such a dependency.

With this change objects exposed in ddtrace.contrib.<integration_name>.__all__ will always be available. Accessing these objects will not raise an AttributeError and crash an application: ex.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Copy link
Contributor

github-actions bot commented Dec 12, 2024

CODEOWNERS have been resolved as:

ddtrace/contrib/aiobotocore/__init__.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/aiohttp/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/aiohttp_jinja2/__init__.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/aiomysql/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/aiopg/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/aioredis/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/algoliasearch/__init__.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/anthropic/__init__.py                                   @DataDog/ml-observability
ddtrace/contrib/aredis/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/asgi/__init__.py                                        @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/asyncio/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/asyncpg/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/avro/__init__.py                                        @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/boto/__init__.py                                        @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/botocore/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/bottle/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/cassandra/__init__.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/celery/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/cherrypy/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/consul/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/coverage/__init__.py                                    @DataDog/ci-app-libraries
ddtrace/contrib/django/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/dogpile_cache/__init__.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/dramatiq/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/falcon/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/fastapi/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/flask/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/flask_cache/__init__.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/freezegun/__init__.py                                   @DataDog/ci-app-libraries
ddtrace/contrib/futures/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/gevent/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/google_generativeai/__init__.py                         @DataDog/ml-observability
ddtrace/contrib/graphql/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/grpc/__init__.py                                        @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/httplib/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/httpx/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/jinja2/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/kafka/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/langchain/__init__.py                                   @DataDog/ml-observability
ddtrace/contrib/logbook/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/logging/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/loguru/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/mako/__init__.py                                        @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/mariadb/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/molten/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/mongoengine/__init__.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/mysql/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/mysqldb/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/openai/__init__.py                                      @DataDog/ml-observability
ddtrace/contrib/protobuf/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/pylibmc/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/pymemcache/__init__.py                                  @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/pymongo/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/pymysql/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/pynamodb/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/pyodbc/__init__.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/pyramid/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/redis/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/rediscluster/__init__.py                                @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/requests/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/sanic/__init__.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/selenium/__init__.py                                    @DataDog/ci-app-libraries
ddtrace/contrib/snowflake/__init__.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/sqlalchemy/__init__.py                                  @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/sqlite3/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/starlette/__init__.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/structlog/__init__.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/subprocess/__init__.py                                  @DataDog/asm-python
ddtrace/contrib/tornado/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/unittest/__init__.py                                    @DataDog/ci-app-libraries
ddtrace/contrib/urllib/__init__.py                                      @DataDog/asm-python
ddtrace/contrib/urllib3/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/vertexai/__init__.py                                    @DataDog/ml-observability
ddtrace/contrib/vertica/__init__.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/webbrowser/__init__.py                                  @DataDog/asm-python
ddtrace/contrib/yaaredis/__init__.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
docs/conf.py                                                            @DataDog/python-guild
pyproject.toml                                                          @DataDog/python-guild
templates/integration/__init__.py                                       @DataDog/apm-core-python

@mabdinur mabdinur force-pushed the munir/get-rid-of-require-modules-integrations branch 2 times, most recently from 2634736 to 2a29668 Compare December 13, 2024 16:08
@mabdinur mabdinur changed the title chore(integrations): chore(integrations): remove required_modules from some integrations Dec 13, 2024
@pr-commenter
Copy link

pr-commenter bot commented Dec 13, 2024

Benchmarks

Benchmark execution time: 2024-12-19 23:53:43

Comparing candidate commit 8b0def1 in PR branch munir/get-rid-of-require-modules-integrations with baseline commit 5cee25e in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 394 metrics, 2 unstable metrics.

@mabdinur mabdinur force-pushed the munir/get-rid-of-require-modules-integrations branch from 2a29668 to 7e13140 Compare December 16, 2024 16:42
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Dec 16, 2024

Datadog Report

Branch report: munir/get-rid-of-require-modules-integrations
Commit report: 85296e1
Test service: dd-trace-py

✅ 0 Failed, 55 Passed, 1413 Skipped, 1m 17.72s Total duration (32m 37.73s time saved)

@mabdinur mabdinur marked this pull request as ready for review December 19, 2024 23:13
@mabdinur mabdinur requested review from a team as code owners December 19, 2024 23:13
@mabdinur mabdinur requested a review from liashenko December 19, 2024 23:13
@mabdinur mabdinur enabled auto-merge (squash) December 20, 2024 16:36
@mabdinur mabdinur added the changelog/no-changelog A changelog entry is not required for this PR. label Dec 23, 2024
@mabdinur mabdinur changed the title chore(integrations): remove required_modules from some integrations chore(integrations): remove required_modules from integrations Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants