--- a/src/pyams_apm/include.py Wed Sep 19 12:41:27 2018 +0200
+++ b/src/pyams_apm/include.py Thu Nov 08 15:28:16 2018 +0100
@@ -12,22 +12,18 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
-
-# import interfaces
-from pyramid.interfaces import IApplicationCreated
-
-# import packages
import elasticapm
from elasticapm.instrumentation import register
from pyramid.events import subscriber
+from pyramid.interfaces import IApplicationCreated
@subscriber(IApplicationCreated)
def handle_apm_application(event):
+ register.register('pyams_apm.packages.ldap3.LDAP3OpenInstrumentation')
register.register('pyams_apm.packages.ldap3.LDAP3BindInstrumentation')
register.register('pyams_apm.packages.ldap3.LDAP3SearchInstrumentation')
+ register.register('pyams_apm.packages.ldap3.LDAP3GetResponseInstrumentation')
register.register('pyams_apm.packages.chameleon.ChameleonCookingInstrumentation')
register.register('pyams_apm.packages.chameleon.ChameleonRenderingInstrumentation')
elasticapm.instrument()
--- a/src/pyams_apm/packages/ldap3.py Wed Sep 19 12:41:27 2018 +0200
+++ b/src/pyams_apm/packages/ldap3.py Thu Nov 08 15:28:16 2018 +0100
@@ -16,6 +16,19 @@
from elasticapm.traces import capture_span
+class LDAP3OpenInstrumentation(AbstractInstrumentedModule):
+ name = "ldap.open"
+
+ instrument_list = [
+ ("ldap3.strategy.base", "BaseStrategy.open"),
+ ("ldap3.strategy.reusable", "ReusableStrategy.open")
+ ]
+
+ def call(self, module, method, wrapped, instance, args, kwargs):
+ with capture_span('LDAP.OPEN', "db.ldap", leaf=True):
+ return wrapped(*args, **kwargs)
+
+
class LDAP3BindInstrumentation(AbstractInstrumentedModule):
name = "ldap.bind"
@@ -39,3 +52,16 @@
}
}, leaf=True):
return wrapped(*args, **kwargs)
+
+
+class LDAP3GetResponseInstrumentation(AbstractInstrumentedModule):
+ name = "ldap.get_response"
+
+ instrument_list = [
+ ("ldap3.strategy.base", "BaseStrategy.get_response"),
+ ("ldap3.strategy.reusable", "ReusableStrategy.get_response")
+ ]
+
+ def call(self, module, method, wrapped, instance, args, kwargs):
+ with capture_span('LDAP.GET_RESPONSE', "db.ldap", leaf=True):
+ return wrapped(*args, **kwargs)