##// END OF EJS Templates
metrics: remove bootstrap timing, as its not usefull at all....
metrics: remove bootstrap timing, as its not usefull at all. Counter resets on each start we don't get any good metrics out of that

File last commit:

r4632:ed2c6dae stable
r4813:5072ed70 default
Show More
__init__.py
46 lines | 1.3 KiB | text/x-python | PythonLexer
from __future__ import absolute_import, division, unicode_literals
import logging
from .stream import TCPStatsClient, UnixSocketStatsClient # noqa
from .udp import StatsClient # noqa
HOST = 'localhost'
PORT = 8125
IPV6 = False
PREFIX = None
MAXUDPSIZE = 512
log = logging.getLogger('rhodecode.statsd')
def statsd_config(config, prefix='statsd.'):
_config = {}
for key in config.keys():
if key.startswith(prefix):
_config[key[len(prefix):]] = config[key]
return _config
def client_from_config(configuration, prefix='statsd.', **kwargs):
from pyramid.settings import asbool
_config = statsd_config(configuration, prefix)
statsd_enabled = asbool(_config.pop('enabled', False))
if not statsd_enabled:
log.debug('statsd client not enabled by statsd.enabled = flag, skipping...')
return
host = _config.pop('statsd_host', HOST)
port = _config.pop('statsd_port', PORT)
prefix = _config.pop('statsd_prefix', PREFIX)
maxudpsize = _config.pop('statsd_maxudpsize', MAXUDPSIZE)
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)
def get_statsd_client(request):
return client_from_config(request.registry.settings)