From 9a2f72773a851f37c418ba23470106b4ccb31250 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 26 Jan 2016 17:04:59 +0100 Subject: [PATCH] fixed new relic app name The app name wasn't displayed correctly on the new relic dashboard. Although `NEW_RELIC_APP_NAME` was set in `production.py`, the variable was not loaded *before* the newrelic agent was called. Since the new relic agent is loaded at a very low level, NEW_RELIC_APP_NAME has to be set before django settings are imported. --- CHANGELOG.md | 4 ++++ docs/settings.rst | 3 ++- {{cookiecutter.repo_name}}/config/settings/production.py | 2 +- {{cookiecutter.repo_name}}/env.example | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52c021ea..0819ae7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All enhancements and patches to cookiecutter-django will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2016-1-26] +### Changed +- Fixed NEW_RELIC_APP_NAME environment variable (@jayfk) + ## [2016-1-18] ### Added - Added .dockerignore file (@bogdal) diff --git a/docs/settings.rst b/docs/settings.rst index aec7c513..c253c18c 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -40,6 +40,7 @@ DJANGO_SENTRY_CLIENT SENTRY_CLIENT n/a DJANGO_SENTRY_LOG_LEVEL SENTRY_LOG_LEVEL n/a logging.INFO DJANGO_MAILGUN_API_KEY MAILGUN_ACCESS_KEY n/a raises error DJANGO_MAILGUN_SERVER_NAME MAILGUN_SERVER_NAME n/a raises error +NEW_RELIC_APP_NAME NEW_RELIC_APP_NAME n/a raises error NEW_RELIC_LICENSE_KEY NEW_RELIC_LICENSE_KEY n/a raises error DJANGO_OPBEAT_APP_ID OPBEAT['APP_ID'] n/a raises error DJANGO_OPBEAT_SECRET_TOKEN OPBEAT['SECRET_TOKEN'] n/a raises error @@ -51,4 +52,4 @@ Other Settings -------------- ACCOUNT_ALLOW_REGISTRATION (=True) - Allow enable or disable user registration through `django-allauth` without disabling other characteristics like authentication and account management. \ No newline at end of file + Allow enable or disable user registration through `django-allauth` without disabling other characteristics like authentication and account management. diff --git a/{{cookiecutter.repo_name}}/config/settings/production.py b/{{cookiecutter.repo_name}}/config/settings/production.py index 09b7ba37..abf5fc99 100644 --- a/{{cookiecutter.repo_name}}/config/settings/production.py +++ b/{{cookiecutter.repo_name}}/config/settings/production.py @@ -147,7 +147,7 @@ EMAIL_SUBJECT_PREFIX = env("DJANGO_EMAIL_SUBJECT_PREFIX", default='[{{cookiecutt SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL) {% if cookiecutter.use_newrelic == 'y'-%} NEW_RELIC_LICENSE_KEY = env('NEW_RELIC_LICENSE_KEY') -NEW_RELIC_APP_NAME = '{{cookiecutter.project_name}}' +NEW_RELIC_APP_NAME = env('NEW_RELIC_APP_NAME') {%- endif %} # TEMPLATE CONFIGURATION diff --git a/{{cookiecutter.repo_name}}/env.example b/{{cookiecutter.repo_name}}/env.example index 749deaed..7eae951c 100644 --- a/{{cookiecutter.repo_name}}/env.example +++ b/{{cookiecutter.repo_name}}/env.example @@ -16,7 +16,8 @@ DJANGO_SECURE_SSL_REDIRECT=False DJANGO_SENTRY_DSN= {% endif %} {% if cookiecutter.use_newrelic == 'y' -%} -NEW_RELIC_LICENSE_KEY +NEW_RELIC_LICENSE_KEY= +NEW_RELIC_APP_NAME={{cookiecutter.repo_name}} {% endif %} {% if cookiecutter.use_opbeat == 'y' -%} DJANGO_OPBEAT_ORGANIZATION_ID