Ensure that configs know which environment it is.

This allows us to prefix metrics with the environment to allow stats from staging and live to go to the same statsd, and alls us to filter in the dashboard by environment.
This commit is contained in:
Martyn Inglis
2016-08-08 10:20:33 +01:00
parent 365019461b
commit 6b12c397a1
2 changed files with 6 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ class StatsdClient(StatsClient):
prefix=app.config.get('STATSD_PREFIX') prefix=app.config.get('STATSD_PREFIX')
) )
self.active = app.config.get('STATSD_ENABLED') self.active = app.config.get('STATSD_ENABLED')
self.namespace = "notifications.api." self.namespace = app.config.get('NOTIFY_ENVIRONMENT') + ".notifications.api."
def format_stat_name(self, stat): def format_stat_name(self, stat):
return self.namespace + stat return self.namespace + stat

View File

@@ -110,27 +110,32 @@ class Config(object):
class Development(Config): class Development(Config):
NOTIFY_ENVIRONMENT = 'development'
CSV_UPLOAD_BUCKET_NAME = 'developement-martyn-notifications-csv-upload' CSV_UPLOAD_BUCKET_NAME = 'developement-martyn-notifications-csv-upload'
DEBUG = True DEBUG = True
class Preview(Config): class Preview(Config):
NOTIFY_ENVIRONMENT = 'preview'
CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload' CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload'
STATSD_PREFIX = "preview" STATSD_PREFIX = "preview"
class Test(Development): class Test(Development):
NOTIFY_ENVIRONMENT = 'test'
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload' CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
STATSD_PREFIX = "test" STATSD_PREFIX = "test"
class Staging(Config): class Staging(Config):
NOTIFY_ENVIRONMENT = 'staging'
CSV_UPLOAD_BUCKET_NAME = 'staging-notify-csv-upload' CSV_UPLOAD_BUCKET_NAME = 'staging-notify-csv-upload'
STATSD_PREFIX = os.getenv('STATSD_PREFIX') STATSD_PREFIX = os.getenv('STATSD_PREFIX')
STATSD_ENABLED = True STATSD_ENABLED = True
class Live(Config): class Live(Config):
NOTIFY_ENVIRONMENT = 'live'
CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload' CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload'
STATSD_ENABLED = True STATSD_ENABLED = True
STATSD_PREFIX = os.getenv('STATSD_PREFIX') STATSD_PREFIX = os.getenv('STATSD_PREFIX')