Updated Chameleon instrumentation
authorThierry Florac <tflorac@ulthar.net>
Wed, 01 Jul 2020 12:36:21 +0200
changeset 28 57ede88e05a1
parent 27 f39e48cdd7b6
child 29 76e8fa9c5516
Updated Chameleon instrumentation
src/pyams_apm/packages/chameleon.py
--- a/src/pyams_apm/packages/chameleon.py	Mon Jun 29 22:32:01 2020 +0200
+++ b/src/pyams_apm/packages/chameleon.py	Wed Jul 01 12:36:21 2020 +0200
@@ -36,8 +36,10 @@
                           span_type='template',
                           span_subtype='chameleon',
                           span_action='cook',
-                          extra={'filename': instance.filename},
-                          leaf=True):
+                          extra={
+                              'filename': instance.filename
+                          },
+                          leaf=False):
             return wrapped(*args, **kwargs)
 
 
@@ -51,10 +53,22 @@
     def call(self, module, method, wrapped, instance, args, kwargs):
         # pylint: disable=too-many-arguments
         """Wrapped method call"""
+        view = kwargs.get('view')
+        context = kwargs.get('context')
         with capture_span('RENDER',
                           span_type='template',
                           span_subtype='chameleon',
                           span_action='render',
-                          extra={'filename': instance.filename},
-                          leaf=True):
+                          tags={
+                              'view': '{}.{}'.format(view.__class__.__module__,
+                                                     view.__class__.__name__)
+                              if view is not None else None,
+                              'context': '{}.{}'.format(context.__class__.__module__,
+                                                        context.__class__.__name__)
+                              if context is not None else None
+                          },
+                          extra={
+                              'filename': instance.filename
+                          },
+                          leaf=False):
             return wrapped(*args, **kwargs)