Skip to content

Commit 123c214

Browse files
authored
ref: Remove transaction profiler in new major (#6921)
Closes #6920
1 parent 8043783 commit 123c214

24 files changed

Lines changed: 12 additions & 1991 deletions

MIGRATION_GUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
2626

2727
## Removed
2828

29+
- Transaction profiling and related code was removed.
2930
- Removed the deprecated Hub class and all uses of hub throughout the SDK in arguments, options, etc. Use a scope instead.
3031
- Removed the `auto_session_tracing` decorator. Use `track_session` instead.
3132

docs/apidocs.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ API Docs
2929
.. autoclass:: sentry_sdk.tracing.Span
3030
:members:
3131

32-
.. autoclass:: sentry_sdk.profiler.transaction_profiler.Profile
33-
:members:
34-
3532
.. autoclass:: sentry_sdk.session.Session
3633
:members:
3734

sentry_sdk/_types.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ class DataCollection(TypedDict):
274274
"monitor_config": Mapping[str, object],
275275
"monitor_slug": Optional[str],
276276
"platform": Literal["python"],
277-
"profile": object, # Should be sentry_sdk.profiler.Profile, but we can't import that here due to circular imports
278277
"release": Optional[str],
279278
"request": dict[str, object],
280279
"sdk": Mapping[str, object],
@@ -418,7 +417,6 @@ class DataCollection(TypedDict):
418417
"attachment",
419418
"session",
420419
"internal",
421-
"profile",
422420
"profile_chunk",
423421
"monitor",
424422
"span",
@@ -429,7 +427,7 @@ class DataCollection(TypedDict):
429427
SessionStatus = Literal["ok", "exited", "crashed", "abnormal"]
430428

431429
ContinuousProfilerMode = Literal["thread", "gevent", "unknown"]
432-
ProfilerMode = Union[ContinuousProfilerMode, Literal["sleep"]]
430+
ProfilerMode = Union[ContinuousProfilerMode]
433431

434432
MonitorConfigScheduleType = Literal["crontab", "interval"]
435433
MonitorConfigScheduleUnit = Literal[

sentry_sdk/client.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
from sentry_sdk.integrations.dedupe import DedupeIntegration
3333
from sentry_sdk.monitor import Monitor
3434
from sentry_sdk.profiler.continuous_profiler import setup_continuous_profiler
35-
from sentry_sdk.profiler.transaction_profiler import (
36-
Profile,
37-
has_profiling_enabled,
38-
setup_profiler,
39-
)
4035
from sentry_sdk.scrubber import EventScrubber
4136
from sentry_sdk.serializer import serialize
4237
from sentry_sdk.sessions import SessionFlusher
@@ -632,7 +627,6 @@ def _record_lost_event(
632627
self.options["send_default_pii"] = True
633628
self.options["error_sampler"] = sample_all
634629
self.options["traces_sampler"] = sample_all
635-
self.options["profiles_sampler"] = sample_all
636630
# data_collection was resolved in _get_options() before this
637631
# spotlight override flipped send_default_pii on. Re-derive it so
638632
# data_collection agrees with should_send_default_pii() in
@@ -708,20 +702,14 @@ def _record_lost_event(
708702
SDK_INFO["name"] = sdk_name
709703
logger.debug("Setting SDK name to '%s'", sdk_name)
710704

711-
if has_profiling_enabled(self.options):
712-
try:
713-
setup_profiler(self.options)
714-
except Exception as e:
715-
logger.debug("Can not set up profiler. (%s)", e)
716-
else:
717-
try:
718-
setup_continuous_profiler(
719-
self.options,
720-
sdk_info=SDK_INFO,
721-
capture_func=_capture_envelope,
722-
)
723-
except Exception as e:
724-
logger.debug("Can not set up continuous profiler. (%s)", e)
705+
try:
706+
setup_continuous_profiler(
707+
self.options,
708+
sdk_info=SDK_INFO,
709+
capture_func=_capture_envelope,
710+
)
711+
except Exception as e:
712+
logger.debug("Can not set up continuous profiler. (%s)", e)
725713

726714
finally:
727715
_client_init_debug.set(old_debug)
@@ -733,7 +721,6 @@ def _record_lost_event(
733721
or self.log_batcher
734722
or self.metrics_batcher
735723
or self.span_batcher
736-
or has_profiling_enabled(self.options)
737724
or isinstance(self.transport, HttpTransportCore)
738725
):
739726
# If we have anything on that could spawn a background thread, we
@@ -1121,8 +1108,6 @@ def capture_event(
11211108
if not self._should_capture(event, hint, scope):
11221109
return None
11231110

1124-
profile = event.pop("profile", None)
1125-
11261111
event_id = event.get("event_id")
11271112
if event_id is None:
11281113
event["event_id"] = event_id = uuid.uuid4().hex
@@ -1163,9 +1148,6 @@ def capture_event(
11631148

11641149
envelope = Envelope(headers=headers)
11651150

1166-
if is_transaction and isinstance(profile, Profile):
1167-
envelope.add_profile(profile.to_json(event_opt, self.options))
1168-
11691151
if is_transaction and not span_recorder_has_gen_ai_span:
11701152
envelope.add_transaction(event_opt)
11711153
elif is_transaction:

sentry_sdk/consts.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,6 @@ def __init__(
13011301
traces_sample_rate: "Optional[float]" = None,
13021302
trace_lifecycle: "Optional[Literal['static', 'stream']]" = None,
13031303
traces_sampler: "Optional[TracesSampler]" = None,
1304-
profiles_sample_rate: "Optional[float]" = None,
1305-
profiles_sampler: "Optional[TracesSampler]" = None,
13061304
profiler_mode: "Optional[ProfilerMode]" = None,
13071305
profile_lifecycle: 'Literal["manual", "trace"]' = "manual",
13081306
profile_session_sample_rate: "Optional[float]" = None,
@@ -1705,16 +1703,6 @@ def __init__(
17051703
Return a string for that repr value to be used or `None` to continue serializing how Sentry would have
17061704
done it anyway.
17071705
1708-
:param profiles_sample_rate: A number between `0` and `1`, controlling the percentage chance a given sampled
1709-
transaction will be profiled.
1710-
1711-
(`0` represents 0% while `1` represents 100%.) Applies equally to all transactions created in the app.
1712-
1713-
This is relative to the tracing sample rate - e.g. `0.5` means 50% of sampled transactions will be
1714-
profiled.
1715-
1716-
:param profiles_sampler:
1717-
17181706
:param profiler_mode:
17191707
17201708
:param profile_lifecycle:

sentry_sdk/envelope.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ def add_transaction(
5959
) -> None:
6060
self.add_item(Item(payload=PayloadRef(json=transaction), type="transaction"))
6161

62-
def add_profile(
63-
self,
64-
profile: "Any",
65-
) -> None:
66-
self.add_item(Item(payload=PayloadRef(json=profile), type="profile"))
67-
6862
def add_profile_chunk(
6963
self,
7064
profile_chunk: "Any",
@@ -259,8 +253,6 @@ def data_category(self) -> "EventDataCategory":
259253
return "trace_metric"
260254
elif ty == "client_report":
261255
return "internal"
262-
elif ty == "profile":
263-
return "profile"
264256
elif ty == "profile_chunk":
265257
return "profile_chunk"
266258
elif ty == "check_in":

sentry_sdk/integrations/django/asgi.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ async def sentry_wrapped_callback(
188188
if current_scope.transaction is not None:
189189
current_scope.transaction.update_active_thread()
190190

191-
sentry_scope = sentry_sdk.get_isolation_scope()
192-
if sentry_scope.profile is not None:
193-
sentry_scope.profile.update_active_thread_id()
194-
195191
integration = client.get_integration(DjangoIntegration)
196192
if not integration or not integration.middleware_spans:
197193
return await callback(request, *args, **kwargs)

sentry_sdk/integrations/django/views.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ def sentry_wrapped_callback(request: "Any", *args: "Any", **kwargs: "Any") -> "A
9999
if current_scope.transaction is not None:
100100
current_scope.transaction.update_active_thread()
101101

102-
sentry_scope = sentry_sdk.get_isolation_scope()
103-
# set the active thread id to the handler thread for sync views
104-
# this isn't necessary for async views since that runs on main
105-
if sentry_scope.profile is not None:
106-
sentry_scope.profile.update_active_thread_id()
107-
108102
integration = client.get_integration(DjangoIntegration)
109103
if not integration or not integration.middleware_spans:
110104
return callback(request, *args, **kwargs)

sentry_sdk/integrations/fastapi.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ def _sentry_call(*args: "Any", **kwargs: "Any") -> "Any":
181181
elif current_scope.transaction is not None:
182182
current_scope.transaction.update_active_thread()
183183

184-
sentry_scope = sentry_sdk.get_isolation_scope()
185-
if sentry_scope.profile is not None:
186-
sentry_scope.profile.update_active_thread_id()
187-
188184
return old_call(*args, **kwargs)
189185

190186
_sentry_call._sentry_is_patched = True # type: ignore[attr-defined]

sentry_sdk/integrations/quart.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ def _sentry_func(*args: "Any", **kwargs: "Any") -> "Any":
133133
if current_scope.transaction is not None:
134134
current_scope.transaction.update_active_thread()
135135

136-
sentry_scope = sentry_sdk.get_isolation_scope()
137-
if sentry_scope.profile is not None:
138-
sentry_scope.profile.update_active_thread_id()
139-
140136
return old_func(*args, **kwargs)
141137

142138
return old_decorator(_sentry_func)

0 commit comments

Comments
 (0)