Skip to content

Commit 7af9c8b

Browse files
authored
chore(profiling): Remove profile context from sdk (getsentry#2013)
The profile context can be populated by the relay automatically. No need to do this in the SDK. This also means that if the profile has to be dropped by relay due to rate limits or any reason, we won't render a bad link on the transaction to a non-existent profile.
1 parent 0f3f2ed commit 7af9c8b

File tree

3 files changed

+0
-36
lines changed

3 files changed

+0
-36
lines changed

sentry_sdk/profiler.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,6 @@ def _set_initial_sampling_decision(self, sampling_context):
574574
)
575575
)
576576

577-
def get_profile_context(self):
578-
# type: () -> ProfileContext
579-
return {"profile_id": self.event_id}
580-
581577
def start(self):
582578
# type: () -> None
583579
if not self.sampled or self.active:

sentry_sdk/tracing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,6 @@ def finish(self, hub=None, end_timestamp=None):
631631

632632
if self._profile is not None and self._profile.valid():
633633
event["profile"] = self._profile
634-
contexts.update({"profile": self._profile.get_profile_context()})
635634
self._profile = None
636635

637636
event["measurements"] = self._measurements

tests/test_profiler.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -233,37 +233,6 @@ def test_profiles_sampler(
233233
assert len(items["profile"]) == profile_count
234234

235235

236-
@mock.patch("sentry_sdk.profiler.PROFILE_MINIMUM_SAMPLES", 0)
237-
def test_profile_context(
238-
sentry_init,
239-
capture_envelopes,
240-
teardown_profiling,
241-
):
242-
sentry_init(
243-
traces_sample_rate=1.0,
244-
_experiments={"profiles_sample_rate": 1.0},
245-
)
246-
247-
envelopes = capture_envelopes()
248-
249-
with start_transaction(name="profiling"):
250-
pass
251-
252-
items = defaultdict(list)
253-
for envelope in envelopes:
254-
for item in envelope.items:
255-
items[item.type].append(item)
256-
257-
assert len(items["transaction"]) == 1
258-
assert len(items["profile"]) == 1
259-
260-
transaction = items["transaction"][0]
261-
profile = items["profile"][0]
262-
assert transaction.payload.json["contexts"]["profile"] == {
263-
"profile_id": profile.payload.json["event_id"],
264-
}
265-
266-
267236
def test_minimum_unique_samples_required(
268237
sentry_init,
269238
capture_envelopes,

0 commit comments

Comments
 (0)