From 82fc7c8e3d58fa25419621be746e811f55e93edf Mon Sep 17 00:00:00 2001 From: Mike Shultz Date: Tue, 23 Apr 2024 19:37:19 -0600 Subject: [PATCH] fix: apply contract event labels to task when appropriate --- silverback/application.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/silverback/application.py b/silverback/application.py index b04eea34..5c390339 100644 --- a/silverback/application.py +++ b/silverback/application.py @@ -118,10 +118,16 @@ def broker_task_decorator( # Register user function as task handler with our broker def add_taskiq_task(handler: Callable) -> AsyncTaskiqDecoratedTask: + labels = {"task_type": str(task_type)} + + if container and isinstance(container, ContractEvent): + labels["contract_address"] = container.contract.address + labels["event_abi"] = container.abi + broker_task = self.broker.register_task( handler, task_name=handler.__name__, - task_type=str(task_type), + **labels, ) self.tasks[task_type].append(TaskData(container=container, handler=broker_task))