mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(reports): Add celery task execution ID to email notification logs (#35807)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
5218b4eea2
commit
61c68f7b8f
@@ -507,6 +507,7 @@ class BaseReportState:
|
||||
"dashboard_id": dashboard_id,
|
||||
"owners": self._report_schedule.owners,
|
||||
"slack_channels": slack_channels,
|
||||
"execution_id": str(self._execution_id),
|
||||
}
|
||||
return log_data
|
||||
|
||||
|
||||
@@ -253,7 +253,11 @@ class EmailNotification(BaseNotification): # pylint: disable=too-few-public-met
|
||||
header_data=content.header_data,
|
||||
)
|
||||
logger.info(
|
||||
"Report sent to email, notification content is %s", content.header_data
|
||||
"Report sent to email, task_id: %s, notification content is %s",
|
||||
content.header_data.get("execution_id")
|
||||
if content.header_data
|
||||
else None,
|
||||
content.header_data,
|
||||
)
|
||||
except SupersetErrorsException as ex:
|
||||
raise NotificationError(
|
||||
|
||||
@@ -216,6 +216,7 @@ class HeaderDataType(TypedDict):
|
||||
chart_id: int | None
|
||||
dashboard_id: int | None
|
||||
slack_channels: list[str] | None
|
||||
execution_id: str | None
|
||||
|
||||
|
||||
class DatasourceDict(TypedDict):
|
||||
|
||||
@@ -117,4 +117,4 @@ def test_report_with_header_data(
|
||||
assert header_data.get("notification_format") == report_schedule.report_format
|
||||
assert header_data.get("notification_source") == ReportSourceFormat.DASHBOARD
|
||||
assert header_data.get("notification_type") == report_schedule.type
|
||||
assert len(send_email_smtp_mock.call_args.kwargs["header_data"]) == 7
|
||||
assert len(send_email_smtp_mock.call_args.kwargs["header_data"]) == 8
|
||||
|
||||
@@ -64,6 +64,7 @@ def test_log_data_with_chart(mocker: MockerFixture) -> None:
|
||||
"dashboard_id": None,
|
||||
"owners": [1, 2],
|
||||
"slack_channels": None,
|
||||
"execution_id": "execution_id_example",
|
||||
}
|
||||
|
||||
assert result == expected_result
|
||||
@@ -94,6 +95,7 @@ def test_log_data_with_dashboard(mocker: MockerFixture) -> None:
|
||||
"dashboard_id": 123,
|
||||
"owners": [1, 2],
|
||||
"slack_channels": None,
|
||||
"execution_id": "execution_id_example",
|
||||
}
|
||||
|
||||
assert result == expected_result
|
||||
@@ -128,6 +130,7 @@ def test_log_data_with_email_recipients(mocker: MockerFixture) -> None:
|
||||
"dashboard_id": 123,
|
||||
"owners": [1, 2],
|
||||
"slack_channels": [],
|
||||
"execution_id": "execution_id_example",
|
||||
}
|
||||
|
||||
assert result == expected_result
|
||||
@@ -162,6 +165,7 @@ def test_log_data_with_slack_recipients(mocker: MockerFixture) -> None:
|
||||
"dashboard_id": 123,
|
||||
"owners": [1, 2],
|
||||
"slack_channels": ["channel_1", "channel_2"],
|
||||
"execution_id": "execution_id_example",
|
||||
}
|
||||
|
||||
assert result == expected_result
|
||||
@@ -195,6 +199,7 @@ def test_log_data_no_owners(mocker: MockerFixture) -> None:
|
||||
"dashboard_id": 123,
|
||||
"owners": [],
|
||||
"slack_channels": ["channel_1", "channel_2"],
|
||||
"execution_id": "execution_id_example",
|
||||
}
|
||||
|
||||
assert result == expected_result
|
||||
@@ -230,6 +235,7 @@ def test_log_data_with_missing_values(mocker: MockerFixture) -> None:
|
||||
"dashboard_id": None,
|
||||
"owners": [1, 2],
|
||||
"slack_channels": ["channel_1", "channel_2"],
|
||||
"execution_id": "execution_id_example",
|
||||
}
|
||||
|
||||
assert result == expected_result
|
||||
|
||||
@@ -47,6 +47,7 @@ def test_render_description_with_html() -> None:
|
||||
"chart_id": None,
|
||||
"dashboard_id": None,
|
||||
"slack_channels": None,
|
||||
"execution_id": "test-execution-id",
|
||||
},
|
||||
)
|
||||
email_body = (
|
||||
@@ -91,6 +92,7 @@ def test_email_subject_with_datetime() -> None:
|
||||
"chart_id": None,
|
||||
"dashboard_id": None,
|
||||
"slack_channels": None,
|
||||
"execution_id": "test-execution-id",
|
||||
},
|
||||
)
|
||||
subject = EmailNotification(
|
||||
|
||||
@@ -36,6 +36,7 @@ def mock_header_data() -> HeaderDataType:
|
||||
"chart_id": None,
|
||||
"dashboard_id": None,
|
||||
"slack_channels": ["some_channel"],
|
||||
"execution_id": "test-execution-id",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user