Skip to content

Instantly share code, notes, and snippets.

View GrahamDumpleton's full-sized avatar
😎

Graham Dumpleton GrahamDumpleton

😎
View GitHub Profile
@GrahamDumpleton
GrahamDumpleton / gist:3915819
Created October 19, 2012 01:49
Tracking a one off task run from a script as a background job.
# 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
@GrahamDumpleton
GrahamDumpleton / gist:3909828
Created October 18, 2012 04:16
Additional ObjectWrapper methods.
def __eq__(self, other):
if isinstance(other, ObjectWrapper):
return self._nr_last_object == other._nr_last_object
return self._nr_last_object == other
def __ne__(self, other):
result = self.__eq__(other)
if result is NotImplemented:
return result
return not result
@GrahamDumpleton
GrahamDumpleton / gist:3815596
Created October 2, 2012 01:16
PyCon US 2013 Talk Proposal 2

Title

How well do you really understand the WSGI specification?

Category

Web Frameworks

@GrahamDumpleton
GrahamDumpleton / gist:3652331
Created September 6, 2012 07:00
Agent configuration for Nova instrumentation
# Import hooks for nova.
[import-hook:nova.wsgi]
enabled = true
execute = nova-api-instrumentation:instrument_nova_wsgi
[import-hook:nova.api.openstack.wsgi]
enabled = true
execute = nova-api-instrumentation:instrument_nova_api_openstack_wsgi
@GrahamDumpleton
GrahamDumpleton / gist:3652313
Created September 6, 2012 06:58
Nova instrumentation for New Relic
import types
import sys
from newrelic.api.object_wrapper import callable_name
from newrelic.api.error_trace import wrap_error_trace
from newrelic.api.in_function import wrap_in_function
from newrelic.api.transaction_name import wrap_transaction_name
from newrelic.api.function_trace import wrap_function_trace, FunctionTraceWrapper
from newrelic.api.external_trace import wrap_external_trace
from newrelic.api.web_transaction import WSGIApplicationWrapper

Sed in nulla eu est vestibulum convallis. Praesent ante magna, molestie vel porttitor vel, aliquet ut dolor. Proin molestie massa eu tellu.

I am lazy when it comes to searching though documentation on hosting providers web sites. HHG was therefore awesome for me as it brought all the important stuff I needed to know into one place. An indispensable quick reference guide.

I can be lazy when it comes to searching web documentation. HHG is awesome as it combines the important stuff I need to know in one place.

@GrahamDumpleton
GrahamDumpleton / gist:3564216
Created September 1, 2012 05:04
PyCon US 2013 Talk Proposal 1

Title

Why Apache sucks for hosting Python web applications.

Category

Web Frameworks

@GrahamDumpleton
GrahamDumpleton / gist:3519068
Created August 29, 2012 21:14
Incorrect creation of Django WSGI application on each request.
# This is correct.
import os, sys
sys.path.append('/usr/local/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
# This must be at global scope.
_application = django.core.handlers.wsgi.WSGIHandler()
@GrahamDumpleton
GrahamDumpleton / gist:3511393
Created August 29, 2012 11:49
Enabling Pyramid instrumentation in agent configuration file.
[import-hook:pyramid.router]
enabled = true
execute = newrelic.hooks.framework_pyramid:instrument_pyramid_router
meta = getattr(instance, '_meta', None)
if meta is None:
group = 'Python/TastyPie/Api'
name = instance.api_name
elif meta.api_name is not None:
group = 'Python/TastyPie/Api'
name = '%s/%s/%s' % (meta.api_name, meta.resource_name, view_name)
else:
group = 'Python/TastyPie/Resource'