Skip to content

Commit 66b5981

Browse files
authored
fix(event_manager): Resolve TypeError while recording first insight span (#87123)
Fixes a regression introduced in #86604 that resulted in a captured `TypeError` when recording the first insight span for a project. We switched from using signals, which are prohibited in `EventManager.save`, to directly calling the onboarding receiver function. In this specific instance, we missed that the function was decorated, and the import resulted in `None`. For an unknown reason, the resulting `TypeError` did not show up in Sentry. Projects that have not recorded these flags since the regression was rolled out will be flagged when they ingest the next span of the corresponding insights module.
1 parent 7736c94 commit 66b5981

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/sentry/receivers/onboarding.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ def record_first_cron_checkin(project, monitor_id, **kwargs):
375375
)
376376

377377

378-
@first_insight_span_received.connect(weak=False)
379378
def record_first_insight_span(project, module, **kwargs):
380379
flag = None
381380
if module == InsightModules.HTTP:
@@ -410,6 +409,9 @@ def record_first_insight_span(project, module, **kwargs):
410409
)
411410

412411

412+
first_insight_span_received.connect(record_first_insight_span, weak=False)
413+
414+
413415
@member_invited.connect(weak=False)
414416
def record_member_invited(member, user, **kwargs):
415417
OrganizationOnboardingTask.objects.record(

tests/sentry/event_manager/test_event_manager.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,49 @@ def test_transaction_sampler_and_receive_mock_called(
16621662
mock.call(ClustererNamespace.TRANSACTIONS, self.project, "wait")
16631663
]
16641664

1665+
def test_first_insight_span(self) -> None:
1666+
event_data = make_event(
1667+
transaction="test_transaction",
1668+
contexts={
1669+
"trace": {
1670+
"parent_span_id": "bce14471e0e9654d",
1671+
"op": "foobar",
1672+
"trace_id": "a0fa8803753e40fd8124b21eeb2986b5",
1673+
"span_id": "bf5be759039ede9a",
1674+
}
1675+
},
1676+
spans=[
1677+
{
1678+
"trace_id": "a0fa8803753e40fd8124b21eeb2986b5",
1679+
"parent_span_id": "bf5be759039ede9a",
1680+
"span_id": "a" * 16,
1681+
"start_timestamp": 0,
1682+
"timestamp": 1,
1683+
"same_process_as_parent": True,
1684+
"op": "db.redis",
1685+
"description": "EXEC *",
1686+
"sentry_tags": {
1687+
"description": "EXEC *",
1688+
"category": "db",
1689+
"op": "db.redis",
1690+
"transaction": "/app/index",
1691+
},
1692+
}
1693+
],
1694+
timestamp="2019-06-14T14:01:40Z",
1695+
start_timestamp="2019-06-14T14:01:40Z",
1696+
type="transaction",
1697+
)
1698+
1699+
assert not self.project.flags.has_insights_db
1700+
1701+
manager = EventManager(event_data)
1702+
manager.normalize()
1703+
manager.save(self.project.id)
1704+
1705+
self.project.refresh_from_db()
1706+
assert self.project.flags.has_insights_db
1707+
16651708
def test_sdk(self) -> None:
16661709
manager = EventManager(make_event(**{"sdk": {"name": "sentry-unity", "version": "1.0"}}))
16671710
manager.normalize()

0 commit comments

Comments
 (0)