Skip to content

Instantly share code, notes, and snippets.

@amjith
Created June 4, 2013 00:09
Show Gist options
  • Save amjith/5702572 to your computer and use it in GitHub Desktop.
Save amjith/5702572 to your computer and use it in GitHub Desktop.
WSGI app to test the NR disable/enable.
from time import sleep
from webtest import TestApp
import newrelic.agent
newrelic.agent.initialize('newrelic.ini')
def hello_world(environ, start_response):
path = environ.get('PATH_INFO')
if path.startswith('/slow'):
sleep(5)
start_response('200 OK', [('Content-Type', 'text/html')])
header = newrelic.agent.get_browser_timing_header
footer = newrelic.agent.get_browser_timing_footer
return ['<head>', header(), '</head>', '<body>%s' % path, footer(), '</body>']
application = newrelic.agent.wsgi_application()(hello_world)
test_application = TestApp(application)
newrelic.agent.global_settings().enabled = False
print 'Agent disabled.'
test_application.get('/slow123')
raw_input('Press enter to continue:')
newrelic.agent.global_settings().enabled = True
print 'Agent enabled.'
test_application.get('/slow123')
test_application.get('/')
test_application.get('/')
test_application.get('/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment