Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
_filter_headers,
request_body_within_bounds,
)
from sentry_sdk.tracing import SOURCE_FOR_STYLE, Transaction
from sentry_sdk.tracing import SOURCE_FOR_STYLE, Transaction, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.utils import (
capture_internal_exceptions,
event_from_exception,
Expand Down Expand Up @@ -103,6 +103,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,
)
with hub.start_transaction(
transaction, custom_sampling_context={"aiohttp_request": request}
Expand Down
3 changes: 2 additions & 1 deletion sentry_sdk/integrations/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sentry_sdk.hub import Hub
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.tracing import Transaction
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_TASK
from sentry_sdk.utils import capture_internal_exceptions, event_from_exception

try:
Expand Down Expand Up @@ -63,6 +63,7 @@ def sentry_patched_perform_job(self, job, *args, **kwargs):
job.meta.get("_sentry_trace_headers") or {},
op="rq.task",
name="unknown RQ task",
source=TRANSACTION_SOURCE_TASK,
)

with capture_internal_exceptions():
Expand Down
3 changes: 1 addition & 2 deletions sentry_sdk/integrations/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
request_body_within_bounds,
)
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
from sentry_sdk.tracing import SOURCE_FOR_STYLE
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.utils import (
TRANSACTION_SOURCE_ROUTE,
AnnotatedValue,
capture_internal_exceptions,
event_from_exception,
Expand Down
7 changes: 6 additions & 1 deletion sentry_sdk/integrations/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from inspect import iscoroutinefunction

from sentry_sdk.hub import Hub, _should_send_default_pii
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT, Transaction
from sentry_sdk.tracing import (
TRANSACTION_SOURCE_COMPONENT,
TRANSACTION_SOURCE_ROUTE,
Transaction,
)
from sentry_sdk.utils import (
HAS_REAL_CONTEXTVARS,
CONTEXTVARS_ERROR_MESSAGE,
Expand Down Expand Up @@ -116,6 +120,7 @@ def _handle_request_impl(self):
# sentry_urldispatcher_resolve is responsible for
# setting a transaction name later.
name="generic Tornado request",
source=TRANSACTION_SOURCE_ROUTE,
)

with hub.start_transaction(
Expand Down
7 changes: 5 additions & 2 deletions sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
event_from_exception,
)
from sentry_sdk._compat import PY2, reraise, iteritems
from sentry_sdk.tracing import Transaction
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.sessions import auto_session_tracking
from sentry_sdk.integrations._wsgi_common import _filter_headers
from sentry_sdk.profiler import profiling
Expand Down Expand Up @@ -123,7 +123,10 @@ def __call__(self, environ, start_response):
)

transaction = Transaction.continue_from_environ(
environ, op="http.server", name="generic WSGI request"
environ,
op="http.server",
name="generic WSGI request",
source=TRANSACTION_SOURCE_ROUTE,
)

with hub.start_transaction(
Expand Down
3 changes: 1 addition & 2 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
TRANSACTION_SOURCE_VIEW = "view"
TRANSACTION_SOURCE_COMPONENT = "component"
TRANSACTION_SOURCE_TASK = "task"
TRANSACTION_SOURCE_UNKNOWN = "unknown"

SOURCE_FOR_STYLE = {
"endpoint": TRANSACTION_SOURCE_COMPONENT,
Expand Down Expand Up @@ -547,7 +546,7 @@ def __init__(
sentry_tracestate=None, # type: Optional[str]
third_party_tracestate=None, # type: Optional[str]
baggage=None, # type: Optional[Baggage]
source=TRANSACTION_SOURCE_UNKNOWN, # type: str
source=TRANSACTION_SOURCE_CUSTOM, # type: str
**kwargs # type: Any
):
# type: (...) -> None
Expand Down
10 changes: 0 additions & 10 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@
MAX_STRING_LENGTH = 512
BASE64_ALPHABET = re.compile(r"^[a-zA-Z0-9/+=]*$")

# Transaction source
# see https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations
TRANSACTION_SOURCE_CUSTOM = "custom"
TRANSACTION_SOURCE_URL = "url"
TRANSACTION_SOURCE_ROUTE = "route"
TRANSACTION_SOURCE_VIEW = "view"
TRANSACTION_SOURCE_COMPONENT = "component"
TRANSACTION_SOURCE_TASK = "task"
TRANSACTION_SOURCE_UNKNOWN = "unknown"


def json_dumps(data):
# type: (Any) -> bytes
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/celery/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def dummy_task(x, y):
assert execution_event["transaction_info"] == {"source": "task"}

assert submission_event["transaction"] == "submission"
assert submission_event["transaction_info"] == {"source": "unknown"}
assert submission_event["transaction_info"] == {"source": "custom"}

assert execution_event["type"] == submission_event["type"] == "transaction"
assert execution_event["contexts"]["trace"]["trace_id"] == transaction.trace_id
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/tornado/test_tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_transactions(tornado_testcase, sentry_init, capture_events, handler, co
assert client_tx["type"] == "transaction"
assert client_tx["transaction"] == "client"
assert client_tx["transaction_info"] == {
"source": "unknown"
"source": "custom"
} # because this is just the start_transaction() above.

if server_error is not None:
Expand Down
3 changes: 3 additions & 0 deletions tests/tracing/test_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def test_basic(sentry_init, capture_events, sample_rate):
assert len(events) == 1
event = events[0]

assert event["transaction"] == "hi"
assert event["transaction_info"]["source"] == "custom"

span1, span2 = event["spans"]
parent_span = event
assert span1["tags"]["status"] == "internal_error"
Expand Down