Skip to content

Commit

Permalink
Merge branch 'potel-base' into ivana/potelport-http-client-breadcrumb…
Browse files Browse the repository at this point in the history
…-statuses
  • Loading branch information
sentrivana committed Feb 24, 2025
2 parents 645506a + eb93c1f commit eab5e0f
Show file tree
Hide file tree
Showing 28 changed files with 124 additions and 97 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 @@ -55,7 +55,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: getsentry/[email protected]
- name: "Setup ClickHouse Server"
uses: getsentry/[email protected]
- name: Setup Test Env
run: |
pip install "coverage[toml]" tox
Expand Down Expand Up @@ -140,7 +141,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: getsentry/[email protected]
- name: "Setup ClickHouse Server"
uses: getsentry/[email protected]
- 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 @@ -47,7 +47,8 @@
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
allow-prereleases: true
{% if needs_clickhouse %}
- uses: getsentry/[email protected]
- name: "Setup ClickHouse Server"
uses: getsentry/[email protected]
{% 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 @@ -137,7 +137,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,
attributes=_prepopulate_attributes(request),
) as span:
Expand Down
6 changes: 3 additions & 3 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_SOURCE_TASK
from sentry_sdk.tracing import TransactionSource
from sentry_sdk.utils import (
capture_internal_exceptions,
ensure_integration_enabled,
Expand Down Expand Up @@ -103,14 +103,14 @@ async def _sentry_run_job(self, job_id, score):
scope._name = "arq"
scope.set_transaction_name(
DEFAULT_TRANSACTION_NAME,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
)
scope.clear_breadcrumbs()

with sentry_sdk.start_span(
op=OP.QUEUE_TASK_ARQ,
name=DEFAULT_TRANSACTION_NAME,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
origin=ArqIntegration.origin,
) as span:
return_value = await old_run_job(self, job_id, score)
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 @@ -265,9 +262,9 @@ def event_processor(self, event, hint, asgi_scope):
and "source" in event["transaction_info"]
and event["transaction_info"]["source"]
in [
TRANSACTION_SOURCE_COMPONENT,
TRANSACTION_SOURCE_ROUTE,
TRANSACTION_SOURCE_CUSTOM,
TransactionSource.COMPONENT,
TransactionSource.ROUTE,
TransactionSource.CUSTOM,
]
)
if not already_set:
Expand Down Expand Up @@ -306,7 +303,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 @@ -318,11 +315,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
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sentry_sdk
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 @@ -125,7 +125,7 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs):

with sentry_sdk.isolation_scope() as scope:
scope.set_transaction_name(
aws_context.function_name, source=TRANSACTION_SOURCE_COMPONENT
aws_context.function_name, source=TransactionSource.COMPONENT
)
timeout_thread = None
with capture_internal_exceptions():
Expand Down Expand Up @@ -170,7 +170,7 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs):
with sentry_sdk.start_span(
op=OP.FUNCTION_AWS,
name=aws_context.function_name,
source=TRANSACTION_SOURCE_COMPONENT,
source=TransactionSource.COMPONENT,
origin=AwsLambdaIntegration.origin,
attributes=_prepopulate_attributes(request_data, aws_context),
):
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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 @@ -306,7 +306,7 @@ def _inner(*args, **kwargs):
with isolation_scope() as scope:
scope._name = "celery"
scope.clear_breadcrumbs()
scope.set_transaction_name(task.name, source=TRANSACTION_SOURCE_TASK)
scope.set_transaction_name(task.name, source=TransactionSource.TASK)
scope.add_event_processor(_make_event_processor(task, *args, **kwargs))

# Celery task objects are not a thing to be trusted. Even
Expand All @@ -317,7 +317,7 @@ def _inner(*args, **kwargs):
with sentry_sdk.start_span(
op=OP.QUEUE_TASK_CELERY,
name=task.name,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
origin=CeleryIntegration.origin,
# for some reason, args[1] is a list if non-empty but a
# tuple if empty
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 @@ -12,7 +12,7 @@
_request_headers_to_span_attributes,
)
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 @@ -90,7 +90,7 @@ def sentry_func(functionhandler, gcp_event, *args, **kwargs):
with sentry_sdk.start_span(
op=OP.FUNCTION_GCP,
name=environ.get("FUNCTION_NAME", ""),
source=TRANSACTION_SOURCE_COMPONENT,
source=TransactionSource.COMPONENT,
origin=GcpIntegration.origin,
attributes=_prepopulate_attributes(gcp_event),
):
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_SOURCE_CUSTOM
from sentry_sdk.tracing import 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):
with sentry_sdk.start_span(
op=OP.GRPC_SERVER,
name=name,
source=TRANSACTION_SOURCE_CUSTOM,
source=TransactionSource.CUSTOM,
origin=SPAN_ORIGIN,
):
try:
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_SOURCE_CUSTOM
from sentry_sdk.tracing import TransactionSource

from typing import TYPE_CHECKING

Expand Down Expand Up @@ -42,7 +42,7 @@ def behavior(request, context):
with sentry_sdk.start_span(
op=OP.GRPC_SERVER,
name=name,
source=TRANSACTION_SOURCE_CUSTOM,
source=TransactionSource.CUSTOM,
origin=SPAN_ORIGIN,
):
try:
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 @@ -165,7 +165,7 @@ def _sentry_execute(self, task, timestamp=None):
with sentry_sdk.start_span(
name=task.name,
op=OP.QUEUE_TASK_HUEY,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
origin=HueyIntegration.origin,
):
return old_execute(self, task, timestamp)
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 @@ -252,7 +252,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
6 changes: 3 additions & 3 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,14 +63,14 @@ def _f(*f_args, _tracing=None, **f_kwargs):
root_span_name = qualname_from_function(f) or DEFAULT_TRANSACTION_NAME
sentry_sdk.get_current_scope().set_transaction_name(
root_span_name,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
)
with sentry_sdk.continue_trace(_tracing or {}):
with sentry_sdk.start_span(
op=OP.QUEUE_TASK_RAY,
name=root_span_name,
origin=RayIntegration.origin,
source=TRANSACTION_SOURCE_TASK,
source=TransactionSource.TASK,
) as root_span:
try:
result = f(*f_args, **f_kwargs)
Expand Down
Loading

0 comments on commit eab5e0f

Please sign in to comment.