Skip to content

fix(autofix): Fix log format #92152

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 2 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 10 additions & 4 deletions src/sentry/seer/autofix.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@
TIMEOUT_SECONDS = 60 * 30 # 30 minutes


def _get_logs_for_event(event: Event | GroupEvent, project: Project) -> list[dict] | None:
def _get_logs_for_event(
event: Event | GroupEvent, project: Project
) -> dict[str, list[dict]] | None:
trace_id = event.trace_id
if not trace_id:
return None
return {
"logs": [],
}

projects_qs = Project.objects.filter(
organization=project.organization, status=ObjectStatus.ACTIVE
Expand Down Expand Up @@ -136,7 +140,9 @@ def _get_logs_for_event(event: Event | GroupEvent, project: Project) -> list[dic
prev_log["consecutive_count"] = count
merged_logs.append(prev_log)

return merged_logs
return {
"logs": merged_logs,
}


def build_spans_tree(spans_data: list[dict]) -> list[dict]:
Expand Down Expand Up @@ -782,7 +788,7 @@ def _call_autofix(
serialized_event: dict[str, Any],
profile: dict[str, Any] | None,
trace_tree: dict[str, Any] | None,
logs: list[dict] | None,
logs: dict[str, list[dict]] | None,
instruction: str | None = None,
timeout_secs: int = TIMEOUT_SECONDS,
pr_to_comment_on_url: str | None = None,
Expand Down
5 changes: 3 additions & 2 deletions tests/sentry/seer/test_autofix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,8 +1638,9 @@ def test_merging_consecutive_logs(self, mock_query):
project = self.project
# Patch project.organization to avoid DB hits
project.organization = self.organization
merged = _get_logs_for_event(event, project)
assert merged is not None
result = _get_logs_for_event(event, project)
assert result is not None
merged = result["logs"]
# The first two "foo" logs should be merged (consecutive), the last "foo" is not consecutive
foo_merged = [
log for log in merged if log["message"] == "foo" and log.get("consecutive_count") == 2
Expand Down
Loading