src/pyams_apm/packages/chameleon.py
changeset 2 e78763bdfb3f
parent 0 1cc388b5cf69
child 15 1cedda2f8455
equal deleted inserted replaced
1:57857e3d151c 2:e78763bdfb3f
    11 #
    11 #
    12 
    12 
    13 __docformat__ = 'restructuredtext'
    13 __docformat__ = 'restructuredtext'
    14 
    14 
    15 
    15 
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 
       
    20 # import packages
       
    21 from elasticapm.instrumentation.packages.base import AbstractInstrumentedModule
    16 from elasticapm.instrumentation.packages.base import AbstractInstrumentedModule
    22 from elasticapm.traces import capture_span
    17 from elasticapm.traces import capture_span
    23 
    18 
    24 
    19 
    25 class ChameleonCookingInstrumentation(AbstractInstrumentedModule):
    20 class ChameleonCookingInstrumentation(AbstractInstrumentedModule):
    26     name = "chameleon"
    21     name = "chameleon_cooking"
    27 
    22 
    28     instrument_list = [("chameleon.template", "BaseTemplate.cook")]
    23     instrument_list = [("chameleon.template", "BaseTemplate.cook")]
    29 
    24 
    30     def call(self, module, method, wrapped, instance, args, kwargs):
    25     def call(self, module, method, wrapped, instance, args, kwargs):
    31         with capture_span('COOK', "template.chameleon.cook",
    26         with capture_span('COOK', "template.chameleon.cook",
    32                           {'filename': instance.filename}, leaf=True):
    27                           {'filename': instance.filename}, leaf=True):
    33             return wrapped(*args, **kwargs)
    28             return wrapped(*args, **kwargs)
    34 
    29 
    35 
    30 
    36 class ChameleonRenderingInstrumentation(AbstractInstrumentedModule):
    31 class ChameleonRenderingInstrumentation(AbstractInstrumentedModule):
    37     name = "chameleon"
    32     name = "chameleon_rendering"
    38 
    33 
    39     instrument_list = [("chameleon.template", "BaseTemplate.render")]
    34     instrument_list = [("chameleon.template", "BaseTemplate.render")]
    40 
    35 
    41     def call(self, module, method, wrapped, instance, args, kwargs):
    36     def call(self, module, method, wrapped, instance, args, kwargs):
    42         with capture_span('RENDER', "template.chameleon.render",
    37         with capture_span('RENDER', "template.chameleon.render",