コード例 #1
0
def build_statsd_client(app, mocker):
    client = StatsdClient()
    app.config['NOTIFY_ENVIRONMENT'] = "test"
    app.config['NOTIFY_APP_NAME'] = "api"
    app.config['STATSD_HOST'] = "localhost"
    app.config['STATSD_PORT'] = "8000"
    app.config['STATSD_PREFIX'] = "prefix"
    client.init_app(app)
    if not app.config['STATSD_ENABLED']:
        # statsd_client not initialised if statsd not enabled, so lets mock it
        client.statsd_client = Mock()
    mocker.patch.object(client.statsd_client, "incr")
    mocker.patch.object(client.statsd_client, "gauge")
    mocker.patch.object(client.statsd_client, "timing")
    return client
コード例 #2
0
class _StatsdWrapper():
    def __init__(self):
        self.config = {}
        self.config.update({
            'STATSD_ENABLED':
            config['GENERAL']['STATSD_ENABLED'],
            'NOTIFY_ENVIRONMENT':
            config['GENERAL']['CF_SPACE'],
            'NOTIFY_APP_NAME':
            'autoscaler',
            'STATSD_HOST':
            os.environ.get('STATSD_HOST', 'testing.local'),
            'STATSD_PORT':
            8125,
        })
        self.statsd_client = StatsdClient()
        self.statsd_client.init_app(self)
コード例 #3
0
class _StatsdWrapper():
    def __init__(self):
        self.config = {}
        self.config.update({
            'STATSD_ENABLED':
            config['GENERAL']['STATSD_ENABLED'],
            'NOTIFY_ENVIRONMENT':
            config['GENERAL']['CF_SPACE'],
            'NOTIFY_APP_NAME':
            'autoscaler',
            'STATSD_HOST':
            'statsd.hostedgraphite.com',
            'STATSD_PORT':
            '8125',
            'STATSD_PREFIX':
            os.environ['STATSD_PREFIX']
        })
        self.statsd_client = StatsdClient()
        self.statsd_client.init_app(self)