-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pipeline) : use Sentry as main notifier
Sentry is a much better tool than our little code executor, at least in terms of not spamming our alerting channel. We can precisely configure how and when we want to be notified, what is important, discuss about issues, etc. It also now directly links every issue to a particular commit, making it easier to identify regressions. The flow changes a little bit as the logs are in the Sentry issue, not directly linked in the Slack message, but I hope we'll be able to triage much better.
- Loading branch information
Showing
12 changed files
with
48 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
from datetime import datetime | ||
|
||
from sentry_sdk import configure_scope | ||
|
||
|
||
def task_failure_callback(context): | ||
with configure_scope() as scope: | ||
dag_id = context.get("dag").dag_id | ||
task_id = context.get("task_instance").task_id | ||
execution_date = context.get("execution_date") | ||
|
||
if isinstance(execution_date, datetime): | ||
execution_date = execution_date.isoformat() | ||
|
||
scope.set_tag("dag_id", dag_id) | ||
scope.set_tag("task_id", task_id) | ||
scope.set_tag("execution_date", execution_date) | ||
task_instance = context.get("task_instance") | ||
scope.set_tag("airflow_logs_url", task_instance.log_url) | ||
|
||
github_base_url = "https://github.com/gip-inclusion/data-inclusion" | ||
if commit_sha := os.getenv("AIRFLOW__SENTRY__RELEASE", None): | ||
scope.set_tag("github_commit_url", f"{github_base_url}/commit/{commit_sha}") | ||
|
||
|
||
def notify_failure_args(): | ||
return { | ||
"on_failure_callback": task_failure_callback, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters