Skip to content
Snippets Groups Projects
Commit 0a3da3d8 authored by Gunnar Schaefer's avatar Gunnar Schaefer
Browse files

Merge pull request #35 from scitran/newrelic

Optional NewRelic support
parents 30edad1a 093e0c9b
No related branches found
No related tags found
No related merge requests found
......@@ -115,6 +115,10 @@ def dispatcher(router, request, response):
response.write(json.dumps(rv, default=bson.json_util.default))
response.headers['Content-Type'] = 'application/json; charset=utf-8'
try:
import newrelic.agent
app = newrelic.agent.WSGIApplicationWrapper(webapp2.WSGIApplication(routes))
except ImportError:
app = webapp2.WSGIApplication(routes)
app = webapp2.WSGIApplication(routes)
app.router.set_dispatcher(dispatcher)
......@@ -9,6 +9,15 @@ logging.basicConfig(
log = logging.getLogger('scitran.api')
logging.getLogger('scitran.data').setLevel(logging.WARNING) # silence scitran.data logging
try:
import newrelic.agent
newrelic.agent.initialize('../../newrelic.ini')
log.info('New Relic detected and loaded. Monitoring enabled.')
except ImportError:
log.info('New Relic not detected. Monitoring disabled.')
except newrelic.api.exceptions.ConfigurationError:
log.warn('New Relic detected but configuration was not valid. Please ensure newrelic.ini is present. Monitoring disabled.')
import os
import time
import pymongo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment