From 930c64df8a78ecc491d71b27bc1fa6c7eade7d38 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 22 Aug 2015 13:18:55 -0700 Subject: [PATCH] Move zulip.com-related statsd configuration out of main settings.py. This also removes the convenient way to run statsd in the Dev VM, because we don't anticipate anyone doing that. It's just 2 lines of config to configure it anyway: STATSD_HOST = 'localhost' STATSD_PREFIX = 'user' (imported from commit 5b09422ee0e956bc7f336dd1e575634380b8bfa2) --- zerver/lib/utils.py | 2 +- zerver/management/commands/send_stats.py | 2 +- zproject/local_settings.py | 5 ++++- zproject/settings.py | 22 ++++------------------ 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/zerver/lib/utils.py b/zerver/lib/utils.py index f8504a8d4d..2543868423 100644 --- a/zerver/lib/utils.py +++ b/zerver/lib/utils.py @@ -40,7 +40,7 @@ class StatsDWrapper(object): # Hand off to statsd if we have it enabled # otherwise do nothing if name in ['timer', 'timing', 'incr', 'decr', 'gauge']: - if settings.USING_STATSD: + if settings.STATSD_HOST != '': from django_statsd.clients import statsd if name == 'gauge': return self._our_gauge diff --git a/zerver/management/commands/send_stats.py b/zerver/management/commands/send_stats.py index 231fe4673e..98f3910772 100644 --- a/zerver/management/commands/send_stats.py +++ b/zerver/management/commands/send_stats.py @@ -18,7 +18,7 @@ class Command(BaseCommand): name = options['name'] val = options['val'] - if settings.USING_STATSD: + if settings.STATSD_HOST != '': from statsd import statsd func = getattr(statsd, operation) diff --git a/zproject/local_settings.py b/zproject/local_settings.py index bd97b7c002..2296b76adb 100644 --- a/zproject/local_settings.py +++ b/zproject/local_settings.py @@ -41,12 +41,15 @@ NOREPLY_EMAIL_ADDRESS = "noreply@zulip.com" SESSION_SERIALIZER = "django.contrib.sessions.serializers.PickleSerializer" +STATSD_HOST = 'stats.zulip.net' + if ZULIP_COM_STAGING: EXTERNAL_HOST = 'staging.zulip.com' + STATSD_PREFIX = 'staging' else: EXTERNAL_HOST = 'zulip.com' EXTERNAL_API_PATH = 'api.zulip.com' - + STATSD_PREFIX = 'app' S3_BUCKET="humbug-user-uploads" S3_AUTH_UPLOADS_BUCKET = "zulip-user-uploads" diff --git a/zproject/settings.py b/zproject/settings.py index 79c18d0ee7..e59ddea45f 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -154,6 +154,7 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '', 'EXTERNAL_URI_SCHEME': "https://", 'ZULIP_COM': False, 'ZULIP_COM_STAGING': False, + 'STATSD_HOST': '', 'GOOGLE_CLIENT_ID': '', 'DBX_APNS_CERT_FILE': None, } @@ -481,24 +482,9 @@ else: # STATSD CONFIGURATION ######################################################################## -LOCAL_STATSD = (False) -USING_STATSD = ZULIP_COM or LOCAL_STATSD - -# These must be named STATSD_PREFIX for the statsd module -# to pick them up -if ZULIP_COM_STAGING: - STATSD_PREFIX = 'staging' -elif PRODUCTION: - STATSD_PREFIX = 'app' -else: - STATSD_PREFIX = 'user' - -if USING_STATSD: - if LOCAL_STATSD: - STATSD_HOST = 'localhost' - else: - STATSD_HOST = 'stats.zulip.net' - +# Statsd is not super well supported; if you want to use it you'll need +# to set STATSD_HOST and STATSD_PREFIX. +if STATSD_HOST != '': INSTALLED_APPS += ['django_statsd'] STATSD_PORT = 8125 STATSD_CLIENT = 'django_statsd.clients.normal'