From 40e161d3e6b257350953d64e17108f9f8fa99d9d Mon Sep 17 00:00:00 2001 From: Tatiana Al-Chueyr Date: Thu, 19 Dec 2024 13:54:13 +0000 Subject: [PATCH] Add more logs to troubleshoot --- cosmos/listeners/dag_run_listener.py | 6 ++++-- cosmos/telemetry.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cosmos/listeners/dag_run_listener.py b/cosmos/listeners/dag_run_listener.py index ec324bf47..ee553a975 100644 --- a/cosmos/listeners/dag_run_listener.py +++ b/cosmos/listeners/dag_run_listener.py @@ -70,7 +70,7 @@ def uses_cosmos(dag: DAG) -> bool: @hookimpl def on_dag_run_success(dag_run: DagRun, msg: str) -> None: logger.info("The on_dag_run_success was called") - print("The on_dag_run_success was called") + dag = dag_run.get_dag() if not uses_cosmos(dag): return @@ -86,12 +86,13 @@ def on_dag_run_success(dag_run: DagRun, msg: str) -> None: } telemetry.emit_usage_metrics_if_enabled(DAG_RUN, additional_telemetry_metrics) + logger.info("Completed on_dag_run_success") @hookimpl def on_dag_run_failed(dag_run: DagRun, msg: str) -> None: logger.info("The on_dag_run_failed was called") - print("The on_dag_run_failed was called") + dag = dag_run.get_dag() if not uses_cosmos(dag): return @@ -107,3 +108,4 @@ def on_dag_run_failed(dag_run: DagRun, msg: str) -> None: } telemetry.emit_usage_metrics_if_enabled(DAG_RUN, additional_telemetry_metrics) + logger.info("Completed on_dag_run_failed") diff --git a/cosmos/telemetry.py b/cosmos/telemetry.py index 4b5dd4abc..6ae452023 100644 --- a/cosmos/telemetry.py +++ b/cosmos/telemetry.py @@ -44,7 +44,7 @@ def emit_usage_metrics(metrics: dict[str, object]) -> bool: telemetry_url = constants.TELEMETRY_URL.format( **metrics, telemetry_version=constants.TELEMETRY_VERSION, query_string=query_string ) - logging.debug("Telemetry is enabled. Emitting the following usage metrics to %s: %s", telemetry_url, metrics) + logging.info("Telemetry is enabled. Emitting the following usage metrics to %s: %s", telemetry_url, metrics) response = httpx.get(telemetry_url, timeout=constants.TELEMETRY_TIMEOUT, follow_redirects=True) if not response.is_success: logging.warning( @@ -71,5 +71,5 @@ def emit_usage_metrics_if_enabled(event_type: str, additional_metrics: dict[str, is_success = emit_usage_metrics(metrics) return is_success else: - logging.debug("Telemetry is disabled. To enable it, export AIRFLOW__COSMOS__ENABLE_TELEMETRY=True.") + logging.info("Telemetry is disabled. To enable it, export AIRFLOW__COSMOS__ENABLE_TELEMETRY=True.") return False