Couchbase en NewRelic

Todos los créditos van realmente a http://ssutch.org/pycassa-newrelic-tracing/

import newrelic.api.function_trace


def instrument_couchbase_connection(module):
newrelic
.api.function_trace.wrap_function_trace(module, 'Connection.__init__')


_patch_methods
= ['set', 'add', 'replace', 'append', 'prepend',
'get', 'delete', 'incr', 'decr', 'stats',
'set_multi', 'add_multi', 'replace_multi', 'append_multi', 'prepend_multi', 'get_multi']


def instrument_couchbase_methods(module):
for meth in _patch_methods:
try:
newrelic
.api.function_trace.wrap_function_trace(module, 'Connection.{}'.format(meth))
except AttributeError:
print 'not tracing Connection.{}'.format(meth)


def instrument_couchbase():
instrument_couchbase_connection
('couchbase.libcouchbase')
instrument_couchbase_methods
('couchbase.libcouchbase')