howardyoo commented on code in PR #37948:
URL: https://github.com/apache/airflow/pull/37948#discussion_r1524169050
##########
airflow/traces/utils.py:
##########
@@ -18,52 +18,66 @@
from __future__ import annotations
import logging
+from typing import TYPE_CHECKING
from airflow.utils.hashlib_wrapper import md5
+if TYPE_CHECKING:
+ from airflow.models import DagRun, TaskInstance
+ from airflow.models.taskinstancekey import TaskInstanceKey
+
log = logging.getLogger(__name__)
-def gen_trace_id(dag_run) -> str:
+def gen_trace_id(dag_run: DagRun, as_int: bool = False) -> str | int:
+ """Generate trace id from DagRun."""
dag_id = dag_run.dag_id
run_id = dag_run.run_id
start_dt = dag_run.start_date
hash_seed = f"{dag_id}_{run_id}_{start_dt.timestamp()}"
hash_hex = md5(hash_seed.encode("utf-8")).hexdigest()
+ if as_int is True:
+ return int(hash_hex, 16)
Review Comment:
Right. I'd say as_int should be okay, as what the trace_id and span_id needs
is the 'int' type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]