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
1 change: 1 addition & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh

## Removed

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

Expand Down
3 changes: 0 additions & 3 deletions docs/apidocs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ API Docs
.. autoclass:: sentry_sdk.tracing.Span
:members:

.. autoclass:: sentry_sdk.profiler.transaction_profiler.Profile
:members:

.. autoclass:: sentry_sdk.session.Session
:members:

Expand Down
4 changes: 1 addition & 3 deletions sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ class DataCollection(TypedDict):
"monitor_config": Mapping[str, object],
"monitor_slug": Optional[str],
"platform": Literal["python"],
"profile": object, # Should be sentry_sdk.profiler.Profile, but we can't import that here due to circular imports
"release": Optional[str],
"request": dict[str, object],
"sdk": Mapping[str, object],
Expand Down Expand Up @@ -418,7 +417,6 @@ class DataCollection(TypedDict):
"attachment",
"session",
"internal",
"profile",
Comment thread
cursor[bot] marked this conversation as resolved.
"profile_chunk",
"monitor",
"span",
Expand All @@ -429,7 +427,7 @@ class DataCollection(TypedDict):
SessionStatus = Literal["ok", "exited", "crashed", "abnormal"]

ContinuousProfilerMode = Literal["thread", "gevent", "unknown"]
ProfilerMode = Union[ContinuousProfilerMode, Literal["sleep"]]
ProfilerMode = Union[ContinuousProfilerMode]

