You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/07 16:17:36 UTC

[GitHub] [airflow] tlskr opened a new issue #21395: Airflow Not Automatically Sending Errors to Sentry

tlskr opened a new issue #21395:
URL: https://github.com/apache/airflow/issues/21395


   ### Apache Airflow version
   
   2.2.3 (latest released)
   
   ### What happened
   
   I have configured Airflow to set sentry_on and sentry_dsn through environment variables.  When I deliberately raise an Exception no error is sent to Sentry.
   
   I have tried patching Sentry.enrich_errors to log a call, but when patched nothing was logged when an exception is raised.
   
   ### What you expected to happen
   
   I expect the Airflow instance to send an error message to Sentry on an exception.
   
   When Sentry.enrich_errors is patched, I expect it to log a message when an exception is raised.
   
   ### How to reproduce
   
   I have set sentry_on and sentry_dsn in environment variables (AIRFLOW__SENTRY__SENTRY_ON and AIRFLOW__SENTRY__SENTRY_DSN), and these appear in the Airflow GUI Admin > Configuration display.
   
   I run the following code on my local instance to raise an exception.  
   
   Note:
   -- when the enrich_errors patch is commented out, no error message is sent to Sentry.
   -- I am confident in the sentry_dsn value, because our custom code sending to Sentry in on_failure_callback works.
   
   ```
   import logging
   from datetime import datetime, timedelta
   from functools import wraps
   
   from airflow import DAG
   from airflow.configuration import conf
   from airflow.exceptions import AirflowException
   from airflow.operators.python import PythonOperator
   from airflow.sentry import Sentry
   
   logging.info("sentry_on is %s" % str(conf.getboolean("sentry", "sentry_on", fallback=False)))
   
   
   class MySentry:
       def enrich_errors(self, func):
           """ Patch for enrich_errors to log if it has been called.  """
   
           @wraps(func)
           def wrapper(_self, *args, **kwargs):
               logging.info("MySentry.enrich_errors has been called")
               return func(_self, *args, **kwargs)
   
           return wrapper
   
   # Sentry.enrich_errors = MySentry.enrich_errors
   
   def throw_exception_function():
       raise Exception("still another exception thrown on purpose, no DAG or Task on_failure_callback, patch enrich_errors")
   
   
   with DAG(
       dag_id="deliberate_exception__patch_enrich_errors",
       default_args={
           "owner": "DAG owner",
           "depends_on_past": False,
           "start_date": datetime(2017, 1, 1),
           "retries": 0,
           "retry_delay": timedelta(minutes=0),
       },
       description="Deliberately throws exception without on_failure_callback for DAG or task; patches enrich_errors",
       schedule_interval=None,
       catchup=False,
   ) as dag:
   
       Sentry.enrich_errors = MySentry.enrich_errors
   
       exception_task = PythonOperator(
           task_id="exception_task",
           python_callable=throw_exception_function,
       )
   ```
   
   
   ### Operating System
   
   Linux and OSX
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-amazon==2.4.0
   apache-airflow-providers-cncf-kubernetes==2.2.0
   apache-airflow-providers-datadog==2.0.1
   apache-airflow-providers-ftp==2.0.1
   apache-airflow-providers-http==2.0.1
   apache-airflow-providers-imap==2.1.0
   apache-airflow-providers-jdbc==2.0.1
   apache-airflow-providers-microsoft-azure==3.4.0
   apache-airflow-providers-mongo==2.2.0
   apache-airflow-providers-postgres==2.4.0
   apache-airflow-providers-sftp==2.1.1
   apache-airflow-providers-slack==4.1.0
   apache-airflow-providers-snowflake==2.3.1
   apache-airflow-providers-sqlite==2.0.1
   apache-airflow-providers-ssh==2.2.0
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Caerbannog commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
Caerbannog commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1065225367


   Disregard my last message.
   5 days later I looked at my Sentry console again, and it was full of the exceptions I was expecting.
   So either I messed up last time, or Sentry had a backlog of events that took time to process. I probably messed up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] wolfier commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
wolfier commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1035857278


   Which of `sentry-sdk` version is installed in the environment?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Caerbannog commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
Caerbannog commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1059959353


   Same problem here. Nothing is sent to Sentry servers after an error. No sentry message in the log.
   Yet ConfiguredSentry() in airflow.sentry seems to have been initialized so it's not a sentry_on config problem.
   
   Airflow 2.2.3 installed with the docker image
   sentry-sdk 1.5.6 from apache-airflow[sentry]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tlskr commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
tlskr commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1036300474


   We are on 1.5.2.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1031651082


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] tlskr commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
tlskr commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1031833167


   We're using `sentry-sdk`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] seancaulfield commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
seancaulfield commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1033145460


   We have both the `sentry` extra for `apache-airflow` and the `sentry-sdk` Python package installed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on issue #21395: Airflow Not Automatically Sending Errors to Sentry

Posted by GitBox <gi...@apache.org>.
ashb commented on issue #21395:
URL: https://github.com/apache/airflow/issues/21395#issuecomment-1031811016


   Just to confirm -- do you have the `apache-airflow[sentry]` extra, or `sentry-sdk` installed?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org