src/pyams_apm/include.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 from pyramid.interfaces import IApplicationCreated
       
    20 
       
    21 # import packages
       
    22 import elasticapm
       
    23 from elasticapm.instrumentation import register
       
    24 from pyramid.events import subscriber
       
    25 
       
    26 
       
    27 @subscriber(IApplicationCreated)
       
    28 def handle_apm_application(event):
       
    29     register.register('pyams_apm.packages.chameleon.ChameleonCookingInstrumentation')
       
    30     register.register('pyams_apm.packages.chameleon.ChameleonRenderingInstrumentation')
       
    31     elasticapm.instrument()
       
    32 
       
    33 
       
    34 def include_package(config):
       
    35     """Pyramid package include"""
       
    36 
       
    37     # add APM tween
       
    38     config.add_tween('pyams_apm.tween.elastic_apm_tween_factory')
       
    39 
       
    40     # scan package
       
    41     config.scan()