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

chore(pipeline) : use Sentry as main notifier #369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vperron
Copy link
Contributor

@vperron vperron commented Jan 15, 2025

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.

The goal here is to use the opportunity of migrating to Slack to kill 2 birds with one stone.

Example of the custom info added to Sentry :

image

image

@vperron vperron requested a review from vmttn as a code owner January 15, 2025 15:59
@vperron vperron force-pushed the vperron/notify-sentry branch from 9738fc3 to 728b6ae Compare January 15, 2025 16:38
Copy link
Contributor

@vmttn vmttn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execution_date c'est déprécié depuis bien longtemps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oups :/ en effet

from sentry_sdk import configure_scope


def task_failure_callback(context):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est assez hacky, puisque la callback ne fait rien d'autres que configurer une scope

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui, le nommage est naze, j'ai poussé hier avant de partir mais j'aurais dû faire un draft, toutes mes excuses 🙏

@@ -229,6 +229,7 @@ resource "null_resource" "up" {
AIRFLOW_WWW_USER_PASSWORD='${var.airflow_admin_password}'
AIRFLOW__CORE__FERNET_KEY='${var.airflow__core__fernet_key}'
AIRFLOW__SENTRY__SENTRY_DSN='${var.airflow__sentry__sentry_dsn}'
AIRFLOW__SENTRY__RELEASE='${var.stack_version}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas fan du nommage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est parce que la variable release de la conf de sentry permet de lier une version du soft en question:
https://docs.sentry.io/product/sentry-basics/integrate-backend/configuration-options/

C'est peut etre un peu overkill, on peut juste mettre un tag avec le SHA et une URL vers le commit, mais je me disais que utiliser des maintenant la notion de "release" est un plus (les issues sont automatiquement liées au commit suspect, etc)

image

@vperron
Copy link
Contributor Author

vperron commented Jan 16, 2025

Si on utilise simplement le logging de base (comme aujourd'hui donc) on perd a minima le lien direct vers les logs Airflow depuis l'issue, que l'on avait jusqu'à aujourd'hui dans Mattermost.

Maintenant là où tu as raison c'est que on peut probablement utiliser le before_send pour enrichir le contexte, ça permet de ne pas annoter chaque DAG avec les arguments en question. Mais on aura pas aussi facilement accès aux propriétés du DAG, à tester.

Je trouve que configurer une release apporte un net plus car on peut immédiatement dire quel commit a fait apparaitre ou réapparaitre tel probleme.
Enfin avoir un lien direct vers le commit dans GH est aussi un plus assez pratique et terminé en 2/3 lignes de code, je trouve que c'est utile...

Enfin, tagger le nom du DAG et de la tâche est négligeable mais permet d'identifier super rapidement dans le bandeau de
droite les conditions de telle ou telle erreur, mais j'avoue que c'est peut etre un poil moins utile. Juste les erreurs sont assez riches en contenu (stacktrace, logs, breadcrumbs, ...) et je n'aime pas parser tout ça avec les yeux pour comprendre rapidement ce qui a planté, mais c'est une préférence personnelle.

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.
@vperron vperron force-pushed the vperron/notify-sentry branch from 728b6ae to ab05c24 Compare January 16, 2025 08:30
@vperron vperron requested a review from vmttn January 16, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants