Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

File crawler errors under their own Sentry environment

Claude46fc2ce0b441
diff --git a/mwmbl/crawler/app.py b/mwmbl/crawler/app.py
index fef988f..5a4861b 100644
--- a/mwmbl/crawler/app.py
+++ b/mwmbl/crawler/app.py
@@ -387,9 +387,16 @@ def _crawler_error_event(report: CrawlerErrorReport, user_id: int) -> dict:
"crawler_version": report.crawler_version,
"crawler_device": report.device_name,
}
+ # Set explicitly, or the SDK fills environment, release and server_name in from the server
+ # itself, filing a volunteer's crawler bug under production on our host. Its own
+ # environment puts crawler issues behind Sentry's environment filter, apart from ours.
+ release = f"mwmbl-crawler@{report.crawler_version}" if report.crawler_version else None
return {
"level": "error",
"logger": "mwmbl.crawler.remote",
+ "environment": "crawler",
+ "release": release,
+ "server_name": report.device_name,
"exception": {
"values": [
{
diff --git a/test/test_crawler_error_reports.py b/test/test_crawler_error_reports.py
index f579c47..4459d80 100644
--- a/test/test_crawler_error_reports.py
+++ b/test/test_crawler_error_reports.py
@@ -63,7 +63,9 @@ def test_a_report_goes_to_sentry_as_an_exception_with_its_traceback():
"run_indexing_continuously",
"run_indexing",
]
- assert event["tags"]["crawler_version"] == "1.2.0"
+ assert event["environment"] == "crawler"
+ assert event["release"] == "[email protected]"
+ assert event["server_name"] == "crawler-3f7a1c9e"
assert event["user"] == {"id": str(user.id)}