diff --git a/.github/workflows/test-integrations-ai.yml b/.github/workflows/test-integrations-ai.yml index b92ed9c61d..6653e989be 100644 --- a/.github/workflows/test-integrations-ai.yml +++ b/.github/workflows/test-integrations-ai.yml @@ -45,31 +45,39 @@ jobs: - name: Test anthropic latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-anthropic-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-anthropic-latest" - name: Test cohere latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-cohere-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-cohere-latest" - name: Test langchain latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-langchain-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-langchain-latest" - name: Test openai latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-openai-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-openai-latest" - name: Test huggingface_hub latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-huggingface_hub-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-huggingface_hub-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-ai-pinned: name: AI (pinned) timeout-minutes: 30 @@ -97,31 +105,39 @@ jobs: - name: Test anthropic pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-anthropic" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-anthropic" - name: Test cohere pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-cohere" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-cohere" - name: Test langchain pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-langchain" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-langchain" - name: Test openai pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-openai" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-openai" - name: Test huggingface_hub pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-huggingface_hub" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-huggingface_hub" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All AI tests passed needs: test-ai-pinned diff --git a/.github/workflows/test-integrations-aws-lambda.yml b/.github/workflows/test-integrations-aws-lambda.yml index 4bb2b11131..8f8cbc18f1 100644 --- a/.github/workflows/test-integrations-aws-lambda.yml +++ b/.github/workflows/test-integrations-aws-lambda.yml @@ -80,15 +80,23 @@ jobs: - name: Test aws_lambda pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-aws_lambda" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-aws_lambda" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All AWS Lambda tests passed needs: test-aws_lambda-pinned diff --git a/.github/workflows/test-integrations-cloud-computing.yml b/.github/workflows/test-integrations-cloud-computing.yml index ece522c437..e2bab93dc1 100644 --- a/.github/workflows/test-integrations-cloud-computing.yml +++ b/.github/workflows/test-integrations-cloud-computing.yml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7","3.10","3.11","3.12"] + python-version: ["3.8","3.11","3.12"] # python3.6 reached EOL and is no longer being supported on # new versions of hosted runners on Github Actions # ubuntu-20.04 is the last version that supported python3.6 @@ -45,27 +45,35 @@ jobs: - name: Test boto3 latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-boto3-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-boto3-latest" - name: Test chalice latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-chalice-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-chalice-latest" - name: Test cloud_resource_context latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-cloud_resource_context-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-cloud_resource_context-latest" - name: Test gcp latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-gcp-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-gcp-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-cloud_computing-pinned: name: Cloud Computing (pinned) timeout-minutes: 30 @@ -93,27 +101,35 @@ jobs: - name: Test boto3 pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-boto3" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-boto3" - name: Test chalice pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-chalice" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-chalice" - name: Test cloud_resource_context pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-cloud_resource_context" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-cloud_resource_context" - name: Test gcp pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gcp" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gcp" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Cloud Computing tests passed needs: test-cloud_computing-pinned diff --git a/.github/workflows/test-integrations-common.yml b/.github/workflows/test-integrations-common.yml index e611db9894..4b1b13f289 100644 --- a/.github/workflows/test-integrations-common.yml +++ b/.github/workflows/test-integrations-common.yml @@ -45,15 +45,23 @@ jobs: - name: Test common pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-common" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Common tests passed needs: test-common-pinned diff --git a/.github/workflows/test-integrations-data-processing.yml b/.github/workflows/test-integrations-data-processing.yml index be2ffc24e1..5d768bb7d0 100644 --- a/.github/workflows/test-integrations-data-processing.yml +++ b/.github/workflows/test-integrations-data-processing.yml @@ -47,35 +47,43 @@ jobs: - name: Test arq latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-arq-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-arq-latest" - name: Test beam latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-beam-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-beam-latest" - name: Test celery latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-celery-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-celery-latest" - name: Test huey latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-huey-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-huey-latest" - name: Test rq latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-rq-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-rq-latest" - name: Test spark latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-spark-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-spark-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-data_processing-pinned: name: Data Processing (pinned) timeout-minutes: 30 @@ -105,35 +113,43 @@ jobs: - name: Test arq pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-arq" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-arq" - name: Test beam pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-beam" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-beam" - name: Test celery pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-celery" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-celery" - name: Test huey pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-huey" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-huey" - name: Test rq pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-rq" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-rq" - name: Test spark pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-spark" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-spark" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Data Processing tests passed needs: test-data_processing-pinned diff --git a/.github/workflows/test-integrations-databases.yml b/.github/workflows/test-integrations-databases.yml index e03aa8aa60..d0ecc89c94 100644 --- a/.github/workflows/test-integrations-databases.yml +++ b/.github/workflows/test-integrations-databases.yml @@ -64,35 +64,43 @@ jobs: - name: Test asyncpg latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-asyncpg-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-asyncpg-latest" - name: Test clickhouse_driver latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-clickhouse_driver-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-clickhouse_driver-latest" - name: Test pymongo latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-pymongo-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-pymongo-latest" - name: Test redis latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-redis-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-redis-latest" - name: Test redis_py_cluster_legacy latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-redis_py_cluster_legacy-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-redis_py_cluster_legacy-latest" - name: Test sqlalchemy latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-sqlalchemy-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-sqlalchemy-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-databases-pinned: name: Databases (pinned) timeout-minutes: 30 @@ -139,35 +147,43 @@ jobs: - name: Test asyncpg pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-asyncpg" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-asyncpg" - name: Test clickhouse_driver pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-clickhouse_driver" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-clickhouse_driver" - name: Test pymongo pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-pymongo" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-pymongo" - name: Test redis pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-redis" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-redis" - name: Test redis_py_cluster_legacy pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-redis_py_cluster_legacy" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-redis_py_cluster_legacy" - name: Test sqlalchemy pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-sqlalchemy" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-sqlalchemy" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Databases tests passed needs: test-databases-pinned diff --git a/.github/workflows/test-integrations-graphql.yml b/.github/workflows/test-integrations-graphql.yml index e210280f9b..dd17bf51ec 100644 --- a/.github/workflows/test-integrations-graphql.yml +++ b/.github/workflows/test-integrations-graphql.yml @@ -45,27 +45,35 @@ jobs: - name: Test ariadne latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-ariadne-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-ariadne-latest" - name: Test gql latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-gql-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-gql-latest" - name: Test graphene latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-graphene-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-graphene-latest" - name: Test strawberry latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-strawberry-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-strawberry-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-graphql-pinned: name: GraphQL (pinned) timeout-minutes: 30 @@ -73,7 +81,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7","3.8","3.11"] + python-version: ["3.7","3.8","3.11","3.12"] # python3.6 reached EOL and is no longer being supported on # new versions of hosted runners on Github Actions # ubuntu-20.04 is the last version that supported python3.6 @@ -93,27 +101,35 @@ jobs: - name: Test ariadne pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-ariadne" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-ariadne" - name: Test gql pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gql" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gql" - name: Test graphene pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-graphene" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-graphene" - name: Test strawberry pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-strawberry" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-strawberry" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All GraphQL tests passed needs: test-graphql-pinned diff --git a/.github/workflows/test-integrations-miscellaneous.yml b/.github/workflows/test-integrations-miscellaneous.yml index 57ae62e071..982b8613c8 100644 --- a/.github/workflows/test-integrations-miscellaneous.yml +++ b/.github/workflows/test-integrations-miscellaneous.yml @@ -45,31 +45,39 @@ jobs: - name: Test loguru latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-loguru-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-loguru-latest" - name: Test opentelemetry latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-opentelemetry-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-opentelemetry-latest" - name: Test potel latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-potel-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-potel-latest" - name: Test pure_eval latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-pure_eval-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-pure_eval-latest" - name: Test trytond latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-trytond-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-trytond-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-miscellaneous-pinned: name: Miscellaneous (pinned) timeout-minutes: 30 @@ -97,31 +105,39 @@ jobs: - name: Test loguru pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-loguru" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-loguru" - name: Test opentelemetry pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-opentelemetry" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-opentelemetry" - name: Test potel pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-potel" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-potel" - name: Test pure_eval pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-pure_eval" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-pure_eval" - name: Test trytond pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-trytond" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-trytond" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Miscellaneous tests passed needs: test-miscellaneous-pinned diff --git a/.github/workflows/test-integrations-networking.yml b/.github/workflows/test-integrations-networking.yml index e5c26cc2a3..ac36574425 100644 --- a/.github/workflows/test-integrations-networking.yml +++ b/.github/workflows/test-integrations-networking.yml @@ -45,27 +45,35 @@ jobs: - name: Test gevent latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-gevent-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-gevent-latest" - name: Test grpc latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-grpc-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-grpc-latest" - name: Test httpx latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-httpx-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-httpx-latest" - name: Test requests latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-requests-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-requests-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-networking-pinned: name: Networking (pinned) timeout-minutes: 30 @@ -93,27 +101,35 @@ jobs: - name: Test gevent pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gevent" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-gevent" - name: Test grpc pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-grpc" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-grpc" - name: Test httpx pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-httpx" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-httpx" - name: Test requests pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-requests" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-requests" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Networking tests passed needs: test-networking-pinned diff --git a/.github/workflows/test-integrations-web-frameworks-1.yml b/.github/workflows/test-integrations-web-frameworks-1.yml index 00634b920d..743a97cfa0 100644 --- a/.github/workflows/test-integrations-web-frameworks-1.yml +++ b/.github/workflows/test-integrations-web-frameworks-1.yml @@ -63,27 +63,35 @@ jobs: - name: Test django latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-django-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-django-latest" - name: Test flask latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-flask-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-flask-latest" - name: Test starlette latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-starlette-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-starlette-latest" - name: Test fastapi latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-fastapi-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-fastapi-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-web_frameworks_1-pinned: name: Web Frameworks 1 (pinned) timeout-minutes: 30 @@ -129,27 +137,35 @@ jobs: - name: Test django pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-django" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-django" - name: Test flask pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-flask" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-flask" - name: Test starlette pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-starlette" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-starlette" - name: Test fastapi pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-fastapi" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-fastapi" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Web Frameworks 1 tests passed needs: test-web_frameworks_1-pinned diff --git a/.github/workflows/test-integrations-web-frameworks-2.yml b/.github/workflows/test-integrations-web-frameworks-2.yml index d6c593e2c7..09d179271a 100644 --- a/.github/workflows/test-integrations-web-frameworks-2.yml +++ b/.github/workflows/test-integrations-web-frameworks-2.yml @@ -45,47 +45,55 @@ jobs: - name: Test aiohttp latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-aiohttp-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-aiohttp-latest" - name: Test asgi latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-asgi-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-asgi-latest" - name: Test bottle latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-bottle-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-bottle-latest" - name: Test falcon latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-falcon-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-falcon-latest" - name: Test pyramid latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-pyramid-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-pyramid-latest" - name: Test quart latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-quart-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-quart-latest" - name: Test sanic latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-sanic-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-sanic-latest" - name: Test starlite latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-starlite-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-starlite-latest" - name: Test tornado latest run: | set -x # print commands that are executed - ./scripts/runtox.sh "py${{ matrix.python-version }}-tornado-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "py${{ matrix.python-version }}-tornado-latest" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} test-web_frameworks_2-pinned: name: Web Frameworks 2 (pinned) timeout-minutes: 30 @@ -113,47 +121,55 @@ jobs: - name: Test aiohttp pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-aiohttp" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-aiohttp" - name: Test asgi pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-asgi" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-asgi" - name: Test bottle pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-bottle" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-bottle" - name: Test falcon pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-falcon" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-falcon" - name: Test pyramid pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-pyramid" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-pyramid" - name: Test quart pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-quart" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-quart" - name: Test sanic pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-sanic" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-sanic" - name: Test starlite pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-starlite" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-starlite" - name: Test tornado pinned run: | set -x # print commands that are executed - ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-tornado" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-tornado" - name: Generate coverage XML + if: ${{ !cancelled() }} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage.xml + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} check_required_tests: name: All Web Frameworks 2 tests passed needs: test-web_frameworks_2-pinned diff --git a/.gitignore b/.gitignore index 9dcdf030d3..cfd8070197 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.pid .python-version .coverage* +.junitxml* .DS_Store .tox pip-log.txt diff --git a/codecov.yml b/codecov.yml index 6e4467b675..086157690e 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,4 +1,3 @@ -comment: false coverage: status: project: @@ -6,8 +5,23 @@ coverage: target: auto # auto compares coverage to the previous base commit threshold: 10% # this allows a 10% drop from the previous base commit coverage informational: true + ignore: - "tests" - "sentry_sdk/_types.py" + +# Read more here: https://docs.codecov.com/docs/pull-request-comments +comment: + after_n_builds: 99 + layout: 'diff, files' + # Update, if comment exists. Otherwise post new. + behavior: default + # Comments will only post when coverage changes. Furthermore, if a comment + # already exists, and a newer commit results in no coverage change for the + # entire pull, the comment will be deleted. + require_changes: true + require_base: true # must have a base report to post + require_head: true # must have a head report to post + github_checks: annotations: false \ No newline at end of file diff --git a/pytest.ini b/pytest.ini index f736c30496..c3f7a6b1e8 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,14 +1,11 @@ [pytest] -DJANGO_SETTINGS_MODULE = tests.integrations.django.myapp.settings -addopts = --tb=short -markers = - tests_internal_exceptions: Handle internal exceptions just as the SDK does, to test it. (Otherwise internal exceptions are recorded and reraised.) - only: A temporary marker, to make pytest only run the tests with the mark, similar to jests `it.only`. To use, run `pytest -v -m only`. +addopts = -vvv -rfEs -s --durations=5 --cov=tests --cov=sentry_sdk --cov-branch --cov-report= --tb=short --junitxml=.junitxml-{envname} asyncio_mode = strict +markers = + tests_internal_exceptions: Handle internal exceptions just as the SDK does, to test it. (Otherwise internal exceptions are recorded and reraised.) [pytest-watch] -; Enable this to drop into pdb on errors -; pdb = True - verbose = True nobeep = True +; Enable this to drop into pdb on errors +; pdb = True diff --git a/scripts/split-tox-gh-actions/templates/test_group.jinja b/scripts/split-tox-gh-actions/templates/test_group.jinja index 823a3b9b01..dcf3a3734b 100644 --- a/scripts/split-tox-gh-actions/templates/test_group.jinja +++ b/scripts/split-tox-gh-actions/templates/test_group.jinja @@ -71,18 +71,27 @@ run: | set -x # print commands that are executed {% if category == "pinned" %} - ./scripts/runtox.sh --exclude-latest "{% raw %}py${{ matrix.python-version }}{% endraw %}-{{ framework }}" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh --exclude-latest "{% raw %}py${{ matrix.python-version }}{% endraw %}-{{ framework }}" {% elif category == "latest" %} - ./scripts/runtox.sh "{% raw %}py${{ matrix.python-version }}{% endraw %}-{{ framework }}-latest" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch + ./scripts/runtox.sh "{% raw %}py${{ matrix.python-version }}{% endraw %}-{{ framework }}-latest" {% endif %} {% endfor %} - name: Generate coverage XML + if: {% raw %}${{ !cancelled() }}{% endraw %} run: | coverage combine .coverage* coverage xml -i - - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + if: {% raw %}${{ !cancelled() }}{% endraw %} + uses: codecov/codecov-action@v4.5.0 with: token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} files: coverage.xml + + - name: Upload test results to Codecov + if: {% raw %}${{ !cancelled() }}{% endraw %} + uses: codecov/test-results-action@v1 + with: + token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} \ No newline at end of file diff --git a/sentry_sdk/integrations/_asgi_common.py b/sentry_sdk/integrations/_asgi_common.py index 17a88523e5..a099b42e32 100644 --- a/sentry_sdk/integrations/_asgi_common.py +++ b/sentry_sdk/integrations/_asgi_common.py @@ -1,6 +1,6 @@ import urllib -from sentry_sdk.hub import _should_send_default_pii +from sentry_sdk.scope import should_send_default_pii from sentry_sdk.integrations._wsgi_common import _filter_headers from sentry_sdk._types import TYPE_CHECKING @@ -101,7 +101,7 @@ def _get_request_data(asgi_scope): ) client = asgi_scope.get("client") - if client and _should_send_default_pii(): + if client and should_send_default_pii(): request_data["env"] = {"REMOTE_ADDR": _get_ip(asgi_scope)} return request_data diff --git a/sentry_sdk/integrations/gnu_backtrace.py b/sentry_sdk/integrations/gnu_backtrace.py index f8321a6cd7..32d2afafbf 100644 --- a/sentry_sdk/integrations/gnu_backtrace.py +++ b/sentry_sdk/integrations/gnu_backtrace.py @@ -1,6 +1,6 @@ import re -from sentry_sdk.hub import Hub +import sentry_sdk from sentry_sdk.integrations import Integration from sentry_sdk.scope import add_global_event_processor from sentry_sdk.utils import capture_internal_exceptions @@ -49,7 +49,7 @@ def process_gnu_backtrace(event, hint): def _process_gnu_backtrace(event, hint): # type: (Event, dict[str, Any]) -> Event - if Hub.current.get_integration(GnuBacktraceIntegration) is None: + if sentry_sdk.get_client().get_integration(GnuBacktraceIntegration) is None: return event exc_info = hint.get("exc_info", None) diff --git a/sentry_sdk/integrations/wsgi.py b/sentry_sdk/integrations/wsgi.py index f946844de5..117582ea2f 100644 --- a/sentry_sdk/integrations/wsgi.py +++ b/sentry_sdk/integrations/wsgi.py @@ -6,7 +6,7 @@ from sentry_sdk._werkzeug import get_host, _get_headers from sentry_sdk.api import continue_trace from sentry_sdk.consts import OP -from sentry_sdk.hub import _should_send_default_pii +from sentry_sdk.scope import should_send_default_pii from sentry_sdk.integrations._wsgi_common import _filter_headers from sentry_sdk.sessions import ( auto_session_tracking_scope as auto_session_tracking, @@ -143,7 +143,7 @@ def _get_environ(environ): capture (server name, port and remote addr if pii is enabled). """ keys = ["SERVER_NAME", "SERVER_PORT"] - if _should_send_default_pii(): + if should_send_default_pii(): # make debugging of proxy setup easier. Proxy headers are # in headers. keys += ["REMOTE_ADDR"] @@ -266,7 +266,7 @@ def event_processor(event, hint): # if the code below fails halfway through we at least have some data request_info = event.setdefault("request", {}) - if _should_send_default_pii(): + if should_send_default_pii(): user_info = event.setdefault("user", {}) if client_ip: user_info.setdefault("ip_address", client_ip) diff --git a/sentry_sdk/metrics.py b/sentry_sdk/metrics.py index f750e834a2..dfc1d89734 100644 --- a/sentry_sdk/metrics.py +++ b/sentry_sdk/metrics.py @@ -720,20 +720,18 @@ def _tags_to_dict(tags): def _get_aggregator(): # type: () -> Optional[MetricsAggregator] - hub = sentry_sdk.Hub.current - client = hub.client + client = sentry_sdk.get_client() return ( client.metrics_aggregator - if client is not None and client.metrics_aggregator is not None + if client.is_active() and client.metrics_aggregator is not None else None ) def _get_aggregator_and_update_tags(key, value, unit, tags): # type: (str, Optional[MetricValue], MeasurementUnit, Optional[MetricTags]) -> Tuple[Optional[MetricsAggregator], Optional[LocalAggregator], Optional[MetricTags]] - hub = sentry_sdk.Hub.current - client = hub.client - if client is None or client.metrics_aggregator is None: + client = sentry_sdk.get_client() + if not client.is_active() or client.metrics_aggregator is None: return None, None, tags updated_tags = dict(tags or ()) # type: Dict[str, MetricTagValue] diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index 1f3de09620..117d52c81f 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -6,7 +6,7 @@ from celery import Celery, VERSION from celery.bin import worker -from sentry_sdk import Hub, configure_scope, start_transaction, get_current_span +from sentry_sdk import configure_scope, start_transaction, get_current_span from sentry_sdk.integrations.celery import ( CeleryIntegration, _wrap_apply_async, @@ -60,9 +60,6 @@ def inner( celery.conf.result_backend = "redis://127.0.0.1:6379" celery.conf.task_always_eager = False - Hub.main.bind_client(Hub.current.client) - request.addfinalizer(lambda: Hub.main.bind_client(None)) - # Once we drop celery 3 we can use the celery_worker fixture if VERSION < (5,): worker_fn = worker.worker(app=celery).run @@ -302,45 +299,6 @@ def dummy_task(x, y): assert not events -@pytest.mark.skip( - reason="This tests for a broken rerun in Celery 3. We don't support Celery 3 anymore." -) -def test_broken_prerun(init_celery, connect_signal): - from celery.signals import task_prerun - - stack_lengths = [] - - def crash(*args, **kwargs): - # scope should exist in prerun - stack_lengths.append(len(Hub.current._stack)) - 1 / 0 - - # Order here is important to reproduce the bug: In Celery 3, a crashing - # prerun would prevent other preruns from running. - - connect_signal(task_prerun, crash) - celery = init_celery() - - assert len(Hub.current._stack) == 1 - - @celery.task(name="dummy_task") - def dummy_task(x, y): - stack_lengths.append(len(Hub.current._stack)) - return x / y - - if VERSION >= (4,): - dummy_task.delay(2, 2) - else: - with pytest.raises(ZeroDivisionError): - dummy_task.delay(2, 2) - - assert len(Hub.current._stack) == 1 - if VERSION < (4,): - assert stack_lengths == [2] - else: - assert stack_lengths == [2, 2] - - @pytest.mark.xfail( (4, 2, 0) <= VERSION < (4, 4, 3), strict=True, diff --git a/tests/integrations/conftest.py b/tests/integrations/conftest.py index 9f30ccf076..560155e2b5 100644 --- a/tests/integrations/conftest.py +++ b/tests/integrations/conftest.py @@ -10,6 +10,9 @@ def inner(): old_capture_event_scope = sentry_sdk.Scope.capture_event def capture_event_hub(self, event, hint=None, scope=None): + """ + Can be removed when we remove push_scope and the Hub from the SDK. + """ if hint: if "exc_info" in hint: error = hint["exc_info"][1] diff --git a/tests/test_basics.py b/tests/test_basics.py index 8727e27f35..5407049417 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -8,6 +8,7 @@ from tests.conftest import patch_start_tracing_child +import sentry_sdk from sentry_sdk import ( push_scope, configure_scope, @@ -220,7 +221,7 @@ def before_breadcrumb(crumb, hint): events = capture_events() monkeypatch.setattr( - Hub.current.client.transport, "record_lost_event", record_lost_event + sentry_sdk.get_client().transport, "record_lost_event", record_lost_event ) def do_this(): @@ -269,7 +270,7 @@ def test_option_enable_tracing( updated_traces_sample_rate, ): sentry_init(enable_tracing=enable_tracing, traces_sample_rate=traces_sample_rate) - options = Hub.current.client.options + options = sentry_sdk.get_client().options assert has_tracing_enabled(options) is tracing_enabled assert options["traces_sample_rate"] == updated_traces_sample_rate @@ -311,6 +312,9 @@ def test_push_scope(sentry_init, capture_events): def test_push_scope_null_client(sentry_init, capture_events): + """ + This test can be removed when we remove push_scope and the Hub from the SDK. + """ sentry_init() events = capture_events() @@ -331,6 +335,9 @@ def test_push_scope_null_client(sentry_init, capture_events): ) @pytest.mark.parametrize("null_client", (True, False)) def test_push_scope_callback(sentry_init, null_client, capture_events): + """ + This test can be removed when we remove push_scope and the Hub from the SDK. + """ sentry_init() if null_client: @@ -439,6 +446,9 @@ def test_integration_scoping(sentry_init, capture_events): reason="This test is not valid anymore, because with the new Scopes calling bind_client on the Hub sets the client on the global scope. This test should be removed once the Hub is removed" ) def test_client_initialized_within_scope(sentry_init, caplog): + """ + This test can be removed when we remove push_scope and the Hub from the SDK. + """ caplog.set_level(logging.WARNING) sentry_init() @@ -455,6 +465,9 @@ def test_client_initialized_within_scope(sentry_init, caplog): reason="This test is not valid anymore, because with the new Scopes the push_scope just returns the isolation scope. This test should be removed once the Hub is removed" ) def test_scope_leaks_cleaned_up(sentry_init, caplog): + """ + This test can be removed when we remove push_scope and the Hub from the SDK. + """ caplog.set_level(logging.WARNING) sentry_init() @@ -475,6 +488,9 @@ def test_scope_leaks_cleaned_up(sentry_init, caplog): reason="This test is not valid anymore, because with the new Scopes there is not pushing and popping of scopes. This test should be removed once the Hub is removed" ) def test_scope_popped_too_soon(sentry_init, caplog): + """ + This test can be removed when we remove push_scope and the Hub from the SDK. + """ caplog.set_level(logging.ERROR) sentry_init() @@ -719,7 +735,7 @@ def test_functions_to_trace_with_class(sentry_init, capture_events): def test_redis_disabled_when_not_installed(sentry_init): sentry_init() - assert Hub.current.get_integration(RedisIntegration) is None + assert sentry_sdk.get_client().get_integration(RedisIntegration) is None def test_multiple_setup_integrations_calls(): diff --git a/tests/test_client.py b/tests/test_client.py index 0464f32b5e..a2fea56202 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -9,6 +9,7 @@ import pytest +import sentry_sdk from sentry_sdk import ( Hub, Client, @@ -563,7 +564,11 @@ def capture_envelope(self, envelope): def test_configure_scope_available(sentry_init, request, monkeypatch): - # Test that scope is configured if client is configured + """ + Test that scope is configured if client is configured + + This test can be removed once configure_scope and the Hub are removed. + """ sentry_init() with configure_scope() as scope: @@ -585,7 +590,9 @@ def callback(scope): def test_client_debug_option_enabled(sentry_init, caplog): sentry_init(debug=True) - Hub.current._capture_internal_exception((ValueError, ValueError("OK"), None)) + sentry_sdk.Scope.get_isolation_scope()._capture_internal_exception( + (ValueError, ValueError("OK"), None) + ) assert "OK" in caplog.text @@ -595,7 +602,9 @@ def test_client_debug_option_disabled(with_client, sentry_init, caplog): if with_client: sentry_init() - Hub.current._capture_internal_exception((ValueError, ValueError("OK"), None)) + sentry_sdk.Scope.get_isolation_scope()._capture_internal_exception( + (ValueError, ValueError("OK"), None) + ) assert "OK" not in caplog.text @@ -949,7 +958,7 @@ def test_init_string_types(dsn, sentry_init): # extra code sentry_init(dsn) assert ( - Hub.current.client.dsn + sentry_sdk.get_client().dsn == "http://894b7d594095440f8dfea9b300e6f572@localhost:8000/2" ) @@ -1047,7 +1056,7 @@ def test_debug_option( else: sentry_init(debug=client_option) - Hub.current._capture_internal_exception( + sentry_sdk.Scope.get_isolation_scope()._capture_internal_exception( (ValueError, ValueError("something is wrong"), None) ) if debug_output_expected: diff --git a/tests/test_crons.py b/tests/test_crons.py index 2b4ed3cab2..493cc44272 100644 --- a/tests/test_crons.py +++ b/tests/test_crons.py @@ -4,7 +4,7 @@ import pytest import sentry_sdk -from sentry_sdk import Hub, configure_scope, set_level + from sentry_sdk.crons import capture_checkin @@ -322,6 +322,8 @@ def test_scope_data_in_checkin(sentry_init, capture_envelopes): # Optional event keys "release", "environment", + "server_name", + "sdk", # Mandatory check-in specific keys "check_in_id", "monitor_slug", @@ -330,42 +332,33 @@ def test_scope_data_in_checkin(sentry_init, capture_envelopes): "duration", "monitor_config", "contexts", # an event processor adds this - # TODO: These fields need to be checked if valid for checkin: - "_meta", - "tags", - "extra", # an event processor adds this - "modules", - "server_name", - "sdk", ] - hub = Hub.current - with configure_scope() as scope: - # Add some data to the scope - set_level("warning") - hub.add_breadcrumb(message="test breadcrumb") - scope.set_tag("test_tag", "test_value") - scope.set_extra("test_extra", "test_value") - scope.set_context("test_context", {"test_key": "test_value"}) + # Add some data to the scope + sentry_sdk.add_breadcrumb(message="test breadcrumb") + sentry_sdk.set_context("test_context", {"test_key": "test_value"}) + sentry_sdk.set_extra("test_extra", "test_value") + sentry_sdk.set_level("warning") + sentry_sdk.set_tag("test_tag", "test_value") - capture_checkin( - monitor_slug="abc123", - check_in_id="112233", - status="ok", - duration=123, - ) + capture_checkin( + monitor_slug="abc123", + check_in_id="112233", + status="ok", + duration=123, + ) - (envelope,) = envelopes - check_in_event = envelope.items[0].payload.json + (envelope,) = envelopes + check_in_event = envelope.items[0].payload.json - invalid_keys = [] - for key in check_in_event.keys(): - if key not in valid_keys: - invalid_keys.append(key) + invalid_keys = [] + for key in check_in_event.keys(): + if key not in valid_keys: + invalid_keys.append(key) - assert len(invalid_keys) == 0, "Unexpected keys found in checkin: {}".format( - invalid_keys - ) + assert len(invalid_keys) == 0, "Unexpected keys found in checkin: {}".format( + invalid_keys + ) @pytest.mark.asyncio diff --git a/tests/test_metrics.py b/tests/test_metrics.py index c0793e8015..a29a18b0cf 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -5,7 +5,8 @@ import pytest -from sentry_sdk import Hub, Scope, metrics, start_transaction +import sentry_sdk +from sentry_sdk import Scope, metrics from sentry_sdk.tracing import TRANSACTION_SOURCE_ROUTE from sentry_sdk.envelope import parse_json @@ -66,7 +67,7 @@ def test_increment(sentry_init, capture_envelopes, maybe_monkeypatched_threading metrics.increment("foobar", 1.0, tags={"foo": "bar", "blub": "blah"}, timestamp=ts) # python specific alias metrics.incr("foobar", 2.0, tags={"foo": "bar", "blub": "blah"}, timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes statsd_item, meta_item = envelope.items @@ -119,7 +120,7 @@ def test_timing(sentry_init, capture_envelopes, maybe_monkeypatched_threading): with metrics.timing("whatever", tags={"blub": "blah"}, timestamp=ts): time.sleep(0.1) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes statsd_item, meta_item = envelope.items @@ -191,7 +192,7 @@ def amazing_nano(): assert amazing() == 42 assert amazing_nano() == 23 - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes statsd_item, meta_item = envelope.items @@ -278,7 +279,7 @@ def test_timing_basic(sentry_init, capture_envelopes, maybe_monkeypatched_thread metrics.timing("timing", 2.0, tags={"a": "b"}, timestamp=ts) metrics.timing("timing", 2.0, tags={"a": "b"}, timestamp=ts) metrics.timing("timing", 3.0, tags={"a": "b"}, timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes statsd_item, meta_item = envelope.items @@ -333,7 +334,7 @@ def test_distribution(sentry_init, capture_envelopes, maybe_monkeypatched_thread metrics.distribution("dist", 2.0, tags={"a": "b"}, timestamp=ts) metrics.distribution("dist", 2.0, tags={"a": "b"}, timestamp=ts) metrics.distribution("dist", 3.0, tags={"a": "b"}, timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes statsd_item, meta_item = envelope.items @@ -395,7 +396,7 @@ def test_set(sentry_init, capture_envelopes, maybe_monkeypatched_threading): metrics.set("my-set", "peter", tags={"magic": "puff"}, timestamp=ts) metrics.set("my-set", "paul", tags={"magic": "puff"}, timestamp=ts) metrics.set("my-set", "mary", tags={"magic": "puff"}, timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes statsd_item, meta_item = envelope.items @@ -449,7 +450,7 @@ def test_gauge(sentry_init, capture_envelopes, maybe_monkeypatched_threading): metrics.gauge("my-gauge", 10.0, tags={"x": "y"}, timestamp=ts) metrics.gauge("my-gauge", 20.0, tags={"x": "y"}, timestamp=ts) metrics.gauge("my-gauge", 30.0, tags={"x": "y"}, timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes @@ -487,7 +488,7 @@ def test_multiple(sentry_init, capture_envelopes): metrics.increment("counter-1", 1.0, timestamp=ts) metrics.increment("counter-2", 1.0, timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes @@ -544,7 +545,7 @@ def test_transaction_name( metrics.distribution("dist", 2.0, tags={"a": "b"}, timestamp=ts) metrics.distribution("dist", 3.0, tags={"a": "b"}, timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes @@ -578,7 +579,7 @@ def test_metric_summaries( ts = time.time() envelopes = capture_envelopes() - with start_transaction( + with sentry_sdk.start_transaction( op="stuff", name="/foo", source=TRANSACTION_SOURCE_ROUTE ) as transaction: metrics.increment("root-counter", timestamp=ts) @@ -586,7 +587,7 @@ def test_metric_summaries( for x in range(10): metrics.distribution("my-dist", float(x), timestamp=ts) - Hub.current.flush() + sentry_sdk.flush() (transaction, envelope) = envelopes @@ -706,7 +707,7 @@ def test_metric_name_normalization( metrics.distribution(metric_name, 1.0, unit=metric_unit) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes @@ -750,7 +751,7 @@ def test_metric_tag_normalization( metrics.distribution("a", 1.0, tags=metric_tag) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes @@ -797,7 +798,7 @@ def before_emit(key, value, unit, tags): metrics.increment("another-removed-metric", 47) metrics.increment("yet-another-removed-metric", 1.0, unit="unsupported") metrics.increment("actual-metric", 1.0) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes @@ -829,10 +830,10 @@ def test_aggregator_flush( envelopes = capture_envelopes() metrics.increment("a-metric", 1.0) - Hub.current.flush() + sentry_sdk.flush() assert len(envelopes) == 1 - assert Hub.current.client.metrics_aggregator.buckets == {} + assert sentry_sdk.get_client().metrics_aggregator.buckets == {} @minimum_python_37_with_gevent @@ -857,7 +858,7 @@ def test_tag_serialization( "more-than-one": [1, "zwei", "3.0", None], }, ) - Hub.current.flush() + sentry_sdk.flush() (envelope,) = envelopes @@ -887,7 +888,7 @@ def test_flush_recursion_protection( _experiments={"enable_metrics": True}, ) envelopes = capture_envelopes() - test_client = Hub.current.client + test_client = sentry_sdk.get_client() real_capture_envelope = test_client.transport.capture_envelope @@ -900,8 +901,8 @@ def bad_capture_envelope(*args, **kwargs): metrics.increment("counter") # flush twice to see the inner metric - Hub.current.flush() - Hub.current.flush() + sentry_sdk.flush() + sentry_sdk.flush() (envelope,) = envelopes m = parse_metrics(envelope.items[0].payload.get_bytes()) @@ -921,7 +922,7 @@ def test_flush_recursion_protection_background_flush( _experiments={"enable_metrics": True}, ) envelopes = capture_envelopes() - test_client = Hub.current.client + test_client = sentry_sdk.get_client() real_capture_envelope = test_client.transport.capture_envelope @@ -934,7 +935,7 @@ def bad_capture_envelope(*args, **kwargs): metrics.increment("counter") # flush via sleep and flag - Hub.current.client.metrics_aggregator._force_flush = True + sentry_sdk.get_client().metrics_aggregator._force_flush = True time.sleep(0.5) (envelope,) = envelopes @@ -963,7 +964,7 @@ def test_disable_metrics_for_old_python_with_gevent( metrics.incr("counter") - Hub.current.flush() + sentry_sdk.flush() - assert Hub.current.client.metrics_aggregator is None + assert sentry_sdk.get_client().metrics_aggregator is None assert not envelopes diff --git a/tests/test_monitor.py b/tests/test_monitor.py index 3822437df3..61b71f06bd 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -1,7 +1,7 @@ import random from unittest import mock -from sentry_sdk import Hub, start_transaction +import sentry_sdk from sentry_sdk.transport import Transport @@ -24,13 +24,13 @@ def test_no_monitor_if_disabled(sentry_init): enable_backpressure_handling=False, ) - assert Hub.current.client.monitor is None + assert sentry_sdk.get_client().monitor is None def test_monitor_if_enabled(sentry_init): sentry_init(transport=HealthyTestTransport()) - monitor = Hub.current.client.monitor + monitor = sentry_sdk.get_client().monitor assert monitor is not None assert monitor._thread is None @@ -43,7 +43,7 @@ def test_monitor_if_enabled(sentry_init): def test_monitor_unhealthy(sentry_init): sentry_init(transport=UnhealthyTestTransport()) - monitor = Hub.current.client.monitor + monitor = sentry_sdk.get_client().monitor monitor.interval = 0.1 assert monitor.is_healthy() is True @@ -64,7 +64,7 @@ def test_transaction_uses_downsampled_rate( reports = capture_client_reports() - monitor = Hub.current.client.monitor + monitor = sentry_sdk.get_client().monitor monitor.interval = 0.1 # make sure rng doesn't sample @@ -75,7 +75,7 @@ def test_transaction_uses_downsampled_rate( assert monitor.is_healthy() is False assert monitor.downsample_factor == 1 - with start_transaction(name="foobar") as transaction: + with sentry_sdk.start_transaction(name="foobar") as transaction: assert transaction.sampled is False assert transaction.sample_rate == 0.5 @@ -90,7 +90,7 @@ def test_monitor_no_thread_on_shutdown_no_errors(sentry_init): "threading.Thread.start", side_effect=RuntimeError("can't create new thread at interpreter shutdown"), ): - monitor = Hub.current.client.monitor + monitor = sentry_sdk.get_client().monitor assert monitor is not None assert monitor._thread is None monitor.run() diff --git a/tests/test_sessions.py b/tests/test_sessions.py index 91ce9cc58b..989bfeadd1 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -1,7 +1,6 @@ from unittest import mock import sentry_sdk -from sentry_sdk import Hub from sentry_sdk.sessions import auto_session_tracking @@ -15,17 +14,17 @@ def test_basic(sentry_init, capture_envelopes): sentry_init(release="fun-release", environment="not-fun-env") envelopes = capture_envelopes() - hub = Hub.current - hub.start_session() + sentry_sdk.Scope.get_isolation_scope().start_session() try: - with hub.configure_scope() as scope: - scope.set_user({"id": "42"}) - raise Exception("all is wrong") + scope = sentry_sdk.Scope.get_current_scope() + scope.set_user({"id": "42"}) + raise Exception("all is wrong") except Exception: - hub.capture_exception() - hub.end_session() - hub.flush() + sentry_sdk.capture_exception() + + sentry_sdk.Scope.get_isolation_scope().end_session() + sentry_sdk.flush() assert len(envelopes) == 2 assert envelopes[0].get_event() is not None @@ -51,23 +50,20 @@ def test_aggregates(sentry_init, capture_envelopes): ) envelopes = capture_envelopes() - hub = Hub.current - with auto_session_tracking(session_mode="request"): with sentry_sdk.push_scope(): try: - with sentry_sdk.configure_scope() as scope: - scope.set_user({"id": "42"}) - raise Exception("all is wrong") + scope = sentry_sdk.Scope.get_current_scope() + scope.set_user({"id": "42"}) + raise Exception("all is wrong") except Exception: sentry_sdk.capture_exception() with auto_session_tracking(session_mode="request"): pass - hub.start_session(session_mode="request") - hub.end_session() - + sentry_sdk.Scope.get_isolation_scope().start_session(session_mode="request") + sentry_sdk.Scope.get_isolation_scope().end_session() sentry_sdk.flush() assert len(envelopes) == 2 @@ -95,8 +91,6 @@ def test_aggregates_explicitly_disabled_session_tracking_request_mode( ) envelopes = capture_envelopes() - hub = Hub.current - with auto_session_tracking(session_mode="request"): with sentry_sdk.push_scope(): try: @@ -107,9 +101,8 @@ def test_aggregates_explicitly_disabled_session_tracking_request_mode( with auto_session_tracking(session_mode="request"): pass - hub.start_session(session_mode="request") - hub.end_session() - + sentry_sdk.Scope.get_isolation_scope().start_session(session_mode="request") + sentry_sdk.Scope.get_isolation_scope().end_session() sentry_sdk.flush() sess = envelopes[1] @@ -128,8 +121,6 @@ def test_no_thread_on_shutdown_no_errors(sentry_init): environment="not-fun-env", ) - hub = Hub.current - # make it seem like the interpreter is shutting down with mock.patch( "threading.Thread.start", @@ -145,7 +136,6 @@ def test_no_thread_on_shutdown_no_errors(sentry_init): with auto_session_tracking(session_mode="request"): pass - hub.start_session(session_mode="request") - hub.end_session() - + sentry_sdk.Scope.get_isolation_scope().start_session(session_mode="request") + sentry_sdk.Scope.get_isolation_scope().end_session() sentry_sdk.flush() diff --git a/tests/test_spotlight.py b/tests/test_spotlight.py index f0ab4664e0..d00c4eb8fc 100644 --- a/tests/test_spotlight.py +++ b/tests/test_spotlight.py @@ -1,13 +1,13 @@ import pytest -from sentry_sdk import Hub, capture_exception +import sentry_sdk @pytest.fixture def capture_spotlight_envelopes(monkeypatch): def inner(): envelopes = [] - test_spotlight = Hub.current.client.spotlight + test_spotlight = sentry_sdk.get_client().spotlight old_capture_envelope = test_spotlight.capture_envelope def append_envelope(envelope): @@ -22,13 +22,13 @@ def append_envelope(envelope): def test_spotlight_off_by_default(sentry_init): sentry_init() - assert Hub.current.client.spotlight is None + assert sentry_sdk.get_client().spotlight is None def test_spotlight_default_url(sentry_init): sentry_init(spotlight=True) - spotlight = Hub.current.client.spotlight + spotlight = sentry_sdk.get_client().spotlight assert spotlight is not None assert spotlight.url == "http://localhost:8969/stream" @@ -36,7 +36,7 @@ def test_spotlight_default_url(sentry_init): def test_spotlight_custom_url(sentry_init): sentry_init(spotlight="http://foobar@test.com/132") - spotlight = Hub.current.client.spotlight + spotlight = sentry_sdk.get_client().spotlight assert spotlight is not None assert spotlight.url == "http://foobar@test.com/132" @@ -48,7 +48,7 @@ def test_spotlight_envelope(sentry_init, capture_spotlight_envelopes): try: raise ValueError("aha!") except Exception: - capture_exception() + sentry_sdk.capture_exception() (envelope,) = envelopes payload = envelope.items[0].payload.json diff --git a/tests/test_transport.py b/tests/test_transport.py index 73eee6d353..6cace6f418 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -11,7 +11,8 @@ from pytest_localserver.http import WSGIServer from werkzeug.wrappers import Request, Response -from sentry_sdk import Hub, Client, add_breadcrumb, capture_message, Scope +import sentry_sdk +from sentry_sdk import Client, add_breadcrumb, capture_message, Scope from sentry_sdk.envelope import Envelope, Item, parse_json from sentry_sdk.transport import KEEP_ALIVE_SOCKET_OPTIONS, _parse_rate_limits from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger @@ -114,8 +115,8 @@ def test_transport_works( if use_pickle: client = pickle.loads(pickle.dumps(client)) - Hub.current.bind_client(client) - request.addfinalizer(lambda: Hub.current.bind_client(None)) + sentry_sdk.Scope.get_global_scope().set_client(client) + request.addfinalizer(lambda: sentry_sdk.Scope.get_global_scope().set_client(None)) add_breadcrumb( level="info", message="i like bread", timestamp=datetime.now(timezone.utc) @@ -238,7 +239,8 @@ def test_transport_infinite_loop(capturing_server, request, make_client): # to an infinite loop ignore_logger("werkzeug") - with Hub(client): + sentry_sdk.Scope.get_global_scope().set_client(client) + with sentry_sdk.isolation_scope(): capture_message("hi") client.flush() @@ -253,7 +255,8 @@ def test_transport_no_thread_on_shutdown_no_errors(capturing_server, make_client "threading.Thread.start", side_effect=RuntimeError("can't create new thread at interpreter shutdown"), ): - with Hub(client): + sentry_sdk.Scope.get_global_scope().set_client(client) + with sentry_sdk.isolation_scope(): capture_message("hi") # nothing exploded but also no events can be sent anymore diff --git a/tests/test_utils.py b/tests/test_utils.py index dd3aa3817a..c4064729f8 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -453,7 +453,7 @@ def test_parse_version(version, expected_result): @pytest.fixture def mock_client_with_dsn_netloc(): """ - Returns a mocked hub with a DSN netloc of "abcd1234.ingest.sentry.io". + Returns a mocked Client with a DSN netloc of "abcd1234.ingest.sentry.io". """ mock_client = mock.Mock(spec=sentry_sdk.Client) mock_client.transport = mock.Mock(spec=sentry_sdk.Transport) @@ -808,7 +808,7 @@ def test_get_current_thread_meta_gevent_in_thread_failed_to_get_hub(): def target(): with mock.patch("sentry_sdk.utils.is_gevent", side_effect=[True]): with mock.patch( - "sentry_sdk.utils.get_gevent_hub", side_effect=["fake hub"] + "sentry_sdk.utils.get_gevent_hub", side_effect=["fake gevent hub"] ): job = gevent.spawn(get_current_thread_meta) job.join() diff --git a/tests/tracing/test_integration_tests.py b/tests/tracing/test_integration_tests.py index 9543014cac..4752c9a131 100644 --- a/tests/tracing/test_integration_tests.py +++ b/tests/tracing/test_integration_tests.py @@ -6,7 +6,6 @@ from sentry_sdk import ( capture_message, - Hub, Scope, start_span, start_transaction, @@ -65,7 +64,9 @@ def test_continue_from_headers(sentry_init, capture_envelopes, sampled, sample_r with start_transaction(name="hi", sampled=True if sample_rate == 0 else None): with start_span() as old_span: old_span.sampled = sampled - headers = dict(Hub.current.iter_trace_propagation_headers(old_span)) + headers = dict( + Scope.get_current_scope().iter_trace_propagation_headers(old_span) + ) headers["baggage"] = ( "other-vendor-value-1=foo;bar;baz, " "sentry-trace_id=771a43a4192642f0b136d5159a501700, " @@ -269,7 +270,7 @@ def test_trace_propagation_meta_head_sdk(sentry_init): with start_transaction(transaction): with start_span(op="foo", description="foodesc") as current_span: span = current_span - meta = Hub.current.trace_propagation_meta() + meta = Scope.get_current_scope().trace_propagation_meta() ind = meta.find(">") + 1 sentry_trace, baggage = meta[:ind], meta[ind:] diff --git a/tests/tracing/test_misc.py b/tests/tracing/test_misc.py index e1006ef1bb..6d722e992f 100644 --- a/tests/tracing/test_misc.py +++ b/tests/tracing/test_misc.py @@ -6,7 +6,7 @@ from unittest.mock import MagicMock import sentry_sdk -from sentry_sdk import Hub, Scope, start_span, start_transaction, set_measurement +from sentry_sdk import Scope, start_span, start_transaction, set_measurement from sentry_sdk.consts import MATCH_ALL from sentry_sdk.tracing import Span, Transaction from sentry_sdk.tracing_utils import should_propagate_trace @@ -84,7 +84,7 @@ def test_finds_transaction_on_scope(sentry_init): transaction = start_transaction(name="dogpark") - scope = Hub.current.scope + scope = Scope.get_current_scope() # See note in Scope class re: getters and setters of the `transaction` # property. For the moment, assigning to scope.transaction merely sets the @@ -113,7 +113,7 @@ def test_finds_transaction_when_descendent_span_is_on_scope( transaction = start_transaction(name="dogpark") child_span = transaction.start_child(op="sniffing") - scope = Hub.current.scope + scope = Scope.get_current_scope() scope._span = child_span # this is the same whether it's the transaction itself or one of its @@ -136,7 +136,7 @@ def test_finds_orphan_span_on_scope(sentry_init): span = start_span(op="sniffing") - scope = Hub.current.scope + scope = Scope.get_current_scope() scope._span = span assert scope._span is not None @@ -150,7 +150,7 @@ def test_finds_non_orphan_span_on_scope(sentry_init): transaction = start_transaction(name="dogpark") child_span = transaction.start_child(op="sniffing") - scope = Hub.current.scope + scope = Scope.get_current_scope() scope._span = child_span assert scope._span is not None diff --git a/tests/tracing/test_sampling.py b/tests/tracing/test_sampling.py index 1940656bdf..88fb048d57 100644 --- a/tests/tracing/test_sampling.py +++ b/tests/tracing/test_sampling.py @@ -3,7 +3,8 @@ import pytest -from sentry_sdk import Hub, Scope, start_span, start_transaction, capture_exception +import sentry_sdk +from sentry_sdk import Scope, start_span, start_transaction, capture_exception from sentry_sdk.tracing import Transaction from sentry_sdk.utils import logger @@ -278,7 +279,7 @@ def record_lost_event(reason, data_category=None, item=None): sentry_init(traces_sample_rate=traces_sample_rate) monkeypatch.setattr( - Hub.current.client.transport, "record_lost_event", record_lost_event + sentry_sdk.get_client().transport, "record_lost_event", record_lost_event ) transaction = start_transaction(name="dogpark") @@ -307,7 +308,7 @@ def record_lost_event(reason, data_category=None, item=None): sentry_init(traces_sampler=traces_sampler) monkeypatch.setattr( - Hub.current.client.transport, "record_lost_event", record_lost_event + sentry_sdk.get_client().transport, "record_lost_event", record_lost_event ) transaction = start_transaction(name="dogpark") diff --git a/tox.ini b/tox.ini index 63fe5870ef..216b9c6e5a 100644 --- a/tox.ini +++ b/tox.ini @@ -12,7 +12,7 @@ envlist = {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-common # === Gevent === - {py3.6,py3.8,py3.10,py3.11}-gevent + {py3.6,py3.8,py3.10,py3.11,py3.12}-gevent # === Integrations === # General format is {pythonversion}-{integrationname}-v{frameworkversion} @@ -30,7 +30,7 @@ envlist = # AIOHTTP {py3.7}-aiohttp-v{3.4} {py3.7,py3.9,py3.11}-aiohttp-v{3.8} - {py3.8,py3.11}-aiohttp-latest + {py3.8,py3.11,py3.12}-aiohttp-latest # Anthropic {py3.7,py3.11,py3.12}-anthropic-v{0.16,0.25} @@ -63,9 +63,9 @@ envlist = # Boto3 {py3.6,py3.7}-boto3-v{1.12} - {py3.7,py3.11,py3.12}-boto3-v{1.21} - {py3.7,py3.11,py3.12}-boto3-v{1.29} - {py3.7,py3.11,py3.12}-boto3-latest + {py3.7,py3.11,py3.12}-boto3-v{1.23} + {py3.11,py3.12}-boto3-v{1.34} + {py3.11,py3.12}-boto3-latest # Bottle {py3.6,py3.9}-bottle-v{0.12} @@ -75,12 +75,12 @@ envlist = {py3.6,py3.8}-celery-v{4} {py3.6,py3.8}-celery-v{5.0} {py3.7,py3.10}-celery-v{5.1,5.2} - {py3.8,py3.11}-celery-v{5.3} - {py3.8,py3.11}-celery-latest + {py3.8,py3.11,py3.12}-celery-v{5.3,5.4} + {py3.8,py3.11,py3.12}-celery-latest # Chalice {py3.6,py3.9}-chalice-v{1.16} - {py3.7,py3.10}-chalice-latest + {py3.8,py3.12}-chalice-latest # Clickhouse Driver {py3.8,py3.11}-clickhouse_driver-v{0.2.0} @@ -128,7 +128,7 @@ envlist = # GQL {py3.7,py3.11}-gql-v{3.4} - {py3.7,py3.11}-gql-latest + {py3.7,py3.11,py3.12}-gql-latest # Graphene {py3.7,py3.11}-graphene-v{3.3} @@ -144,7 +144,7 @@ envlist = {py3.6,py3.9}-httpx-v{0.16,0.18} {py3.6,py3.10}-httpx-v{0.20,0.22} {py3.7,py3.11,py3.12}-httpx-v{0.23,0.24} - {py3.9,py3.11,py3.12}-httpx-v{0.25} + {py3.9,py3.11,py3.12}-httpx-v{0.25,0.27} {py3.9,py3.11,py3.12}-httpx-latest # Huey @@ -182,7 +182,7 @@ envlist = {py3.6}-pymongo-v{3.1} {py3.6,py3.9}-pymongo-v{3.12} {py3.6,py3.11}-pymongo-v{4.0} - {py3.7,py3.11,py3.12}-pymongo-v{4.3,4.6} + {py3.7,py3.11,py3.12}-pymongo-v{4.3,4.7} {py3.7,py3.11,py3.12}-pymongo-latest # Pyramid @@ -213,7 +213,7 @@ envlist = {py3.6}-rq-v{0.6} {py3.6,py3.9}-rq-v{0.13,1.0} {py3.6,py3.11}-rq-v{1.5,1.10} - {py3.7,py3.11,py3.12}-rq-v{1.15} + {py3.7,py3.11,py3.12}-rq-v{1.15,1.16} {py3.7,py3.11,py3.12}-rq-latest # Sanic @@ -225,12 +225,12 @@ envlist = # Spark {py3.8,py3.10,py3.11}-spark-v{3.1,3.3,3.5} - {py3.8,py3.10,py3.11}-spark-latest + {py3.8,py3.10,py3.11,py3.12}-spark-latest # Starlette {py3.7,py3.10}-starlette-v{0.19} {py3.7,py3.11}-starlette-v{0.20,0.24,0.28} - {py3.8,py3.11,py3.12}-starlette-v{0.32} + {py3.8,py3.11,py3.12}-starlette-v{0.32,0.36} {py3.8,py3.11,py3.12}-starlette-latest # Starlite @@ -244,11 +244,12 @@ envlist = # Strawberry {py3.8,py3.11}-strawberry-v{0.209} + {py3.8,py3.11,py3.12}-strawberry-v{0.222} {py3.8,py3.11,py3.12}-strawberry-latest # Tornado {py3.8,py3.11,py3.12}-tornado-v{6.0} - {py3.8,py3.11,py3.12}-tornado-v{6} + {py3.8,py3.11,py3.12}-tornado-v{6.2} {py3.8,py3.11,py3.12}-tornado-latest # Trytond @@ -277,7 +278,8 @@ deps = {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-common: pytest<7.0.0 # === Gevent === - {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-gevent: gevent>=22.10.0, <22.11.0 + {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}-gevent: gevent>=22.10.0, <22.11.0 + {py3.12}-gevent: gevent # See https://github.com/pytest-dev/pytest/issues/9621 # and https://github.com/pytest-dev/pytest-forked/issues/67 # for justification of the upper bound on pytest @@ -331,8 +333,8 @@ deps = # Boto3 boto3-v1.12: boto3~=1.12.0 - boto3-v1.21: boto3~=1.21.0 - boto3-v1.29: boto3~=1.29.0 + boto3-v1.23: boto3~=1.23.0 + boto3-v1.34: boto3~=1.34.0 boto3-latest: boto3 # Bottle @@ -347,18 +349,18 @@ deps = celery-v5.1: Celery~=5.1.0 celery-v5.2: Celery~=5.2.0 celery-v5.3: Celery~=5.3.0 + celery-v5.4: Celery~=5.4.0 celery-latest: Celery {py3.7}-celery: importlib-metadata<5.0 - {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}-celery: newrelic + {py3.6,py3.7,py3.8,py3.9,py3.10,py3.11,py3.12}-celery: newrelic # Chalice chalice-v1.16: chalice~=1.16.0 chalice-latest: chalice chalice: pytest-chalice==0.0.5 - {py3.7}-chalice: botocore~=1.31 - {py3.8}-chalice: botocore~=1.31 + {py3.7,py3.8}-chalice: botocore~=1.31 # Clickhouse Driver clickhouse_driver-v0.2.0: clickhouse_driver~=0.2.0 @@ -462,6 +464,7 @@ deps = httpx-v0.23: httpx~=0.23.0 httpx-v0.24: httpx~=0.24.0 httpx-v0.25: httpx~=0.25.0 + httpx-v0.27: httpx~=0.27.0 httpx-latest: httpx # Huey @@ -512,7 +515,7 @@ deps = pymongo-v3.13: pymongo~=3.13.0 pymongo-v4.0: pymongo~=4.0.0 pymongo-v4.3: pymongo~=4.3.0 - pymongo-v4.6: pymongo~=4.6.0 + pymongo-v4.7: pymongo~=4.7.0 pymongo-latest: pymongo # Pyramid @@ -555,7 +558,7 @@ deps = rq-v{0.6}: fakeredis<1.0 rq-v{0.6}: redis<3.2.2 rq-v{0.13,1.0,1.5,1.10}: fakeredis>=1.0,<1.7.4 - rq-v{1.15}: fakeredis + rq-v{1.15,1.16}: fakeredis rq-latest: fakeredis rq-v0.6: rq~=0.6.0 rq-v0.13: rq~=0.13.0 @@ -563,6 +566,7 @@ deps = rq-v1.5: rq~=1.5.0 rq-v1.10: rq~=1.10.0 rq-v1.15: rq~=1.15.0 + rq-v1.16: rq~=1.16.0 rq-latest: rq # Sanic @@ -596,6 +600,7 @@ deps = starlette-v0.24: starlette~=0.24.0 starlette-v0.28: starlette~=0.28.0 starlette-v0.32: starlette~=0.32.0 + starlette-v0.36: starlette~=0.36.0 starlette-latest: starlette # Starlite @@ -618,12 +623,13 @@ deps = strawberry: flask strawberry: httpx strawberry-v0.209: strawberry-graphql[fastapi,flask]~=0.209.0 + strawberry-v0.222: strawberry-graphql[fastapi,flask]~=0.222.0 strawberry-latest: strawberry-graphql[fastapi,flask] # Tornado tornado: pytest<8.2 tornado-v6.0: tornado~=6.0.0 - tornado-v6: tornado~=6.0 + tornado-v6.2: tornado~=6.2.0 tornado-latest: tornado # Trytond @@ -638,6 +644,9 @@ deps = setenv = PYTHONDONTWRITEBYTECODE=1 OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES + COVERAGE_FILE=.coverage-{envname} + django: DJANGO_SETTINGS_MODULE=tests.integrations.django.myapp.settings + common: TESTPATH=tests gevent: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp @@ -689,7 +698,6 @@ setenv = trytond: TESTPATH=tests/integrations/trytond socket: TESTPATH=tests/integrations/socket - COVERAGE_FILE=.coverage-{envname} passenv = SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY @@ -697,7 +705,9 @@ passenv = SENTRY_PYTHON_TEST_POSTGRES_USER SENTRY_PYTHON_TEST_POSTGRES_PASSWORD SENTRY_PYTHON_TEST_POSTGRES_NAME + usedevelop = True + extras = bottle: bottle falcon: falcon @@ -726,10 +736,10 @@ commands = ; https://github.com/pallets/flask/issues/4455 {py3.7,py3.8,py3.9,py3.10,py3.11}-flask-v{1}: pip install "itsdangerous>=0.24,<2.0" "markupsafe<2.0.0" "jinja2<3.1.1" - ; Running `py.test` as an executable suffers from an import error + ; Running `pytest` as an executable suffers from an import error ; when loading tests in scenarios. In particular, django fails to ; load the settings from the test module. - python -m pytest -rfEs -s --durations=5 -vvv {env:TESTPATH} {posargs} + python -m pytest {env:TESTPATH} {posargs} [testenv:linters] commands =