mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Adds statsd to the application
- statsd client from utils - adds to logger an get same method based reporting as we do for the API.
This commit is contained in:
@@ -26,6 +26,7 @@ from functools import partial
|
|||||||
|
|
||||||
from notifications_python_client.errors import HTTPError
|
from notifications_python_client.errors import HTTPError
|
||||||
from notifications_utils import logging, request_id
|
from notifications_utils import logging, request_id
|
||||||
|
from notifications_utils.clients.statsd.statsd_client import StatsdClient
|
||||||
from notifications_utils.recipients import validate_phone_number, InvalidPhoneError
|
from notifications_utils.recipients import validate_phone_number, InvalidPhoneError
|
||||||
from pygments import highlight
|
from pygments import highlight
|
||||||
from pygments.formatters.html import HtmlFormatter
|
from pygments.formatters.html import HtmlFormatter
|
||||||
@@ -63,6 +64,7 @@ events_api_client = EventsApiClient()
|
|||||||
provider_client = ProviderClient()
|
provider_client = ProviderClient()
|
||||||
organisations_client = OrganisationsClient()
|
organisations_client = OrganisationsClient()
|
||||||
asset_fingerprinter = AssetFingerprinter()
|
asset_fingerprinter = AssetFingerprinter()
|
||||||
|
statsd_client = StatsdClient()
|
||||||
|
|
||||||
# The current service attached to the request stack.
|
# The current service attached to the request stack.
|
||||||
current_service = LocalProxy(partial(_lookup_req_object, 'service'))
|
current_service = LocalProxy(partial(_lookup_req_object, 'service'))
|
||||||
@@ -76,7 +78,8 @@ def create_app():
|
|||||||
application.config.from_object(configs[os.environ['NOTIFY_ENVIRONMENT']])
|
application.config.from_object(configs[os.environ['NOTIFY_ENVIRONMENT']])
|
||||||
|
|
||||||
init_app(application)
|
init_app(application)
|
||||||
logging.init_app(application)
|
statsd_client.init_app(application)
|
||||||
|
logging.init_app(application, statsd_client)
|
||||||
init_csrf(application)
|
init_csrf(application)
|
||||||
request_id.init_app(application)
|
request_id.init_app(application)
|
||||||
|
|
||||||
@@ -164,6 +167,7 @@ def init_app(application):
|
|||||||
@application.before_request
|
@application.before_request
|
||||||
def record_start_time():
|
def record_start_time():
|
||||||
g.start = monotonic()
|
g.start = monotonic()
|
||||||
|
g.endpoint = request.endpoint
|
||||||
|
|
||||||
@application.context_processor
|
@application.context_processor
|
||||||
def inject_global_template_variables():
|
def inject_global_template_variables():
|
||||||
|
|||||||
16
config.py
16
config.py
@@ -9,6 +9,8 @@ class Config(object):
|
|||||||
DANGEROUS_SALT = os.environ['DANGEROUS_SALT']
|
DANGEROUS_SALT = os.environ['DANGEROUS_SALT']
|
||||||
DESKPRO_API_HOST = os.environ['DESKPRO_API_HOST']
|
DESKPRO_API_HOST = os.environ['DESKPRO_API_HOST']
|
||||||
DESKPRO_API_KEY = os.environ['DESKPRO_API_KEY']
|
DESKPRO_API_KEY = os.environ['DESKPRO_API_KEY']
|
||||||
|
# Hosted graphite statsd prefix
|
||||||
|
STATSD_PREFIX = os.getenv('STATSD_PREFIX')
|
||||||
|
|
||||||
DESKPRO_DEPT_ID = 5
|
DESKPRO_DEPT_ID = 5
|
||||||
DESKPRO_ASSIGNED_AGENT_TEAM_ID = 5
|
DESKPRO_ASSIGNED_AGENT_TEAM_ID = 5
|
||||||
@@ -43,6 +45,11 @@ class Config(object):
|
|||||||
ACTIVITY_STATS_LIMIT_DAYS = 7
|
ACTIVITY_STATS_LIMIT_DAYS = 7
|
||||||
TEST_MESSAGE_FILENAME = 'Test message'
|
TEST_MESSAGE_FILENAME = 'Test message'
|
||||||
|
|
||||||
|
STATSD_ENABLED = False
|
||||||
|
STATSD_HOST = "statsd.hostedgraphite.com"
|
||||||
|
STATSD_PORT = 8125
|
||||||
|
NOTIFY_ENVIRONMENT = 'development'
|
||||||
|
|
||||||
EMAIL_DOMAIN_REGEXES = [
|
EMAIL_DOMAIN_REGEXES = [
|
||||||
r"gov\.uk",
|
r"gov\.uk",
|
||||||
r"mod\.uk",
|
r"mod\.uk",
|
||||||
@@ -71,32 +78,41 @@ class Development(Config):
|
|||||||
SESSION_COOKIE_SECURE = False
|
SESSION_COOKIE_SECURE = False
|
||||||
WTF_CSRF_ENABLED = False
|
WTF_CSRF_ENABLED = False
|
||||||
SESSION_PROTECTION = None
|
SESSION_PROTECTION = None
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'development-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'development-notifications-csv-upload'
|
||||||
|
|
||||||
|
|
||||||
class Test(Development):
|
class Test(Development):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
||||||
|
NOTIFY_ENVIRONMENT = 'test'
|
||||||
|
|
||||||
|
|
||||||
class Preview(Config):
|
class Preview(Config):
|
||||||
HTTP_PROTOCOL = 'https'
|
HTTP_PROTOCOL = 'https'
|
||||||
HEADER_COLOUR = '#F499BE' # $baby-pink
|
HEADER_COLOUR = '#F499BE' # $baby-pink
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload'
|
||||||
|
NOTIFY_ENVIRONMENT = 'preview'
|
||||||
|
|
||||||
|
|
||||||
class Staging(Config):
|
class Staging(Config):
|
||||||
SHOW_STYLEGUIDE = False
|
SHOW_STYLEGUIDE = False
|
||||||
HTTP_PROTOCOL = 'https'
|
HTTP_PROTOCOL = 'https'
|
||||||
HEADER_COLOUR = '#6F72AF' # $mauve
|
HEADER_COLOUR = '#6F72AF' # $mauve
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'staging-notify-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'staging-notify-csv-upload'
|
||||||
|
NOTIFY_ENVIRONMENT = 'staging'
|
||||||
|
|
||||||
|
|
||||||
class Live(Config):
|
class Live(Config):
|
||||||
SHOW_STYLEGUIDE = False
|
SHOW_STYLEGUIDE = False
|
||||||
HEADER_COLOUR = '#005EA5' # $govuk-blue
|
HEADER_COLOUR = '#005EA5' # $govuk-blue
|
||||||
HTTP_PROTOCOL = 'https'
|
HTTP_PROTOCOL = 'https'
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload'
|
||||||
|
NOTIFY_ENVIRONMENT = 'live'
|
||||||
|
|
||||||
|
|
||||||
configs = {
|
configs = {
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ export DANGEROUS_SALT='dev-notify-salt'
|
|||||||
export SECRET_KEY='dev-notify-secret-key'
|
export SECRET_KEY='dev-notify-secret-key'
|
||||||
export DESKPRO_API_HOST=""
|
export DESKPRO_API_HOST=""
|
||||||
export DESKPRO_API_KEY=""
|
export DESKPRO_API_KEY=""
|
||||||
|
export STATSD_PREFIX="stats-prefix"
|
||||||
|
|||||||
Reference in New Issue
Block a user