This is an automated email from the ASF dual-hosted git repository.
kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new ac3bd8a Support extra config options for Sentry (#8911)
ac3bd8a is described below
commit ac3bd8a577942fc27f8d7d8f8b047e1841ea0f99
Author: Bolgov Andrey <[email protected]>
AuthorDate: Fri Jul 10 01:34:56 2020 +0300
Support extra config options for Sentry (#8911)
For now only dsn can be configured through the airflow.cfg. Need support
'http_proxy' option for example (it can't be configured through the environment
variables). This change implements solution for supporting all existed (and
maybe future) options for sentry configuration.
---
airflow/config_templates/config.yml | 6 +++++-
airflow/config_templates/default_airflow.cfg | 6 +++++-
airflow/sentry.py | 26 +++++++++++++++++++++++---
docs/errors.rst | 3 +++
4 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/airflow/config_templates/config.yml
b/airflow/config_templates/config.yml
index e706c57..8fb14f3 100644
--- a/airflow/config_templates/config.yml
+++ b/airflow/config_templates/config.yml
@@ -1124,7 +1124,11 @@
default: "[email protected]"
- 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: ~
diff --git a/airflow/config_templates/default_airflow.cfg
b/airflow/config_templates/default_airflow.cfg
index 6cd5033..ab157f8 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -547,7 +547,11 @@ smtp_mail_from = [email protected]
[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]
diff --git a/airflow/sentry.py b/airflow/sentry.py
index f5106f85..51b38d2 100644
--- a/airflow/sentry.py
+++ b/airflow/sentry.py
@@ -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.
@@ -86,13 +91,28 @@ class ConfiguredSentry(DummySentry):
sentry_celery = CeleryIntegration()
integrations.append(sentry_celery)
- dsn = conf.get("sentry", "sentry_dsn")
+ dsn = None
+ sentry_config_opts = conf.getsection("sentry") or {}
+ 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):
"""
diff --git a/docs/errors.rst b/docs/errors.rst
index 9809d0f..716add8 100644
--- a/docs/errors.rst
+++ b/docs/errors.rst
@@ -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.
+Unsupported options: ``integrations``, ``in_app_include``, ``in_app_exclude``,
``ignore_errors``, ``before_breadcrumb``, ``before_send``, ``transport``.
+
Tags
-----