dstandish commented on code in PR #27758:
URL: https://github.com/apache/airflow/pull/27758#discussion_r1068665627


##########
airflow/utils/log/trigger_handler.py:
##########
@@ -0,0 +1,134 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import asyncio
+import logging
+from contextvars import ContextVar
+from copy import copy
+from logging.handlers import QueueHandler
+
+from airflow.utils.log.file_task_handler import FileTaskHandler
+
+ctx_task_instance: ContextVar = ContextVar("task_instance")
+ctx_trigger_id: ContextVar = ContextVar("trigger_id")
+ctx_close_handler: ContextVar = ContextVar("close_handler")
+ctx_indiv_trigger: ContextVar = ContextVar("__individual_trigger")
+
+
+class TriggerMetadataFilter(logging.Filter):
+    """
+    Injects TI key, triggerer job_id, and trigger_id into the log record.
+
+    :meta private:
+    """
+
+    def filter(self, record):
+        for var in (
+            ctx_task_instance,
+            ctx_trigger_id,
+            ctx_close_handler,
+            ctx_indiv_trigger,
+        ):
+            val = var.get(None)
+            if val is not None:
+                setattr(record, var.name, val)
+        return True
+
+
+class DropTriggerLogsFilter(logging.Filter):
+    """
+    If record has non-empty attr trigger_id, filter the record.

Review Comment:
   what's impl?
   the reason not using trigger_id (i considered it) is we can imagine a future 
where the log record has trigger_id on the record for whatever reason but it's 
not with this specific meaning and purpose



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