Skip to content

Commit

Permalink
Support host_name on Datadog provider (#23784)
Browse files Browse the repository at this point in the history
This is required to use other Datadog tenants like app.datadoghq.eu
  • Loading branch information
pecigonzalo committed May 19, 2022
1 parent b2c31ee commit df84c4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion airflow/providers/datadog/hooks/datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, datadog_conn_id: str = 'datadog_default') -> None:
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.
Expand All @@ -53,7 +54,7 @@ def __init__(self, datadog_conn_id: str = 'datadog_default') -> None:
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"""
Expand Down
2 changes: 2 additions & 0 deletions tests/providers/datadog/hooks/test_datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

APP_KEY = 'app_key'
API_KEY = 'api_key'
API_HOST = 'api_host'
METRIC_NAME = 'metric'
DATAPOINT = 7
TAGS = ['tag']
Expand All @@ -53,6 +54,7 @@ def setUp(self, mock_get_connection, mock_initialize):
{
'app_key': APP_KEY,
'api_key': API_KEY,
'api_host': API_HOST,
}
)
)
Expand Down

0 comments on commit df84c4a

Please sign in to comment.