Skip to content

Commit

Permalink
Add more logs to troubleshoot
Browse files Browse the repository at this point in the history
  • Loading branch information
tatiana committed Dec 19, 2024
1 parent f325f8f commit 40e161d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cosmos/listeners/dag_run_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
4 changes: 2 additions & 2 deletions cosmos/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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

0 comments on commit 40e161d

Please sign in to comment.