From ca782bd167964d7b2d7c822b7960cc1507b8542f Mon Sep 17 00:00:00 2001 From: Marwan Sarieddine Date: Tue, 25 Jun 2024 06:49:43 +0300 Subject: [PATCH 1/2] update SDK version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 36f977c..ccc7573 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ requires-python = ">=3.8, <3.13" dependencies = [ "apache-airflow>=2.7", "pyyaml", - "anyscale==0.24.37" + "anyscale==0.24.44", ] [project.urls] From e171c72deac89823399ecd1861063f81f913a335 Mon Sep 17 00:00:00 2001 From: Marwan Sarieddine Date: Mon, 17 Jun 2024 11:31:22 +0300 Subject: [PATCH 2/2] Add telemetry headers - Capture telemetry via a header at SDK init - Enable users to opt-out of telemetry via setting env_var --- anyscale_provider/hooks/anyscale.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/anyscale_provider/hooks/anyscale.py b/anyscale_provider/hooks/anyscale.py index 5807c54..a1043a5 100644 --- a/anyscale_provider/hooks/anyscale.py +++ b/anyscale_provider/hooks/anyscale.py @@ -46,7 +46,14 @@ def client(self) -> Anyscale: if not token: raise AirflowException(f"Missing API token for connection id {self.conn_id}") - return Anyscale(auth_token=token) + # Add custom headers if telemetry is enabled - by default telemetry is enabled. + headers = {} + telemetry_env = os.getenv("ANYSCALE__AIRFLOW_TELEMETRY_ENABLED", "true") + telemetry_enabled = telemetry_env.lower() in ["true", "1", "yes", "on"] + if telemetry_enabled: + headers["X-Anyscale-Source"] = "airflow" + + return Anyscale(auth_token=token, headers=headers) @classmethod def get_ui_field_behaviour(cls) -> dict[str, Any]: