You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/03/16 18:48:37 UTC

[GitHub] [airflow] wonja opened a new issue #14839: Enabling Datadog to tag metrics results in AttributeError

wonja opened a new issue #14839:
URL: https://github.com/apache/airflow/issues/14839


   **Apache Airflow version**: 2.0.1
   **Python version**: 3.8
   **Cloud provider or hardware configuration**: AWS
   
   **What happened**:
   In order to add tags to [Airflow metrics,](https://airflow.apache.org/docs/apache-airflow/stable/logging-monitoring/metrics.html), it's required to set `AIRFLOW__METRICS__STATSD_DATADOG_ENABLED` to `True` and add tags in the `AIRFLOW__METRICS__STATSD_DATADOG_TAGS` variable. We were routing our statsd metrics to Datadog anyway, so this should theoretically have not changed anything other than the addition of any specified tags.
   Setting the environment variable `AIRFLOW__METRICS__STATSD_DATADOG_ENABLED` to `True` (along with the other required statsd connection variables) results in the following error, which causes the process to terminate. This is from the scheduler, but this would apply anywhere that `Stats.timer()` is being called.
   ```
   AttributeError: 'DogStatsd' object has no attribute 'timer'
   return Timer(self.dogstatsd.timer(stat, *args, tags=tags, **kwargs))
   File "/usr/local/lib/python3.8/site-packages/airflow/stats.py", line 345, in timer
   return fn(_self, stat, *args, **kwargs)
   File "/usr/local/lib/python3.8/site-packages/airflow/stats.py", line 233, in wrapper
   timer = Stats.timer('scheduler.critical_section_duration')
   File "/usr/local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 1538, in _do_scheduling
   num_queued_tis = self._do_scheduling(session)
   File "/usr/local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 1382, in _run_scheduler_loop
   self._run_scheduler_loop()
   File "/usr/local/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 1280, in _execute
   Traceback (most recent call last):
   ```
   
   **What you expected to happen**:
   The same default Airflow metrics get sent by connecting to datadog, tagged with the metrics specified in `AIRFLOW__METRICS__STATSD_DATADOG_TAGS`.
   
   **What do you think went wrong?**:
   There is a bug in the implementation of the `Timer` method of `SafeDogStatsdLogger`. https://github.com/apache/airflow/blob/master/airflow/stats.py#L341-L347
   `DogStatsd` has not method called `timer`. Instead it should be `timed`: https://datadogpy.readthedocs.io/en/latest/#datadog.dogstatsd.base.DogStatsd.timed
   
   **How to reproduce it**:
   Set the environment variables (or their respective config values) `AIRFLOW__METRICS__STATSD_ON`, `AIRFLOW__METRICS__STATSD_HOST`, `AIRFLOW__METRICS__STATSD_PORT`, and then set `AIRFLOW__METRICS__STATSD_DATADOG_ENABLED` to `True` and start up Airflow.
   
   
   **Anything else we need to know**:
   How often does this problem occur? Every time
   
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb closed issue #14839: Enabling Datadog to tag metrics results in AttributeError

Posted by GitBox <gi...@apache.org>.
ashb closed issue #14839:
URL: https://github.com/apache/airflow/issues/14839


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on issue #14839: Enabling Datadog to tag metrics results in AttributeError

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #14839:
URL: https://github.com/apache/airflow/issues/14839#issuecomment-800518433


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org