Skip to content
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

feat(issues): Add environment to regression activity #55114

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions src/sentry/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1979,9 +1979,11 @@ def _handle_regression(group: Group, event: Event, release: Optional[Release]) -
)

if is_regression:
environment_name = event.get_tag("environment")
activity_data: dict[str, str | bool] = {
"event_id": event.event_id,
"version": release.version if release else "",
"environment": environment_name if environment_name else "",
}
if resolved_in_activity and release:
activity_data.update(
Expand Down
38 changes: 38 additions & 0 deletions tests/sentry/event_manager/test_event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,44 @@ def test_marks_as_unresolved_with_new_release(

mock_send_activity_notifications_delay.assert_called_once_with(activity.id)

@mock.patch("sentry.event_manager.plugin_is_regression")
def test_sets_regression_environment(self, plugin_is_regression):
plugin_is_regression.return_value = True
manager = EventManager(
make_event(
event_id="a" * 32,
checksum="a" * 32,
timestamp=time() - 50000, # need to work around active_at
)
)
event = manager.save(self.project.id)

assert event.group is not None
group = event.group

group.update(status=GroupStatus.RESOLVED, substatus=None)

activity = Activity.objects.create(
group=group,
project=group.project,
type=ActivityType.SET_RESOLVED_IN_RELEASE.value,
data={"version": ""},
)

manager = EventManager(
make_event(
event_id="c" * 32, checksum="a" * 32, timestamp=time(), environment="staging"
)
)
event = manager.save(self.project.id)
assert event.group_id == group.id

group = Group.objects.get(id=group.id)
assert group.status == GroupStatus.UNRESOLVED

activity = Activity.objects.get(group=group, type=ActivityType.SET_REGRESSION.value)
assert activity.data["environment"] == "staging"

@mock.patch("sentry.tasks.activity.send_activity_notifications.delay")
@mock.patch("sentry.event_manager.plugin_is_regression")
def test_that_release_in_latest_activity_prior_to_regression_is_not_overridden(
Expand Down