--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_apm/packages/ldap3.py Wed Sep 19 11:03:57 2018 +0200
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2008-2017 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from elasticapm.instrumentation.packages.base import AbstractInstrumentedModule
+from elasticapm.traces import capture_span
+
+
+class LDAP3BindInstrumentation(AbstractInstrumentedModule):
+ name = "ldap.bind"
+
+ instrument_list = [("ldap3.connection", "Connection.bind")]
+
+ def call(self, module, method, wrapped, instance, args, kwargs):
+ with capture_span('LDAP.BIND', "db.ldap", leaf=True):
+ return wrapped(*args, **kwargs)
+
+
+class LDAP3SearchInstrumentation(AbstractInstrumentedModule):
+ name = "ldap.search"
+
+ instrument_list = [("ldap3.connection", "Connection.search")]
+
+ def call(self, module, method, wrapped, instance, args, kwargs):
+ with capture_span('LDAP.SEARCH', "db.ldap", leaf=True):
+ return wrapped(*args, **kwargs)