ramitkataria commented on code in PR #57215:
URL: https://github.com/apache/airflow/pull/57215#discussion_r2467528166
##########
airflow-core/src/airflow/models/callback.py:
##########
@@ -131,26 +136,42 @@ class Callback(Base):
trigger_id: Mapped[int] = mapped_column(Integer, ForeignKey("trigger.id"),
nullable=True)
trigger = relationship("Trigger", back_populates="callback", uselist=False)
- def __init__(self, priority_weight: int = 1):
+ def __init__(self, priority_weight: int = 1, prefix: str = "", **kwargs):
self.state = CallbackState.PENDING
self.priority_weight = priority_weight
+ self.data = kwargs # kwargs can be used to include additional info in
metric tags
+ if prefix:
+ self.data["prefix"] = prefix
def queue(self):
self.state = CallbackState.QUEUED
+ def get_metric_info(self, status: str, result: Any) -> dict:
+ tags = {"result": result, **self.data}
+ tags.pop("prefix", None)
+
+ if "kwargs" in tags:
+ # Remove the context (if exists) to keep the tags simple
+ tags["kwargs"] = {k: v for k, v in tags["kwargs"].items() if k !=
"context"}
Review Comment:
This is because of the shallow copy of the dict. If I just did a `pop`, it
would also remove context from the kwargs that would be passed to the trigger
at callback runtime
--
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]