Skip to content

Instantly share code, notes, and snippets.

@GrahamDumpleton
Created December 19, 2012 23:22
Show Gist options
  • Save GrahamDumpleton/4341587 to your computer and use it in GitHub Desktop.
Save GrahamDumpleton/4341587 to your computer and use it in GitHub Desktop.
Manual method for optionally initialising agent based on environment variables.
# Add this at start of WSGI file before any imports, but if necessary after setting
# sys.path so that 'newrelic' package can be found.
import os
license_key = os.environ.get('NEW_RELIC_LICENSE_KEY', None)
config_file = os.environ.get('NEW_RELIC_CONFIG_FILE', None)
environment = os.environ.get('NEW_RELIC_ENVIRONMENT', None)
if license_key or config_file:
import newrelic.agent
newrelic.agent.initialize(config_file, environment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment