Skip to content

Commit

Permalink
Merge branch 'master' into antonpirker/better-aws-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Feb 24, 2025
2 parents 2b86d05 + 189e4a9 commit 38fa8c0
Show file tree
Hide file tree
Showing 29 changed files with 105 additions and 102 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test-integrations-dbs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: getsentry/action-clickhouse-in-ci@v1.1
- name: "Setup ClickHouse Server"
uses: getsentry/action-clickhouse-in-ci@v1.5
- name: Setup Test Env
run: |
pip install "coverage[toml]" tox
Expand Down Expand Up @@ -154,7 +155,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: getsentry/action-clickhouse-in-ci@v1.1
- name: "Setup ClickHouse Server"
uses: getsentry/action-clickhouse-in-ci@v1.5
- name: Setup Test Env
run: |
pip install "coverage[toml]" tox
Expand Down
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,7 @@ By: @mgaligniana (#1773)

import sentry_sdk
from sentry_sdk.integrations.arq import ArqIntegration
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT
from sentry_sdk.tracing import TransactionSource

sentry_sdk.init(
dsn="...",
Expand All @@ -2348,7 +2348,7 @@ By: @mgaligniana (#1773)
await ctx['session'].aclose()

async def main():
with sentry_sdk.start_transaction(name="testing_arq_tasks", source=TRANSACTION_SOURCE_COMPONENT):
with sentry_sdk.start_transaction(name="testing_arq_tasks", source=TransactionSource.COMPONENT):
redis = await create_pool(RedisSettings())
for url in ('https://facebook.com', 'https://microsoft.com', 'https://github.com', "asdf"
):
Expand Down Expand Up @@ -2422,7 +2422,7 @@ By: @mgaligniana (#1773)

import sentry_sdk
from sentry_sdk.integrations.huey import HueyIntegration
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT, Transaction
from sentry_sdk.tracing import TransactionSource, Transaction


def main():
Expand All @@ -2434,7 +2434,7 @@ By: @mgaligniana (#1773)
traces_sample_rate=1.0,
)

with sentry_sdk.start_transaction(name="testing_huey_tasks", source=TRANSACTION_SOURCE_COMPONENT):
with sentry_sdk.start_transaction(name="testing_huey_tasks", source=TransactionSource.COMPONENT):
r = add_numbers(1, 2)

if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion scripts/split_tox_gh_actions/templates/test_group.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
allow-prereleases: true
{% if needs_clickhouse %}
- uses: getsentry/action-clickhouse-in-ci@v1.1
- name: "Setup ClickHouse Server"
uses: getsentry/action-clickhouse-in-ci@v1.5
{% endif %}

{% if needs_redis %}
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sentry_sdk.tracing import (
BAGGAGE_HEADER_NAME,
SOURCE_FOR_STYLE,
TRANSACTION_SOURCE_ROUTE,
TransactionSource,
)
from sentry_sdk.tracing_utils import should_propagate_trace
from sentry_sdk.utils import (
Expand Down Expand Up @@ -129,7 +129,7 @@ async def sentry_app_handle(self, request, *args, **kwargs):
# If this transaction name makes it to the UI, AIOHTTP's
# URL resolver did not find a route or died trying.
name="generic AIOHTTP request",
source=TRANSACTION_SOURCE_ROUTE,
source=TransactionSource.ROUTE,
origin=AioHttpIntegration.origin,
)
with sentry_sdk.start_transaction(
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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, TRANSACTION_SOURCE_TASK
from sentry_sdk.tracing import Transaction, TransactionSource
from sentry_sdk.utils import (
capture_internal_exceptions,
ensure_integration_enabled,
Expand Down Expand Up @@ -102,7 +102,7 @@ async def _sentry_run_job(self, job_id, score):
name="unknown arq task",
status="ok",
op=OP.QUEUE_TASK_ARQ,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
origin=ArqIntegration.origin,
)

Expand Down
17 changes: 7 additions & 10 deletions sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
from sentry_sdk.sessions import track_session
from sentry_sdk.tracing import (
SOURCE_FOR_STYLE,
TRANSACTION_SOURCE_ROUTE,
TRANSACTION_SOURCE_URL,
TRANSACTION_SOURCE_COMPONENT,
TRANSACTION_SOURCE_CUSTOM,
TransactionSource,
)
from sentry_sdk.utils import (
ContextVar,
Expand Down Expand Up @@ -273,9 +270,9 @@ def event_processor(self, event, hint, asgi_scope):
already_set = event["transaction"] != _DEFAULT_TRANSACTION_NAME and event[
"transaction_info"
].get("source") in [
TRANSACTION_SOURCE_COMPONENT,
TRANSACTION_SOURCE_ROUTE,
TRANSACTION_SOURCE_CUSTOM,
TransactionSource.COMPONENT,
TransactionSource.ROUTE,
TransactionSource.CUSTOM,
]
if not already_set:
name, source = self._get_transaction_name_and_source(
Expand Down Expand Up @@ -313,7 +310,7 @@ def _get_transaction_name_and_source(self, transaction_style, asgi_scope):
name = transaction_from_function(endpoint) or ""
else:
name = _get_url(asgi_scope, "http" if ty == "http" else "ws", host=None)
source = TRANSACTION_SOURCE_URL
source = TransactionSource.URL

elif transaction_style == "url":
# FastAPI includes the route object in the scope to let Sentry extract the
Expand All @@ -325,11 +322,11 @@ def _get_transaction_name_and_source(self, transaction_style, asgi_scope):
name = path
else:
name = _get_url(asgi_scope, "http" if ty == "http" else "ws", host=None)
source = TRANSACTION_SOURCE_URL
source = TransactionSource.URL

if name is None:
name = _DEFAULT_TRANSACTION_NAME
source = TRANSACTION_SOURCE_ROUTE
source = TransactionSource.ROUTE
return name, source

return name, source
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sentry_sdk.api import continue_trace
from sentry_sdk.consts import OP
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT
from sentry_sdk.tracing import TransactionSource
from sentry_sdk.utils import (
AnnotatedValue,
capture_internal_exceptions,
Expand Down Expand Up @@ -153,7 +153,7 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs):
headers,
op=OP.FUNCTION_AWS,
name=aws_context.function_name,
source=TRANSACTION_SOURCE_COMPONENT,
source=TransactionSource.COMPONENT,
origin=AwsLambdaIntegration.origin,
)
with sentry_sdk.start_transaction(
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from sentry_sdk.integrations.celery.utils import _now_seconds_since_epoch
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.tracing import BAGGAGE_HEADER_NAME, TRANSACTION_SOURCE_TASK
from sentry_sdk.tracing import BAGGAGE_HEADER_NAME, TransactionSource
from sentry_sdk.tracing_utils import Baggage
from sentry_sdk.utils import (
capture_internal_exceptions,
Expand Down Expand Up @@ -319,7 +319,7 @@ def _inner(*args, **kwargs):
headers,
op=OP.QUEUE_TASK_CELERY,
name="unknown celery task",
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
origin=CeleryIntegration.origin,
)
transaction.name = task.name
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/chalice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sentry_sdk
from sentry_sdk.integrations import Integration, DidNotEnable
from sentry_sdk.integrations.aws_lambda import _make_request_event_processor
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT
from sentry_sdk.tracing import TransactionSource
from sentry_sdk.utils import (
capture_internal_exceptions,
event_from_exception,
Expand Down Expand Up @@ -67,7 +67,7 @@ def wrapped_view_function(**function_args):
configured_time = app.lambda_context.get_remaining_time_in_millis()
scope.set_transaction_name(
app.lambda_context.function_name,
source=TRANSACTION_SOURCE_COMPONENT,
source=TransactionSource.COMPONENT,
)

scope.add_event_processor(
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.scope import add_global_event_processor, should_send_default_pii
from sentry_sdk.serializer import add_global_repr_processor
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TRANSACTION_SOURCE_URL
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TransactionSource
from sentry_sdk.tracing_utils import add_query_source, record_sql_queries
from sentry_sdk.utils import (
AnnotatedValue,
Expand Down Expand Up @@ -398,7 +398,7 @@ def _set_transaction_name_and_source(scope, transaction_style, request):

if transaction_name is None:
transaction_name = request.path_info
source = TRANSACTION_SOURCE_URL
source = TransactionSource.URL
else:
source = SOURCE_FOR_STYLE[transaction_style]

Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sentry_sdk
from sentry_sdk.integrations import DidNotEnable
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TransactionSource
from sentry_sdk.utils import (
transaction_from_function,
logger,
Expand Down Expand Up @@ -61,7 +61,7 @@ def _set_transaction_name_and_source(scope, transaction_style, request):

if not name:
name = _DEFAULT_TRANSACTION_NAME
source = TRANSACTION_SOURCE_ROUTE
source = TransactionSource.ROUTE
else:
source = SOURCE_FOR_STYLE[transaction_style]

Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sentry_sdk.integrations import Integration
from sentry_sdk.integrations._wsgi_common import _filter_headers
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT
from sentry_sdk.tracing import TransactionSource
from sentry_sdk.utils import (
AnnotatedValue,
capture_internal_exceptions,
Expand Down Expand Up @@ -88,7 +88,7 @@ def sentry_func(functionhandler, gcp_event, *args, **kwargs):
headers,
op=OP.FUNCTION_GCP,
name=environ.get("FUNCTION_NAME", ""),
source=TRANSACTION_SOURCE_COMPONENT,
source=TransactionSource.COMPONENT,
origin=GcpIntegration.origin,
)
sampling_context = {
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/grpc/aio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from sentry_sdk.consts import OP
from sentry_sdk.integrations import DidNotEnable
from sentry_sdk.integrations.grpc.consts import SPAN_ORIGIN
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_CUSTOM
from sentry_sdk.tracing import Transaction, TransactionSource
from sentry_sdk.utils import event_from_exception

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -48,7 +48,7 @@ async def wrapped(request, context):
dict(context.invocation_metadata()),
op=OP.GRPC_SERVER,
name=name,
source=TRANSACTION_SOURCE_CUSTOM,
source=TransactionSource.CUSTOM,
origin=SPAN_ORIGIN,
)

Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/grpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from sentry_sdk.consts import OP
from sentry_sdk.integrations import DidNotEnable
from sentry_sdk.integrations.grpc.consts import SPAN_ORIGIN
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_CUSTOM
from sentry_sdk.tracing import Transaction, TransactionSource

from typing import TYPE_CHECKING

Expand Down Expand Up @@ -42,7 +42,7 @@ def behavior(request, context):
metadata,
op=OP.GRPC_SERVER,
name=name,
source=TRANSACTION_SOURCE_CUSTOM,
source=TransactionSource.CUSTOM,
origin=SPAN_ORIGIN,
)

Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sentry_sdk.tracing import (
BAGGAGE_HEADER_NAME,
SENTRY_TRACE_HEADER_NAME,
TRANSACTION_SOURCE_TASK,
TransactionSource,
)
from sentry_sdk.utils import (
capture_internal_exceptions,
Expand Down Expand Up @@ -159,7 +159,7 @@ def _sentry_execute(self, task, timestamp=None):
sentry_headers or {},
name=task.name,
op=OP.QUEUE_TASK_HUEY,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
origin=HueyIntegration.origin,
)
transaction.set_status(SPANSTATUS.OK)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/litestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.tracing import TransactionSource, SOURCE_FOR_STYLE
from sentry_sdk.utils import (
ensure_integration_enabled,
event_from_exception,
Expand Down Expand Up @@ -249,7 +249,7 @@ def event_processor(event, _):

if not tx_name:
tx_name = _DEFAULT_TRANSACTION_NAME
tx_info = {"source": TRANSACTION_SOURCE_ROUTE}
tx_info = {"source": TransactionSource.ROUTE}

event.update(
{
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/ray.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, SPANSTATUS
from sentry_sdk.integrations import _check_minimum_version, DidNotEnable, Integration
from sentry_sdk.tracing import TRANSACTION_SOURCE_TASK
from sentry_sdk.tracing import TransactionSource
from sentry_sdk.utils import (
event_from_exception,
logger,
Expand Down Expand Up @@ -63,7 +63,7 @@ def _f(*f_args, _tracing=None, **f_kwargs):
op=OP.QUEUE_TASK_RAY,
name=qualname_from_function(f),
origin=RayIntegration.origin,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
)

with sentry_sdk.start_transaction(transaction) as transaction:
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sentry_sdk.api import continue_trace
from sentry_sdk.integrations import _check_minimum_version, DidNotEnable, Integration
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.tracing import TRANSACTION_SOURCE_TASK
from sentry_sdk.tracing import TransactionSource
from sentry_sdk.utils import (
capture_internal_exceptions,
ensure_integration_enabled,
Expand Down Expand Up @@ -57,7 +57,7 @@ def sentry_patched_perform_job(self, job, *args, **kwargs):
job.meta.get("_sentry_trace_headers") or {},
op=OP.QUEUE_TASK_RQ,
name="unknown RQ task",
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
origin=RqIntegration.origin,
)

Expand Down
Loading

0 comments on commit 38fa8c0

Please sign in to comment.