MonitorConfigScheduleType = Literal["crontab", "interval"]
MonitorConfigScheduleUnit = Literal[
Expand Down
34 changes: 8 additions & 26 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
from sentry_sdk.integrations.dedupe import DedupeIntegration
from sentry_sdk.monitor import Monitor
from sentry_sdk.profiler.continuous_profiler import setup_continuous_profiler
from sentry_sdk.profiler.transaction_profiler import (
Profile,
has_profiling_enabled,
setup_profiler,
)
from sentry_sdk.scrubber import EventScrubber
from sentry_sdk.serializer import serialize
from sentry_sdk.sessions import SessionFlusher
Expand Down Expand Up @@ -632,7 +627,6 @@ def _record_lost_event(
self.options["send_default_pii"] = True
self.options["error_sampler"] = sample_all
self.options["traces_sampler"] = sample_all
self.options["profiles_sampler"] = sample_all
# data_collection was resolved in _get_options() before this
# spotlight override flipped send_default_pii on. Re-derive it so
# data_collection agrees with should_send_default_pii() in
Expand Down Expand Up @@ -708,20 +702,14 @@ def _record_lost_event(
SDK_INFO["name"] = sdk_name
logger.debug("Setting SDK name to '%s'", sdk_name)

if has_profiling_enabled(self.options):
try:
setup_profiler(self.options)
except Exception as e:
logger.debug("Can not set up profiler. (%s)", e)
else:
try:
setup_continuous_profiler(
self.options,
sdk_info=SDK_INFO,
capture_func=_capture_envelope,
)
except Exception as e:
logger.debug("Can not set up continuous profiler. (%s)", e)
try:
setup_continuous_profiler(
self.options,
sdk_info=SDK_INFO,
capture_func=_capture_envelope,
)
except Exception as e:
logger.debug("Can not set up continuous profiler. (%s)", e)

finally:
_client_init_debug.set(old_debug)
Expand All @@ -733,7 +721,6 @@ def _record_lost_event(
or self.log_batcher
or self.metrics_batcher
or self.span_batcher
or has_profiling_enabled(self.options)
or isinstance(self.transport, HttpTransportCore)
):
# If we have anything on that could spawn a background thread, we
Expand Down Expand Up @@ -1121,8 +1108,6 @@ def capture_event(
if not self._should_capture(event, hint, scope):
return None

profile = event.pop("profile", None)

event_id = event.get("event_id")
if event_id is None:
event["event_id"] = event_id = uuid.uuid4().hex
Expand Down Expand Up @@ -1163,9 +1148,6 @@ def capture_event(

envelope = Envelope(headers=headers)

if is_transaction and isinstance(profile, Profile):
envelope.add_profile(profile.to_json(event_opt, self.options))

if is_transaction and not span_recorder_has_gen_ai_span:
envelope.add_transaction(event_opt)
elif is_transaction:
Expand Down
12 changes: 0 additions & 12 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,8 +1301,6 @@ def __init__(
traces_sample_rate: "Optional[float]" = None,
trace_lifecycle: "Optional[Literal['static', 'stream']]" = None,
traces_sampler: "Optional[TracesSampler]" = None,
profiles_sample_rate: "Optional[float]" = None,
profiles_sampler: "Optional[TracesSampler]" = None,
profiler_mode: "Optional[ProfilerMode]" = None,
profile_lifecycle: 'Literal["manual", "trace"]' = "manual",
profile_session_sample_rate: "Optional[float]" = None,
Expand Down Expand Up @@ -1705,16 +1703,6 @@ def __init__(
Return a string for that repr value to be used or `None` to continue serializing how Sentry would have
done it anyway.

:param profiles_sample_rate: A number between `0` and `1`, controlling the percentage chance a given sampled
transaction will be profiled.

(`0` represents 0% while `1` represents 100%.) Applies equally to all transactions created in the app.

This is relative to the tracing sample rate - e.g. `0.5` means 50% of sampled transactions will be
profiled.

:param profiles_sampler:

:param profiler_mode:

:param profile_lifecycle:
Expand Down
8 changes: 0 additions & 8 deletions sentry_sdk/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ def add_transaction(
) -> None:
self.add_item(Item(payload=PayloadRef(json=transaction), type="transaction"))

def add_profile(
self,
profile: "Any",
) -> None:
self.add_item(Item(payload=PayloadRef(json=profile), type="profile"))

def add_profile_chunk(
self,
profile_chunk: "Any",
Expand Down Expand Up @@ -259,8 +253,6 @@ def data_category(self) -> "EventDataCategory":
return "trace_metric"
elif ty == "client_report":
return "internal"
elif ty == "profile":
return "profile"
elif ty == "profile_chunk":
return "profile_chunk"
elif ty == "check_in":
Expand Down
4 changes: 0 additions & 4 deletions sentry_sdk/integrations/django/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ async def sentry_wrapped_callback(
if current_scope.transaction is not None:
current_scope.transaction.update_active_thread()

sentry_scope = sentry_sdk.get_isolation_scope()
if sentry_scope.profile is not None:
sentry_scope.profile.update_active_thread_id()

integration = client.get_integration(DjangoIntegration)
if not integration or not integration.middleware_spans:
return await callback(request, *args, **kwargs)
Expand Down
6 changes: 0 additions & 6 deletions sentry_sdk/integrations/django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ def sentry_wrapped_callback(request: "Any", *args: "Any", **kwargs: "Any") -> "A
if current_scope.transaction is not None:
current_scope.transaction.update_active_thread()

sentry_scope = sentry_sdk.get_isolation_scope()
# set the active thread id to the handler thread for sync views
# this isn't necessary for async views since that runs on main
if sentry_scope.profile is not None:
sentry_scope.profile.update_active_thread_id()

integration = client.get_integration(DjangoIntegration)
if not integration or not integration.middleware_spans:
return callback(request, *args, **kwargs)
Expand Down
4 changes: 0 additions & 4 deletions sentry_sdk/integrations/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ def _sentry_call(*args: "Any", **kwargs: "Any") -> "Any":
elif current_scope.transaction is not None:
current_scope.transaction.update_active_thread()

sentry_scope = sentry_sdk.get_isolation_scope()
if sentry_scope.profile is not None:
sentry_scope.profile.update_active_thread_id()

return old_call(*args, **kwargs)

_sentry_call._sentry_is_patched = True # type: ignore[attr-defined]
Expand Down
4 changes: 0 additions & 4 deletions sentry_sdk/integrations/quart.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ def _sentry_func(*args: "Any", **kwargs: "Any") -> "Any":
if current_scope.transaction is not None:
current_scope.transaction.update_active_thread()

sentry_scope = sentry_sdk.get_isolation_scope()
if sentry_scope.profile is not None:
sentry_scope.profile.update_active_thread_id()

return old_func(*args, **kwargs)

return old_decorator(_sentry_func)
Expand Down
2 changes: 0 additions & 2 deletions sentry_sdk/integrations/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,6 @@ def _sentry_sync_func(*args: "Any", **kwargs: "Any") -> "Any":
current_scope.transaction.update_active_thread()

sentry_scope = sentry_sdk.get_isolation_scope()
if sentry_scope.profile is not None:
sentry_scope.profile.update_active_thread_id()

request = args[0]

Expand Down
22 changes: 0 additions & 22 deletions sentry_sdk/profiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@
stop_profile_session,
stop_profiler,
)
from sentry_sdk.profiler.transaction_profiler import (
MAX_PROFILE_DURATION_NS,
PROFILE_MINIMUM_SAMPLES,
GeventScheduler,
Profile,
Scheduler,
ThreadScheduler,
has_profiling_enabled,
setup_profiler,
teardown_profiler,
)
from sentry_sdk.profiler.utils import (
DEFAULT_SAMPLING_FREQUENCY,
MAX_STACK_DEPTH,
Expand All @@ -29,17 +18,6 @@
"start_profiler",
"stop_profile_session", # TODO: Deprecate this in favor of `stop_profiler`
"stop_profiler",
# DEPRECATED: The following was re-exported for backwards compatibility. It
# will be removed from sentry_sdk.profiler in a future release.
"MAX_PROFILE_DURATION_NS",
"PROFILE_MINIMUM_SAMPLES",
"Profile",
"Scheduler",
"ThreadScheduler",
"GeventScheduler",
"has_profiling_enabled",
"setup_profiler",
"teardown_profiler",
"DEFAULT_SAMPLING_FREQUENCY",
"MAX_STACK_DEPTH",
"get_frame_name",
Expand Down
Loading
Loading