You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/03/10 11:59:57 UTC

[airflow] branch main updated: Rename DummyStatsLogger per previous inclusivity push (#30001)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 00a2c793c7 Rename DummyStatsLogger per previous inclusivity push (#30001)
00a2c793c7 is described below

commit 00a2c793c7985f8165c2bef9106fc81ee66e07bb
Author: D. Ferruzzi <fe...@amazon.com>
AuthorDate: Fri Mar 10 03:59:46 2023 -0800

    Rename DummyStatsLogger per previous inclusivity push (#30001)
---
 airflow/stats.py | 56 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/airflow/stats.py b/airflow/stats.py
index d20ec2ad77..10b57c0869 100644
--- a/airflow/stats.py
+++ b/airflow/stats.py
@@ -182,31 +182,6 @@ class Timer(TimerProtocol):
             self.real_timer.stop()
 
 
-class DummyStatsLogger:
-    """If no StatsLogger is configured, DummyStatsLogger is used as a fallback."""
-
-    @classmethod
-    def incr(cls, stat, count=1, rate=1, *, tags=None):
-        """Increment stat."""
-
-    @classmethod
-    def decr(cls, stat, count=1, rate=1, *, tags=None):
-        """Decrement stat."""
-
-    @classmethod
-    def gauge(cls, stat, value, rate=1, delta=False, *, tags=None):
-        """Gauge stat."""
-
-    @classmethod
-    def timing(cls, stat, dt, *, tags=None):
-        """Stats timing."""
-
-    @classmethod
-    def timer(cls, *args, **kwargs):
-        """Timer metric that can be cancelled."""
-        return Timer()
-
-
 # Only characters in the character set are considered valid
 # for the stat_name if stat_name_default_handler is used.
 ALLOWED_CHARACTERS = set(string.ascii_letters + string.digits + "_.-")
@@ -325,6 +300,31 @@ def prepare_stat_with_tags(fn: T) -> T:
     return cast(T, wrapper)
 
 
+class NoStatsLogger:
+    """If no StatsLogger is configured, NoStatsLogger is used as a fallback."""
+
+    @classmethod
+    def incr(cls, stat, count=1, rate=1, *, tags=None):
+        """Increment stat."""
+
+    @classmethod
+    def decr(cls, stat, count=1, rate=1, *, tags=None):
+        """Decrement stat."""
+
+    @classmethod
+    def gauge(cls, stat, value, rate=1, delta=False, *, tags=None):
+        """Gauge stat."""
+
+    @classmethod
+    def timing(cls, stat, dt, *, tags=None):
+        """Stats timing."""
+
+    @classmethod
+    def timer(cls, *args, **kwargs):
+        """Timer metric that can be cancelled."""
+        return Timer()
+
+
 class SafeStatsdLogger:
     """StatsD Logger."""
 
@@ -541,8 +541,8 @@ class _Stats(type):
             try:
                 cls.instance = cls.factory()
             except (socket.gaierror, ImportError) as e:
-                log.error("Could not configure StatsClient: %s, using DummyStatsLogger instead.", e)
-                cls.instance = DummyStatsLogger()
+                log.error("Could not configure StatsClient: %s, using NoStatsLogger instead.", e)
+                cls.instance = NoStatsLogger()
         return getattr(cls.instance, name)
 
     def __init__(cls, *args, **kwargs):
@@ -554,7 +554,7 @@ class _Stats(type):
             elif conf.getboolean("metrics", "statsd_on"):
                 cls.__class__.factory = cls.get_statsd_logger
             else:
-                cls.__class__.factory = DummyStatsLogger
+                cls.__class__.factory = NoStatsLogger
 
     @classmethod
     def get_statsd_logger(cls):