Skip to content

Commit

Permalink
Add telemetry headers
Browse files Browse the repository at this point in the history
- Capture telemetry via a header at SDK init
- Enable users to opt-out of telemetry via setting env_var
  • Loading branch information
marwan116 committed Jun 17, 2024
1 parent 922c2eb commit c59c9aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions anyscale_provider/hooks/anyscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ def __init__(self, conn_id: str = default_conn_name, **kwargs: Any) -> None:
if not token:
raise AirflowException(f"Missing API token for connection id {self.conn_id}")

self.sdk = Anyscale(auth_token=token)

# Add custom headers if telemetry is enabled - by default telemetry is enabled.
headers = {}
if os.getenv("ANYSCALE__AIRFLOW_TELEMETRY_ENABLED", "true") == "false":
headers["X-Anyscale-Source"] = "astronomer-sdk"

self.sdk = Anyscale(auth_token=token, headers=headers)

@classmethod
def get_ui_field_behaviour(cls) -> Dict[str, Any]:
Expand Down

0 comments on commit c59c9aa

Please sign in to comment.