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

Sentry before send fallback #18980

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self):
", ".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)
Expand Down
20 changes: 20 additions & 0 deletions tests/core/test_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ def sentry(self):

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.
Expand Down Expand Up @@ -135,3 +148,10 @@ def test_before_send(self, sentry_sdk, sentry):
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()