This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new df84c4ad42 Support host_name on Datadog provider (#23784)
df84c4ad42 is described below
commit df84c4ad42b1bbaf352d14973f1f867c89dc0a3b
Author: Gonzalo Peci <[email protected]>
AuthorDate: Thu May 19 19:20:48 2022 +0200
Support host_name on Datadog provider (#23784)
This is required to use other Datadog tenants like app.datadoghq.eu
---
airflow/providers/datadog/hooks/datadog.py | 3 ++-
tests/providers/datadog/hooks/test_datadog.py | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/airflow/providers/datadog/hooks/datadog.py
b/airflow/providers/datadog/hooks/datadog.py
index b3b7008f43..574b85efc0 100644
--- a/airflow/providers/datadog/hooks/datadog.py
+++ b/airflow/providers/datadog/hooks/datadog.py
@@ -43,6 +43,7 @@ class DatadogHook(BaseHook, LoggingMixin):
conn = self.get_connection(datadog_conn_id)
self.api_key = conn.extra_dejson.get('api_key', None)
self.app_key = conn.extra_dejson.get('app_key', None)
+ self.api_host = conn.extra_dejson.get('api_host', None)
self.source_type_name = conn.extra_dejson.get('source_type_name', None)
# If the host is populated, it will use that hostname instead.
@@ -53,7 +54,7 @@ class DatadogHook(BaseHook, LoggingMixin):
raise AirflowException("api_key must be specified in the Datadog
connection details")
self.log.info("Setting up api keys for Datadog")
- initialize(api_key=self.api_key, app_key=self.app_key)
+ initialize(api_key=self.api_key, app_key=self.app_key,
api_host=self.api_host)
def validate_response(self, response: Dict[str, Any]) -> None:
"""Validate Datadog response"""
diff --git a/tests/providers/datadog/hooks/test_datadog.py
b/tests/providers/datadog/hooks/test_datadog.py
index 3033e630ea..78ca539a62 100644
--- a/tests/providers/datadog/hooks/test_datadog.py
+++ b/tests/providers/datadog/hooks/test_datadog.py
@@ -28,6 +28,7 @@ from airflow.providers.datadog.hooks.datadog import
DatadogHook
APP_KEY = 'app_key'
API_KEY = 'api_key'
+API_HOST = 'api_host'
METRIC_NAME = 'metric'
DATAPOINT = 7
TAGS = ['tag']
@@ -53,6 +54,7 @@ class TestDatadogHook(unittest.TestCase):
{
'app_key': APP_KEY,
'api_key': API_KEY,
+ 'api_host': API_HOST,
}
)
)