realtimetodie commented on code in PR #72458:
URL: https://github.com/apache/airflow/pull/72458#discussion_r3998999262


##########
shared/observability/src/airflow_shared/observability/common.py:
##########
@@ -30,6 +31,20 @@
 log = structlog.getLogger(__name__)
 
 
+def expand_dag_tags(tag_names: Iterable[str]) -> dict[str, str]:
+    """Expand DAG tag attributes into key-value pairs."""
+    result: dict[str, str] = {}
+    for name in tag_names:
+        key, _, value = name.partition(":")
+        result[key] = value
+    return result
+
+
+def build_dag_tags(tag_names: Iterable[str]) -> dict[str, str]:

Review Comment:
   Yes, in an upcoming PR I would like to extend `build_dag_tags` as the single 
entry point for building DAG tag attributes, roughly like this, without having 
to redesign the surrounding code and tests again:
   
   ```python
   # new upcoming function (example)
   def build_dag_tags_attribute(
       tag_names: Iterable[str],
   ) -> dict[str, Sequence[str]]:
       return {"airflow.dag.tags": tuple(tag_names)}
   
   
   def build_dag_tags(
       tag_names: Iterable[str],
       *,
       expand: bool = False,
   ) -> dict[str, str] | dict[str, Sequence[str]]:
       if expand:
           return expand_dag_tags(tag_names)
   
       return build_dag_tags_attribute(tag_names)
   ```
   
   The value of `expand` could then depend on a new configuration option:
   
   ```ini
   [metrics]
   expand_dag_tags = False
   
   [traces]
   expand_dag_tags = True
   ```
   
   It might also depend on the `otel_on` option. I’m open to discussion on the 
exact configuration and don’t have a strong preference here.



-- 
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]

Reply via email to