# HG changeset patch # User RhodeCode Admin # Date 2023-02-02 09:01:32 # Node ID fa4221419326cc37be77e618d876060216369a84 # Parent 2768c2d48018476aedc17d693e8bda779dc8a4c4 statsd: use safe mode and disable statsd if we can't connect diff --git a/rhodecode/lib/_vendor/statsd/__init__.py b/rhodecode/lib/_vendor/statsd/__init__.py --- a/rhodecode/lib/_vendor/statsd/__init__.py +++ b/rhodecode/lib/_vendor/statsd/__init__.py @@ -38,8 +38,14 @@ def client_from_config(configuration, pr 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):