Skip to content
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
6 changes: 5 additions & 1 deletion airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,11 @@
default: "airflow@example.com"
- name: sentry
description: |
Sentry (https://docs.sentry.io) integration
Sentry (https://docs.sentry.io) integration. Here you can supply
additional configuration options based on the Python platform. See:
https://docs.sentry.io/error-reporting/configuration/?platform=python.
Unsupported options: ``integrations``, ``in_app_include``, ``in_app_exclude``,
``ignore_errors``, ``before_breadcrumb``, ``before_send``, ``transport``.
options:
- name: sentry_dsn
description: ~
Expand Down
6 changes: 5 additions & 1 deletion airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,11 @@ smtp_mail_from = airflow@example.com

[sentry]

# Sentry (https://docs.sentry.io) integration
# Sentry (https://docs.sentry.io) integration. Here you can supply
# additional configuration options based on the Python platform. See:
# https://docs.sentry.io/error-reporting/configuration/?platform=python.
# Unsupported options: ``integrations``, ``in_app_include``, ``in_app_exclude``,
# ``ignore_errors``, ``before_breadcrumb``, ``before_send``, ``transport``.
sentry_dsn =

[celery]
Expand Down
26 changes: 23 additions & 3 deletions airflow/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class ConfiguredSentry(DummySentry):
)
SCOPE_CRUMBS = frozenset(("task_id", "state", "operator", "duration"))

UNSUPPORTED_SENTRY_OPTIONS = frozenset(
("integrations", "in_app_include", "in_app_exclude", "ignore_errors",
"before_breadcrumb", "before_send", "transport")
)

def __init__(self):
"""
Initialize the Sentry SDK.
Expand All @@ -86,13 +91,28 @@ def __init__(self):
sentry_celery = CeleryIntegration()
integrations.append(sentry_celery)

dsn = conf.get("sentry", "sentry_dsn")
dsn = None
sentry_config_opts = conf.getsection("sentry") or {}
Comment thread
Moress marked this conversation as resolved.
Outdated
Comment thread
Moress marked this conversation as resolved.
Outdated
if sentry_config_opts:
old_way_dsn = sentry_config_opts.pop("sentry_dsn", None)
new_way_dsn = sentry_config_opts.pop("dsn", None)
# supported backward compability with old way dsn option
dsn = old_way_dsn or new_way_dsn

unsupported_options = self.UNSUPPORTED_SENTRY_OPTIONS.intersection(
sentry_config_opts.keys())
if unsupported_options:
log.warning(
"There are unsupported options in [sentry] section: %s",
", ".join(unsupported_options)
)

if dsn:
init(dsn=dsn, integrations=integrations)
init(dsn=dsn, integrations=integrations, **sentry_config_opts)
else:
# Setting up Sentry using environment variables.
log.debug("Defaulting to SENTRY_DSN in environment.")
init(integrations=integrations)
init(integrations=integrations, **sentry_config_opts)

def add_tagging(self, task_instance):
"""
Expand Down
3 changes: 3 additions & 0 deletions docs/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Add your ``SENTRY_DSN`` to your configuration file e.g. ``airflow.cfg`` under ``
.. note::
If this value is not provided, the SDK will try to read it from the ``SENTRY_DSN`` environment variable.

You can supply `additional configuration options <https://docs.sentry.io/error-reporting/configuration/?platform=python>`__ based on the Python platform via [sentry] section.
Comment thread
Moress marked this conversation as resolved.
Outdated
Unsupported options: ``integrations``, ``in_app_include``, ``in_app_exclude``, ``ignore_errors``, ``before_breadcrumb``, ``before_send``, ``transport``.

Tags
-----

Expand Down