plovegro opened a new issue, #54332:
URL: https://github.com/apache/airflow/issues/54332

   ### Apache Airflow version
   
   3.0.4
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   I am attempting to implement a listener on task success ( or dag success - 
either one doesnt work). Here is a sample of my code
   
   plugin code
   ```
   
   from airflow.plugins_manager import AirflowPlugin
   from listeners_code import on_dag_run_success
   
   class MyListenerPlugin(AirflowPlugin):
       name = "my_listener_plugin"
       listeners = [on_dag_run_success]
   Listener code
   ```
   
   ```
   @hookimpl
   def on_dag_run_success(dag_run: DagRun, msg: str):
       """
       This method is called when dag run state changes to SUCCESS.
       """
       log.info("Dag run in success state")
       start_date = dag_run.start_date
       end_date = dag_run.end_date
       try:
           # It's good practice to include a timeout and check the respons
           url = "https://webhook.site/50546762-d91e-463c-8abb-ca085f2dd79f";
           headers = {'Content-Type': 'application/json','Accept': 
'application/json' }
           response = requests.get(url, timeout=10)
           #response.raise_for_status()  # Raise an error for 4xx/5xx responses
         
       except requests.exceptions.RequestException as e:
           log.error(
               "Failed to send webhook for task '%s': %s",
              1,
               e,
           )
   
       log.info(f"Dag run start:{start_date} end:{end_date}")```
   ```
   
   
   Nothing is visible in the logs, or in the external API when the DAG is run 
and completes.
   
   ### What you think should happen instead?
   
   I should be seeing events fired off on DAG success.
   
   ### How to reproduce
   
   Add plugin code in /plugins folder and restart docker.
   
   ### Operating System
   
   Ubuntu 24
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   Docker
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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