This is an automated email from the ASF dual-hosted git repository. jedcunningham pushed a commit to branch v2-2-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 1a45e1ead6f5a76b4e21b2ea49c1ba6ce03c72f3 Author: Leon Smith <_...@leonmarksmith.com> AuthorDate: Thu Oct 14 15:33:31 2021 +0100 Sentry before send fallback (#18980) (cherry picked from commit 1edcd420eca227dadf8653917772ee27de945996) --- airflow/sentry.py | 2 +- tests/core/test_sentry.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/airflow/sentry.py b/airflow/sentry.py index 9cc9f9b..948ecb8 100644 --- a/airflow/sentry.py +++ b/airflow/sentry.py @@ -109,7 +109,7 @@ if conf.getboolean("sentry", 'sentry_on', fallback=False): ", ".join(unsupported_options), ) - sentry_config_opts['before_send'] = conf.getimport('sentry', 'before_send') + sentry_config_opts['before_send'] = conf.getimport('sentry', 'before_send', fallback=None) if dsn: sentry_sdk.init(dsn=dsn, integrations=integrations, **sentry_config_opts) diff --git a/tests/core/test_sentry.py b/tests/core/test_sentry.py index 59cc831..d68e37c 100644 --- a/tests/core/test_sentry.py +++ b/tests/core/test_sentry.py @@ -106,6 +106,19 @@ class TestSentryHook: importlib.reload(sentry) + @pytest.fixture + def sentry_minimum(self): + """ + Minimum sentry config + """ + with conf_vars({('sentry', 'sentry_on'): 'True'}): + from airflow import sentry + + importlib.reload(sentry) + yield sentry.Sentry + + importlib.reload(sentry) + def test_add_tagging(self, sentry, task_instance): """ Test adding tags. @@ -135,3 +148,10 @@ class TestSentryHook: called = sentry_sdk.call_args[1]['before_send'] expected = import_string('tests.core.test_sentry.before_send') assert called == expected + + def test_before_send_minimum_config(self, sentry_sdk, sentry_minimum): + """ + Test before_send doesn't raise an exception when not set + """ + assert sentry_minimum + sentry_sdk.assert_called_once()