Skip to content

fix(event_manager): Resolve TypeError while recording first insight span #87123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
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
4 changes: 3 additions & 1 deletion src/sentry/receivers/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ def record_first_cron_checkin(project, monitor_id, **kwargs):
)


@first_insight_span_received.connect(weak=False)
def record_first_insight_span(project, module, **kwargs):
flag = None
if module == InsightModules.HTTP:
Expand Down Expand Up @@ -410,6 +409,9 @@ def record_first_insight_span(project, module, **kwargs):
)


first_insight_span_received.connect(record_first_insight_span, weak=False)


@member_invited.connect(weak=False)
def record_member_invited(member, user, **kwargs):
OrganizationOnboardingTask.objects.record(
Expand Down
43 changes: 43 additions & 0 deletions tests/sentry/event_manager/test_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,49 @@ def test_transaction_sampler_and_receive_mock_called(
mock.call(ClustererNamespace.TRANSACTIONS, self.project, "wait")
]

def test_first_insight_span(self) -> None:
event_data = make_event(
transaction="test_transaction",
contexts={
"trace": {
"parent_span_id": "bce14471e0e9654d",
"op": "foobar",
"trace_id": "a0fa8803753e40fd8124b21eeb2986b5",
"span_id": "bf5be759039ede9a",
}
},
spans=[
{
"trace_id": "a0fa8803753e40fd8124b21eeb2986b5",
"parent_span_id": "bf5be759039ede9a",
"span_id": "a" * 16,
"start_timestamp": 0,
"timestamp": 1,
"same_process_as_parent": True,
"op": "db.redis",
"description": "EXEC *",
"sentry_tags": {
"description": "EXEC *",
"category": "db",
"op": "db.redis",
"transaction": "/app/index",
},
}
],
timestamp="2019-06-14T14:01:40Z",
start_timestamp="2019-06-14T14:01:40Z",
type="transaction",
)

assert not self.project.flags.has_insights_db

manager = EventManager(event_data)
manager.normalize()
manager.save(self.project.id)

self.project.refresh_from_db()
assert self.project.flags.has_insights_db

def test_sdk(self) -> None:
manager = EventManager(make_event(**{"sdk": {"name": "sentry-unity", "version": "1.0"}}))
manager.normalize()
Expand Down
Loading