From 7a2bd60f22fc0dafdf23960cb9eb9fa3ea629b76 Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Thu, 2 Feb 2023 10:01:32 +0100 Subject: [PATCH] statsd: use safe mode and disable statsd if we can't connect --- rhodecode/lib/_vendor/statsd/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rhodecode/lib/_vendor/statsd/__init__.py b/rhodecode/lib/_vendor/statsd/__init__.py index 3a11321f..682d8d95 100644 --- a/rhodecode/lib/_vendor/statsd/__init__.py +++ b/rhodecode/lib/_vendor/statsd/__init__.py @@ -38,8 +38,14 @@ def client_from_config(configuration, prefix='statsd.', **kwargs): ipv6 = asbool(_config.pop('statsd_ipv6', IPV6)) log.debug('configured statsd client %s:%s', host, port) - return StatsClient( - host=host, port=port, prefix=prefix, maxudpsize=maxudpsize, ipv6=ipv6) + try: + client = StatsClient( + host=host, port=port, prefix=prefix, maxudpsize=maxudpsize, ipv6=ipv6) + except Exception: + log.exception('StatsD is enabled, but failed to connect to statsd server, fallback: disable statsd') + client = None + + return client def get_statsd_client(request):