milton0825 commented on a change in pull request #4889: [AIRFLOW-4057] statsd
should handle invalid characters
URL: https://github.com/apache/airflow/pull/4889#discussion_r266185459
##########
File path: airflow/settings.py
##########
@@ -71,6 +74,42 @@ def timing(cls, stat, dt):
Stats = DummyStatsLogger
+
+def validate_stat(f):
+ @wraps(f)
+ def wrapper(stat, *args, **kwargs):
+ try:
+ validate_key(stat)
+ except Exception as err:
+ log.warning('Invalid stat name: {stat}.'.format(stat=stat), err)
+ return
+ return f(stat, *args, **kwargs)
+
+ return wrapper
+
+
+class SafeStatsdLogger(object):
+
+ def __init__(self, statsd_client):
+ self.statsd = statsd_client
+
+ @validate_stat
Review comment:
Think twice and I think that we should decouple the stats name rule from the
task/dag id rule as some stats store have event stricter rule. We should also
allow user to define a custom method to handle characters not allowed.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services