This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this as: | |
# | |
# NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-python example.py | |
# | |
# If being run under Heroku, you can skip setting NEW_RELIC_CONFIG_FILE on the | |
# command line as the required environment variable settings added by the | |
# Heroku New Relic addon will be picked up automatically. | |
import time | |
import newrelic.agent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 2.5, 2.6 runs okay. | |
# Python 2.7: | |
# | |
# Traceback (most recent call last): | |
# File "test.py", line 33, in <module> | |
# with cm2: | |
# AttributeError: __exit__ | |
from __future__ import with_statement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import with_statement | |
class CM1(object): | |
def __enter__(self): | |
print '__enter__' | |
return self | |
def __exit__(self, *args): | |
print '__exit__' | |
class CM2(object): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
class RequestsConnectionFilter(logging.Filter): | |
def filter(self, record): | |
return False | |
logging.getLogger('newrelic.lib.requests.packages.urllib3.connectionpool').addFilter(RequestsConnectionFilter()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[function-profile:profile-1] | |
enabled = true | |
function = module:handler | |
filename = /tmp/profile-%(pid)s.dat | |
delay = 1.0 | |
checkpoint = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pstats | |
import glob | |
import sys | |
filenames = sys.argv[1:] | |
# Read all stats files into a single object | |
stats = pstats.Stats(filenames[0]) | |
for i in filenames[1:]: | |
stats.add(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import newrelic.hooks.component_tastypie | |
... | |
def wrap_view(self, view): | |
... | |
wrap_view = newrelic.hooks.component_tastypie.ObjectWrapper(wrap_view, | |
None, newrelic.hooks.component_tastypie.outer_fn_wrapper) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
843,httplib | |
843,urllib | |
813,urllib2 | |
163,requests | |
94,httplib2 | |
87,xmlrpclib | |
33,feedparser | |
6,urllib3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(uwsgi-testing)Grumpys-MacBook-Pro-15:htdocs graham$ which python | |
/Users/graham/Python/uwsgi-testing/bin/python | |
(uwsgi-testing)Grumpys-MacBook-Pro-15:htdocs graham$ python | |
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) | |
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import sys | |
>>> sys.prefix | |
'/Users/graham/Python/uwsgi-testing/bin/..' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save this as newrelic-manage.py in same directory as existing manage.py. | |
# | |
# Run as: | |
# | |
# NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini python newrelic-manage.py run_gunicorn | |
import os | |
import newrelic.agent | |
here = os.path.dirname(__file__) |