Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/potel-base' into potel-base-run-…
Browse files Browse the repository at this point in the history
…all-tests
  • Loading branch information
sl0thentr0py committed Jan 10, 2025
2 parents 98e08ff + 9db3362 commit f902bcc
Show file tree
Hide file tree
Showing 78 changed files with 707 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base

pull_request:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
push:
branches:
- master
- sentry-sdk-2.0
- potel-base
pull_request:
schedule:
- cron: '18 18 * * 3'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/enforce-license-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- master
- main
- release/*
- sentry-sdk-2.0
- potel-base
pull_request:

# Cancel in progress workflows on pull_requests.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
# XXX: We are using `pull_request_target` instead of `pull_request` because we want
# this to run on forks with access to the secrets necessary to run the test suite.
# Prefer to use `pull_request` when possible.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-dbs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-web-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-web-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand All @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7","3.8","3.11","3.12","3.13"]
python-version: ["3.7","3.8","3.9","3.11","3.12","3.13"]
os: [ubuntu-latest]
steps:
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pytest -rs tests/integrations/flask/ # Replace "flask" with the specific integr

## Releasing a New Version

_(only relevant for Sentry employees)_
_(only relevant for Python SDK core team)_

### Prerequisites

Expand Down
1 change: 1 addition & 0 deletions requirements-linting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ pre-commit # local linting
httpcore
openfeature-sdk
launchdarkly-server-sdk
UnleashClient
typer
1 change: 1 addition & 0 deletions scripts/split_tox_gh_actions/split_tox_gh_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"pure_eval",
"trytond",
"typer",
"unleash",
],
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/split_tox_gh_actions/templates/base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
- potel-base

{% if needs_github_secrets %}
# XXX: We are using `pull_request_target` instead of `pull_request` because we want
Expand Down
42 changes: 41 additions & 1 deletion sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def iter_default_integrations(with_auto_enabling_integrations):
"sentry_sdk.integrations.tornado.TornadoIntegration",
]


iter_default_integrations = _generate_default_integrations_iterator(
integrations=_DEFAULT_INTEGRATIONS,
auto_enabling_integrations=_AUTO_ENABLING_INTEGRATIONS,
Expand All @@ -121,6 +120,30 @@ def iter_default_integrations(with_auto_enabling_integrations):
del _generate_default_integrations_iterator


_MIN_VERSIONS = {
"aiohttp": (3, 4),
"anthropic": (0, 16),
"ariadne": (0, 20),
"arq": (0, 23),
"asyncpg": (0, 23),
"boto3": (1, 12), # this is actually the botocore version
"bottle": (0, 12),
"celery": (4, 4, 7),
"clickhouse_driver": (0, 2, 0),
"django": (1, 8),
"falcon": (1, 4),
"flask": (0, 10),
"gql": (3, 4, 1),
"graphene": (3, 3),
"ray": (2, 7, 0),
"rq": (0, 6),
"sanic": (0, 8),
"sqlalchemy": (1, 2),
"strawberry": (0, 209, 5),
"tornado": (6, 0),
}


def setup_integrations(
integrations,
with_defaults=True,
Expand Down Expand Up @@ -196,6 +219,23 @@ def setup_integrations(
return integrations


def _check_minimum_version(integration, version, package=None):
# type: (type[Integration], Optional[tuple[int, ...]], Optional[str]) -> None
package = package or integration.identifier

if version is None:
raise DidNotEnable(f"Unparsable {package} version.")

min_version = _MIN_VERSIONS.get(integration.identifier)
if min_version is None:
return

if version < min_version:
raise DidNotEnable(
f"Integration only supports {package} {'.'.join(map(str, min_version))} or newer."
)


class DidNotEnable(Exception): # noqa: N818
"""
The integration could not be enabled due to a trivial user error like
Expand Down
8 changes: 2 additions & 6 deletions sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sentry_sdk.consts import OP, SPANSTATUS, SPANDATA
from sentry_sdk.integrations import (
_DEFAULT_FAILED_REQUEST_STATUS_CODES,
_check_minimum_version,
Integration,
DidNotEnable,
)
Expand Down Expand Up @@ -98,12 +99,7 @@ def setup_once():
# type: () -> None

version = parse_version(AIOHTTP_VERSION)

if version is None:
raise DidNotEnable("Unparsable AIOHTTP version: {}".format(AIOHTTP_VERSION))

if version < (3, 4):
raise DidNotEnable("AIOHTTP 3.4 or newer required.")
_check_minimum_version(AioHttpIntegration, version)

if not HAS_REAL_CONTEXTVARS:
# We better have contextvars or we're going to leak state between
Expand Down
9 changes: 2 additions & 7 deletions sentry_sdk/integrations/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sentry_sdk
from sentry_sdk.ai.monitoring import record_token_usage
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations import _check_minimum_version, DidNotEnable, Integration
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.utils import (
capture_internal_exceptions,
Expand Down Expand Up @@ -37,12 +37,7 @@ def __init__(self, include_prompts=True):
def setup_once():
# type: () -> None
version = package_version("anthropic")

if version is None:
raise DidNotEnable("Unparsable anthropic version.")

if version < (0, 16):
raise DidNotEnable("anthropic 0.16 or newer required.")
_check_minimum_version(AnthropicIntegration, version)

Messages.create = _wrap_message_create(Messages.create)
AsyncMessages.create = _wrap_message_create_async(AsyncMessages.create)
Expand Down
9 changes: 2 additions & 7 deletions sentry_sdk/integrations/ariadne.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sentry_sdk
from sentry_sdk import get_client, capture_event
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations import _check_minimum_version, DidNotEnable, Integration
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.integrations._wsgi_common import request_body_within_bounds
from sentry_sdk.scope import should_send_default_pii
Expand Down Expand Up @@ -36,12 +36,7 @@ class AriadneIntegration(Integration):
def setup_once():
# type: () -> None
version = package_version("ariadne")

if version is None:
raise DidNotEnable("Unparsable ariadne version.")

if version < (0, 20):
raise DidNotEnable("ariadne 0.20 or newer required.")
_check_minimum_version(AriadneIntegration, version)

ignore_logger("ariadne")

Expand Down
8 changes: 2 additions & 6 deletions sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sentry_sdk
from sentry_sdk.consts import OP, SPANSTATUS
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations import _check_minimum_version, DidNotEnable, Integration
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.tracing import TRANSACTION_SOURCE_TASK
Expand Down Expand Up @@ -57,11 +57,7 @@ def setup_once():
except (TypeError, ValueError):
version = None

if version is None:
raise DidNotEnable("Unparsable arq version: {}".format(ARQ_VERSION))

if version < (0, 23):
raise DidNotEnable("arq 0.23 or newer required.")
_check_minimum_version(ArqIntegration, version)

patch_enqueue_job()
patch_run_job()
Expand Down
13 changes: 5 additions & 8 deletions sentry_sdk/integrations/asyncpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sentry_sdk
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.integrations import Integration, DidNotEnable
from sentry_sdk.integrations import _check_minimum_version, Integration, DidNotEnable
from sentry_sdk.tracing import Span
from sentry_sdk.tracing_utils import add_query_source, record_sql_queries
from sentry_sdk.utils import (
Expand All @@ -22,13 +22,6 @@
raise DidNotEnable("asyncpg not installed.")


# asyncpg.__version__ is a string containing the semantic version in the form of "<major>.<minor>.<patch>"
asyncpg_version = parse_version(asyncpg.__version__)

if asyncpg_version is not None and asyncpg_version < (0, 23, 0):
raise DidNotEnable("asyncpg >= 0.23.0 required")


class AsyncPGIntegration(Integration):
identifier = "asyncpg"
origin = f"auto.db.{identifier}"
Expand All @@ -39,6 +32,10 @@ def __init__(self, *, record_params: bool = False):

@staticmethod
def setup_once() -> None:
# asyncpg.__version__ is a string containing the semantic version in the form of "<major>.<minor>.<patch>"
asyncpg_version = parse_version(asyncpg.__version__)
_check_minimum_version(AsyncPGIntegration, asyncpg_version)

asyncpg.Connection.execute = _wrap_execute(
asyncpg.Connection.execute,
)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs):
headers = {}

with sentry_sdk.continue_trace(headers):
with sentry_sdk.start_transaction(
with sentry_sdk.start_span(
op=OP.FUNCTION_AWS,
name=aws_context.function_name,
source=TRANSACTION_SOURCE_COMPONENT,
Expand Down
12 changes: 2 additions & 10 deletions sentry_sdk/integrations/boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sentry_sdk
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.integrations import Integration, DidNotEnable
from sentry_sdk.integrations import _check_minimum_version, Integration, DidNotEnable
from sentry_sdk.utils import (
capture_internal_exceptions,
ensure_integration_enabled,
Expand Down Expand Up @@ -36,16 +36,8 @@ class Boto3Integration(Integration):
@staticmethod
def setup_once():
# type: () -> None

version = parse_version(BOTOCORE_VERSION)

if version is None:
raise DidNotEnable(
"Unparsable botocore version: {}".format(BOTOCORE_VERSION)
)

if version < (1, 12):
raise DidNotEnable("Botocore 1.12 or newer is required.")
_check_minimum_version(Boto3Integration, version, "botocore")

orig_init = BaseClient.__init__

Expand Down
Loading

0 comments on commit f902bcc

Please sign in to comment.