src/pyams_apm/packages/chameleon.py
changeset 0 1cc388b5cf69
child 2 e78763bdfb3f
equal deleted inserted replaced
-1:000000000000 0:1cc388b5cf69
       
     1 #
       
     2 # Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 
       
    20 # import packages
       
    21 from elasticapm.instrumentation.packages.base import AbstractInstrumentedModule
       
    22 from elasticapm.traces import capture_span
       
    23 
       
    24 
       
    25 class ChameleonCookingInstrumentation(AbstractInstrumentedModule):
       
    26     name = "chameleon"
       
    27 
       
    28     instrument_list = [("chameleon.template", "BaseTemplate.cook")]
       
    29 
       
    30     def call(self, module, method, wrapped, instance, args, kwargs):
       
    31         with capture_span('COOK', "template.chameleon.cook",
       
    32                           {'filename': instance.filename}, leaf=True):
       
    33             return wrapped(*args, **kwargs)
       
    34 
       
    35 
       
    36 class ChameleonRenderingInstrumentation(AbstractInstrumentedModule):
       
    37     name = "chameleon"
       
    38 
       
    39     instrument_list = [("chameleon.template", "BaseTemplate.render")]
       
    40 
       
    41     def call(self, module, method, wrapped, instance, args, kwargs):
       
    42         with capture_span('RENDER', "template.chameleon.render",
       
    43                           {'filename': instance.filename}, leaf=True):
       
    44             return wrapped(*args, **kwargs)