[AIRFLOW-2702] Handle uncaught statsd configuration errors

Closes #3564 from
Noremac201/the_spy_who_errored_me
This commit is contained in:
Cameron Moberg 2018-07-04 14:25:43 +01:00 коммит произвёл Kaxil Naik
Родитель 985a433a8d
Коммит e8e7209e3a
1 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -26,6 +26,7 @@ import atexit
import logging
import os
import pendulum
import socket
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
@ -71,16 +72,17 @@ class DummyStatsLogger(object):
Stats = DummyStatsLogger
if conf.getboolean('scheduler', 'statsd_on'):
from statsd import StatsClient
try:
if conf.getboolean('scheduler', 'statsd_on'):
from statsd import StatsClient
statsd = StatsClient(
host=conf.get('scheduler', 'statsd_host'),
port=conf.getint('scheduler', 'statsd_port'),
prefix=conf.get('scheduler', 'statsd_prefix'))
Stats = statsd
else:
Stats = DummyStatsLogger
statsd = StatsClient(
host=conf.get('scheduler', 'statsd_host'),
port=conf.getint('scheduler', 'statsd_port'),
prefix=conf.get('scheduler', 'statsd_prefix'))
Stats = statsd
except (socket.gaierror, ImportError):
log.warning("Could not configure StatsClient, using DummyStatsLogger instead.")
HEADER = """\
____________ _____________