예제 #1
0
def instrument_gluon_template(module):

    # Wrap parsing/compilation of template files, using
    # the name of the template relative to the context
    # of the application it is contained in. Use a group
    # of 'Template/Compile'. Rendering of template is
    # picked up when executing the code object created
    # from this compilation step.

    def name_function_parse_template(filename,
                                     path='views/',
                                     context=dict(),
                                     *args,
                                     **kwargs):
        if 'request' in context:
            folder = context['request'].folder
            if path.startswith(folder):
                return '%s/%s' % (path[len(folder):], filename)
        else:
            return '%s/%s' % (path, filename)

    wrap_function_trace(module,
                        'parse_template',
                        name=name_function_parse_template,
                        group='Template/Compile')
예제 #2
0
def instrument_gluon_restricted(module):

    # Wrap function which executes all the compiled
    # Python code files. The name used corresponds to
    # path of the resource within the context of the
    # application directory. The group used is either
    # 'Script/Execute' or 'Template/Render' based on
    # whether we can work out whether code object
    # corresponded to compiled template file or not.

    def name_function_restricted(code, environment={}, layer='Unknown'):
        if 'request' in environment:
            folder = environment['request'].folder
            if layer.startswith(folder):
                return layer[len(folder):]
        return layer

    def group_function_restricted(code, environment={}, layer='Unknown'):
        parts = layer.split('.')
        if parts[-1] in ['html'] or parts[-2:] in [['html', 'pyc']]:
            return 'Template/Render'
        return 'Script/Execute'

    wrap_function_trace(module,
                        'restricted',
                        name=name_function_restricted,
                        group=group_function_restricted)
예제 #3
0
def instrument(module):

    if module.__name__ == 'jinja2.environment':

        wrap_function_trace(module, 'Template.render',
                            name_template_render, 'Template/Render')

        wrap_function_trace(module, 'Environment.compile',
                            name_template_compile, 'Template/Compile')
예제 #4
0
def instrument(module):

    if module.__name__ == 'web.application':
        wrap_out_function(module, 'application.wsgifunc', WSGIApplicationWrapper)
        wrap_in_function(module, 'application._delegate', transaction_name_delegate)
        wrap_pre_function(module, 'application.internalerror', wrap_handle_exception)

    elif module.__name__ == 'web.template':
        wrap_function_trace(module, 'render.__getattr__', template_name, 'Template/Render')
예제 #5
0
def instrument_pymongo_connection(module):

    # Must name function explicitly as pymongo overrides the
    # __getattr__() method in a way that breaks introspection.

    rollup = ('Datastore/all', 'Datastore/MongoDB/all')

    wrap_function_trace(module, 'Connection.__init__',
            name='%s:Connection.__init__' % module.__name__,
            terminal=True, rollup=rollup)
예제 #6
0
def instrument_mako_template(module):

    def template_filename(template, text, filename, *args):
        return filename

    wrap_function_trace(module, '_compile_text',
                        name=template_filename, group='Template/Compile')

    wrap_function_trace(module, '_compile_module_file',
                        name=template_filename, group='Template/Compile')
예제 #7
0
def instrument_cyclone_httpserver(module):
    if hasattr(module, 'HTTPConnection'):

        wrap_function_wrapper(module, 'HTTPConnection._on_headers',
                _bw_wrapper_HTTPConnection__on_headers_)
        wrap_function_wrapper(module, 'HTTPConnection._on_request_body',
                _bw_wrapper_HTTPConnection__on_request_body_)
        wrap_function_wrapper(module, 'HTTPConnection._finish_request',
                _bw_wrapper_HTTPConnection__finish_request)

        if hasattr(module.HTTPConnection, '_parse_mime_body'):
            wrap_function_trace(module, 'HTTPConnection._parse_mime_body')
예제 #8
0
def instrument_cyclone_httpserver(module):
    if hasattr(module, 'HTTPConnection'):

        wrap_function_wrapper(module, 'HTTPConnection._on_headers',
                              _bw_wrapper_HTTPConnection__on_headers_)
        wrap_function_wrapper(module, 'HTTPConnection._on_request_body',
                              _bw_wrapper_HTTPConnection__on_request_body_)
        wrap_function_wrapper(module, 'HTTPConnection._finish_request',
                              _bw_wrapper_HTTPConnection__finish_request)

        if hasattr(module.HTTPConnection, '_parse_mime_body'):
            wrap_function_trace(module, 'HTTPConnection._parse_mime_body')
예제 #9
0
def instrument_pymongo_mongo_client(module):

    # Must name function explicitly as pymongo overrides the
    # __getattr__() method in a way that breaks introspection.

    rollup = ('Datastore/all', 'Datastore/MongoDB/all')

    wrap_function_trace(module,
                        'MongoClient.__init__',
                        name='%s:MongoClient.__init__' % module.__name__,
                        terminal=True,
                        rollup=rollup)
예제 #10
0
def instrument_tornado_httpserver(module):
    if hasattr(module, 'HTTPConnection'):
        # The HTTPConnection class only existed prior to Tornado 4.0.

        wrap_function_wrapper(module, 'HTTPConnection._on_headers',
                _bw_wrapper_HTTPConnection__on_headers_)
        wrap_function_wrapper(module, 'HTTPConnection._on_request_body',
                _bw_wrapper_HTTPConnection__on_request_body_)
        wrap_function_wrapper(module, 'HTTPConnection._finish_request',
                _bw_wrapper_HTTPConnection__finish_request)

        if hasattr(module.HTTPConnection, '_parse_mime_body'):
            wrap_function_trace(module, 'HTTPConnection._parse_mime_body')
예제 #11
0
def instrument_flask_app(module):
    wrap_wsgi_application(module, 'Flask.wsgi_app',
            framework=framework_details())

    wrap_function_wrapper(module, 'Flask.add_url_rule',
            _bw_wrapper_Flask_add_url_rule_input_)

    if hasattr(module.Flask, 'endpoint'):
        wrap_function_wrapper(module, 'Flask.endpoint',
                _bw_wrapper_Flask_endpoint_)

    wrap_function_wrapper(module, 'Flask.handle_http_exception',
            _bw_wrapper_Flask_handle_http_exception_)

    # Use the same wrapper for initial user exception processing and
    # fallback for unhandled exceptions.

    if hasattr(module.Flask, 'handle_user_exception'):
        wrap_function_wrapper(module, 'Flask.handle_user_exception',
                _bw_wrapper_Flask_handle_exception_)

    wrap_function_wrapper(module, 'Flask.handle_exception',
            _bw_wrapper_Flask_handle_exception_)

    # The _register_error_handler() method was only introduced in
    # Flask version 0.7.0.

    if hasattr(module.Flask, '_register_error_handler'):
        wrap_function_wrapper(module, 'Flask._register_error_handler',
                _bw_wrapper_Flask__register_error_handler_)

    # Different before/after methods were added in different versions.
    # Check for the presence of everything before patching.

    if hasattr(module.Flask, 'try_trigger_before_first_request_functions'):
        wrap_function_wrapper(module,
                'Flask.try_trigger_before_first_request_functions',
                _bw_wrapper_Flask_try_trigger_before_first_request_functions_)
        wrap_function_wrapper(module, 'Flask.before_first_request',
                _bw_wrapper_Flask_before_first_request_)

    if hasattr(module.Flask, 'preprocess_request'):
        wrap_function_trace(module, 'Flask.preprocess_request')
        wrap_function_wrapper(module, 'Flask.before_request',
                _bw_wrapper_Flask_before_request_)

    if hasattr(module.Flask, 'process_response'):
        wrap_function_trace(module, 'Flask.process_response')
        wrap_function_wrapper(module, 'Flask.after_request',
                _bw_wrapper_Flask_after_request_)

    if hasattr(module.Flask, 'do_teardown_request'):
        wrap_function_trace(module, 'Flask.do_teardown_request')
        wrap_function_wrapper(module, 'Flask.teardown_request',
                _bw_wrapper_Flask_teardown_request_)

    if hasattr(module.Flask, 'do_teardown_appcontext'):
        wrap_function_trace(module, 'Flask.do_teardown_appcontext')
        wrap_function_wrapper(module, 'Flask.teardown_appcontext',
                _bw_wrapper_Flask_teardown_appcontext_)
예제 #12
0
def instrument_bottle(module):
    global module_bottle
    module_bottle = module

    framework_details = ('Bottle', getattr(module, '__version__'))

    if hasattr(module.Bottle, 'wsgi'):  # version >= 0.9
        wrap_wsgi_application(module,
                              'Bottle.wsgi',
                              framework=framework_details)
    elif hasattr(module.Bottle, '__call__'):  # version < 0.9
        wrap_wsgi_application(module,
                              'Bottle.__call__',
                              framework=framework_details)

    if (hasattr(module, 'Route')
            and hasattr(module.Route, '_make_callback')):  # version >= 0.10
        wrap_out_function(module, 'Route._make_callback',
                          output_wrapper_Route_make_callback)
    elif hasattr(module.Bottle, '_match'):  # version >= 0.9
        wrap_out_function(module, 'Bottle._match', output_wrapper_Bottle_match)
    elif hasattr(module.Bottle, 'match_url'):  # version < 0.9
        wrap_out_function(module, 'Bottle.match_url',
                          output_wrapper_Bottle_match)

    wrap_object_attribute(module, 'Bottle.error_handler',
                          proxy_Bottle_error_handler)

    if hasattr(module, 'auth_basic'):
        wrap_function_wrapper(module, 'auth_basic', wrapper_auth_basic)

    if hasattr(module, 'SimpleTemplate'):
        wrap_function_trace(module, 'SimpleTemplate.render')

    if hasattr(module, 'MakoTemplate'):
        wrap_function_trace(module, 'MakoTemplate.render')

    if hasattr(module, 'CheetahTemplate'):
        wrap_function_trace(module, 'CheetahTemplate.render')

    if hasattr(module, 'Jinja2Template'):
        wrap_function_trace(module, 'Jinja2Template.render')

    if hasattr(module, 'SimpleTALTemplate'):
        wrap_function_trace(module, 'SimpleTALTemplate.render')
예제 #13
0
def instrument_bottle(module):
    global module_bottle
    module_bottle = module

    framework_details = ('Bottle', getattr(module, '__version__'))

    if hasattr(module.Bottle, 'wsgi'): # version >= 0.9
        wrap_wsgi_application(module, 'Bottle.wsgi',
                framework=framework_details)
    elif hasattr(module.Bottle, '__call__'): # version < 0.9
        wrap_wsgi_application(module, 'Bottle.__call__',
                framework=framework_details)

    if (hasattr(module, 'Route') and
            hasattr(module.Route, '_make_callback')): # version >= 0.10
        wrap_out_function(module, 'Route._make_callback',
                output_wrapper_Route_make_callback)
    elif hasattr(module.Bottle, '_match'): # version >= 0.9
        wrap_out_function(module, 'Bottle._match',
                output_wrapper_Bottle_match)
    elif hasattr(module.Bottle, 'match_url'): # version < 0.9
        wrap_out_function(module, 'Bottle.match_url',
                output_wrapper_Bottle_match)

    wrap_object_attribute(module, 'Bottle.error_handler',
            proxy_Bottle_error_handler)

    if hasattr(module, 'auth_basic'):
        wrap_function_wrapper(module, 'auth_basic', wrapper_auth_basic)

    if hasattr(module, 'SimpleTemplate'):
        wrap_function_trace(module, 'SimpleTemplate.render')

    if hasattr(module, 'MakoTemplate'):
        wrap_function_trace(module, 'MakoTemplate.render')

    if hasattr(module, 'CheetahTemplate'):
        wrap_function_trace(module, 'CheetahTemplate.render')

    if hasattr(module, 'Jinja2Template'):
        wrap_function_trace(module, 'Jinja2Template.render')

    if hasattr(module, 'SimpleTALTemplate'):
        wrap_function_trace(module, 'SimpleTALTemplate.render')
예제 #14
0
def instrument_django_template(module):

    # Wrap methods for rendering of Django templates. The name
    # of the method changed in between Django versions so need
    # to check for which one we have. The name of the function
    # trace node is taken from the name of the template. This
    # should be a relative path with the template loader
    # uniquely associating it with a specific template library.
    # Therefore do not need to worry about making it absolute as
    # meaning should be known in the context of the specific
    # Django site.

    def template_name(template, *args):
        return template.name

    if hasattr(module.Template, '_render'):
        wrap_function_trace(module,
                            'Template._render',
                            name=template_name,
                            group='Template/Render')
    else:
        wrap_function_trace(module,
                            'Template.render',
                            name=template_name,
                            group='Template/Render')

    # Django 1.8 no longer has module.libraries. As automatic way is not
    # preferred we can just skip this now.

    if not hasattr(module, 'libraries'):
        return

    # Register template tags used for manual insertion of RUM
    # header and footer.
    #
    # TODO This can now be installed as a separate tag library
    # so should possibly look at deprecating this automatic
    # way of doing things.

    library = module.Library()
    library.simple_tag(blueware_browser_timing_header)
    library.simple_tag(blueware_browser_timing_footer)

    module.libraries['django.templatetags.blueware'] = library
예제 #15
0
def instrument(module):

    if module.__name__ == 'pylons.wsgiapp':
        wrap_error_trace(module, 'PylonsApp.__call__')

    elif module.__name__ == 'pylons.controllers.core':
        wrap_transaction_name(module, 'WSGIController.__call__', name_controller)
        wrap_function_trace( module, 'WSGIController.__call__')

        def name_WSGIController_perform_call(self, func, args):
            return callable_name(func)

        wrap_function_trace(module, 'WSGIController._perform_call',
                            name_WSGIController_perform_call)
        wrap_object(module, 'WSGIController._perform_call', capture_error)

    elif module.__name__ == 'pylons.templating':

        wrap_function_trace(module, 'render_genshi')
        wrap_function_trace(module, 'render_mako')
        wrap_function_trace(module, 'render_jinja2')
예제 #16
0
def instrument_django_template(module):

    # Wrap methods for rendering of Django templates. The name
    # of the method changed in between Django versions so need
    # to check for which one we have. The name of the function
    # trace node is taken from the name of the template. This
    # should be a relative path with the template loader
    # uniquely associating it with a specific template library.
    # Therefore do not need to worry about making it absolute as
    # meaning should be known in the context of the specific
    # Django site.

    def template_name(template, *args):
        return template.name

    if hasattr(module.Template, '_render'):
        wrap_function_trace(module, 'Template._render',
                name=template_name, group='Template/Render')
    else:
        wrap_function_trace(module, 'Template.render',
                name=template_name, group='Template/Render')

    # Django 1.8 no longer has module.libraries. As automatic way is not
    # preferred we can just skip this now.

    if not hasattr(module, 'libraries'):
        return

    # Register template tags used for manual insertion of RUM
    # header and footer.
    #
    # TODO This can now be installed as a separate tag library
    # so should possibly look at deprecating this automatic
    # way of doing things.

    library = module.Library()
    library.simple_tag(blueware_browser_timing_header)
    library.simple_tag(blueware_browser_timing_footer)

    module.libraries['django.templatetags.blueware'] = library
예제 #17
0
def instrument(module):

    if module.__name__ == 'pylons.wsgiapp':
        wrap_error_trace(module, 'PylonsApp.__call__')

    elif module.__name__ == 'pylons.controllers.core':
        wrap_transaction_name(module, 'WSGIController.__call__',
                              name_controller)
        wrap_function_trace(module, 'WSGIController.__call__')

        def name_WSGIController_perform_call(self, func, args):
            return callable_name(func)

        wrap_function_trace(module, 'WSGIController._perform_call',
                            name_WSGIController_perform_call)
        wrap_object(module, 'WSGIController._perform_call', capture_error)

    elif module.__name__ == 'pylons.templating':

        wrap_function_trace(module, 'render_genshi')
        wrap_function_trace(module, 'render_mako')
        wrap_function_trace(module, 'render_jinja2')
예제 #18
0
파일: ioloop.py 프로젝트: aadebuger/oneapm
def instrument_tornado_ioloop(module):
    wrap_function_trace(module, 'IOLoop.add_handler')
    wrap_function_trace(module, 'IOLoop.add_timeout')

    wrap_function_wrapper(module, 'IOLoop.add_callback',
            _bw_wrapper_IOLoop_add_callback_)

    if hasattr(module.IOLoop, 'add_future'):
        wrap_function_wrapper(module, 'IOLoop.add_future',
                _bw_wrapper_IOLoop_add_future_)

    if hasattr(module, 'PollIOLoop'):
        wrap_function_trace(module, 'PollIOLoop.add_handler')

        # For Tornado 4.0+, PollIOLoop.add_timeout has been removed.
        if hasattr(module.PollIOLoop, 'add_timeout'):
            wrap_function_trace(module, 'PollIOLoop.add_timeout')

        wrap_function_wrapper(module, 'PollIOLoop.add_callback',
                _bw_wrapper_IOLoop_add_callback_)

        wrap_function_trace(module, 'PollIOLoop.add_callback_from_signal')
예제 #19
0
def instrument_tornado_ioloop(module):
    wrap_function_trace(module, 'IOLoop.add_handler')
    wrap_function_trace(module, 'IOLoop.add_timeout')

    wrap_function_wrapper(module, 'IOLoop.add_callback',
                          _bw_wrapper_IOLoop_add_callback_)

    if hasattr(module.IOLoop, 'add_future'):
        wrap_function_wrapper(module, 'IOLoop.add_future',
                              _bw_wrapper_IOLoop_add_future_)

    if hasattr(module, 'PollIOLoop'):
        wrap_function_trace(module, 'PollIOLoop.add_handler')

        # For Tornado 4.0+, PollIOLoop.add_timeout has been removed.
        if hasattr(module.PollIOLoop, 'add_timeout'):
            wrap_function_trace(module, 'PollIOLoop.add_timeout')

        wrap_function_wrapper(module, 'PollIOLoop.add_callback',
                              _bw_wrapper_IOLoop_add_callback_)

        wrap_function_trace(module, 'PollIOLoop.add_callback_from_signal')
예제 #20
0
def instrument_weberror_reporter(module):

    def smtp_url(reporter, *args, **kwargs):
        return 'smtp://' + reporter.smtp_server

    wrap_external_trace(module, 'EmailReporter.report', 'weberror', smtp_url)
    wrap_function_trace(module, 'EmailReporter.report')

    wrap_function_trace(module, 'LogReporter.report')
    wrap_function_trace(module, 'FileReporter.report')
예제 #21
0
def instrument_gluon_compileapp(module):

    # Wrap the run_models_in() function as first phase
    # in executing a request after URL has been mapped
    # to a specific view. The name given to the web
    # transaction is combination of the application name
    # and view path.

    def transaction_name_run_models_in(environment):
        return '%s::%s' % (environment['request'].application,
                           environment['response'].view)

    wrap_transaction_name(module,
                          'run_models_in',
                          name=transaction_name_run_models_in,
                          group='Web2Py')

    # Wrap functions which coordinate the execution of
    # the separate models, controller and view phases of
    # the request handling. This is done for timing how
    # long taken within these phases of request
    # handling.

    def name_function_run_models_in(environment):
        return '%s/%s' % (environment['request'].controller,
                          environment['request'].function)

    wrap_function_trace(module,
                        'run_models_in',
                        name=name_function_run_models_in,
                        group='Python/Web2Py/Models')

    def name_function_run_controller_in(controller, function, environment):
        return '%s/%s' % (controller, function)

    wrap_function_trace(module,
                        'run_controller_in',
                        name=name_function_run_controller_in,
                        group='Python/Web2Py/Controller')

    def name_function_run_view_in(environment):
        return '%s/%s' % (environment['request'].controller,
                          environment['request'].function)

    wrap_function_trace(module,
                        'run_view_in',
                        name=name_function_run_view_in,
                        group='Python/Web2Py/View')
예제 #22
0
파일: web.py 프로젝트: aadebuger/oneapm
def _bw_wrapper_RequestHandler___init___(wrapped, instance, args, kwargs):
    # In this case we are actually wrapping the instance method on an
    # actual instance of a handler class rather than the class itself.
    # This is so we can wrap any derived version of this method when
    # it has been overridden in a handler class.

    wrap_function_wrapper(instance, 'on_connection_close',
            _bw_wrapper_RequestHandler_on_connection_close)

    wrap_function_trace(instance, 'prepare')

    if hasattr(instance, 'on_finish'):
        wrap_function_trace(instance, 'on_finish')

    handler = instance

    for name in handler.SUPPORTED_METHODS:
        name = name.lower()
        if hasattr(handler, name):
            wrap_function_trace(instance, name)

    return wrapped(*args, **kwargs)
예제 #23
0
파일: web.py 프로젝트: aadebuger/oneapm
def _bw_wrapper_RequestHandler___init___(wrapped, instance, args, kwargs):
    # In this case we are actually wrapping the instance method on an
    # actual instance of a handler class rather than the class itself.
    # This is so we can wrap any derived version of this method when
    # it has been overridden in a handler class.

    wrap_function_wrapper(instance, 'on_connection_close',
                          _bw_wrapper_RequestHandler_on_connection_close)

    wrap_function_trace(instance, 'prepare')

    if hasattr(instance, 'on_finish'):
        wrap_function_trace(instance, 'on_finish')

    handler = instance

    for name in handler.SUPPORTED_METHODS:
        name = name.lower()
        if hasattr(handler, name):
            wrap_function_trace(instance, name)

    return wrapped(*args, **kwargs)
예제 #24
0
def instrument_gearman_client(module):
    wrap_function_trace(module, 'GearmanClient.submit_job')
    wrap_function_trace(module, 'GearmanClient.submit_multiple_jobs')
    wrap_function_trace(module, 'GearmanClient.submit_multiple_requests')
    wrap_function_trace(module, 'GearmanClient.wait_until_jobs_accepted')
    wrap_function_trace(module, 'GearmanClient.wait_until_jobs_completed')
    wrap_function_trace(module, 'GearmanClient.get_job_status')
    wrap_function_trace(module, 'GearmanClient.get_job_statuses')
    wrap_function_trace(module, 'GearmanClient.wait_until_job_statuses_received')
예제 #25
0
def instrument_django_core_mail(module):
    wrap_function_trace(module, 'mail_admins')
    wrap_function_trace(module, 'mail_managers')
    wrap_function_trace(module, 'send_mail')
예제 #26
0
def instrument_django_http_multipartparser(module):
    wrap_function_trace(module, 'MultiPartParser.parse')
예제 #27
0
def instrument_flask_templating(module):
    wrap_function_trace(module, 'render_template')
    wrap_function_trace(module, 'render_template_string')
예제 #28
0
def instrument_tornado_simple_httpclient(module):
    wrap_function_trace(module, 'SimpleAsyncHTTPClient.fetch')
예제 #29
0
파일: reactor.py 프로젝트: aadebuger/oneapm
def instrument_twisted_internet_reactor(module):
    if hasattr(module, 'doIteration'):
        wrap_function_trace(module, 'doIteration')
예제 #30
0
def instrument_cyclone_httputil(module):
    if hasattr(module, 'parse_body_arguments'):
        wrap_function_trace(module, 'parse_body_arguments')
    if hasattr(module, 'parse_multipart_form_data'):
        wrap_function_trace(module, 'parse_multipart_form_data')
예제 #31
0
def instrument_cherrypy__cpreqbody(module):
    wrap_function_trace(module, 'process_multipart')
    wrap_function_trace(module, 'process_multipart_form_data')
예제 #32
0
def instrument_weberror_errormiddleware(module):

    wrap_function_trace(module, 'handle_exception')
예제 #33
0
def instrument_tornado_simple_httpclient(module):
    wrap_function_trace(module, 'SimpleAsyncHTTPClient.fetch')
예제 #34
0
def instrument_tornado_curl_httpclient(module):
    wrap_function_trace(module, 'CurlAsyncHTTPClient.fetch')
예제 #35
0
def instrument_django_core_mail_message(module):
    wrap_function_trace(module, 'EmailMessage.send')
예제 #36
0
def instrument_gearman_client(module):
    wrap_function_trace(module, 'GearmanClient.submit_job')
    wrap_function_trace(module, 'GearmanClient.submit_multiple_jobs')
    wrap_function_trace(module, 'GearmanClient.submit_multiple_requests')
    wrap_function_trace(module, 'GearmanClient.wait_until_jobs_accepted')
    wrap_function_trace(module, 'GearmanClient.wait_until_jobs_completed')
    wrap_function_trace(module, 'GearmanClient.get_job_status')
    wrap_function_trace(module, 'GearmanClient.get_job_statuses')
    wrap_function_trace(module,
                        'GearmanClient.wait_until_job_statuses_received')
예제 #37
0
def instrument_cherrypy__cpreqbody(module):
    wrap_function_trace(module, 'process_multipart')
    wrap_function_trace(module, 'process_multipart_form_data')
예제 #38
0
def instrument_django_http_multipartparser(module):
    wrap_function_trace(module, 'MultiPartParser.parse')
예제 #39
0
def instrument_django_core_mail(module):
    wrap_function_trace(module, 'mail_admins')
    wrap_function_trace(module, 'mail_managers')
    wrap_function_trace(module, 'send_mail')
예제 #40
0
def instrument_cherrypy__cprequest(module):
    wrap_function_trace(module, 'Request.handle_error')
예제 #41
0
def instrument_openerp_http(module):

    # Wrap the correspond dispatch function for request.
    # At this point the url and function info has bind to an endpoint.
    # The name used as web transaction is the path to the function.
    def transaction_httprequest_dispatch(instance, *args, **kwargs):
        return '{0}:{1}'.format(callable_name(instance.endpoint.method),
                                instance.httprequest.method)

    wrap_transaction_name(module,
                          'HttpRequest.dispatch',
                          name=transaction_httprequest_dispatch,
                          group='Python/OpenERP')

    def transaction_jsonrequest_dispatch(instance, *args, **kwargs):
        return '{0}:{1}'.format(callable_name(instance.endpoint.method),
                                instance.httprequest.method)

    wrap_transaction_name(module,
                          'JsonRequest.dispatch',
                          name=transaction_jsonrequest_dispatch,
                          group='Python/OpenERP')

    # Wrap functions which coordinate the execution of the request
    # initial phase. This is for timing how long this phase take.
    # This phase only execute once.
    # NOTICE: this is not captured due to the unkown bug that some of the
    # first request data was not captured.
    wrap_function_trace(module, 'Root.load_addons', group='Fixture/Execute')

    # Wrap functions which coordinate the execution of the different phases
    # of the request handling. This is for timing how long these phases take.
    wrap_function_trace(module, 'Root.setup_session', group='Python/OpenERP')

    wrap_function_trace(module, 'Root.setup_db', group='Python/OpenERP')

    wrap_function_trace(module, 'Root.setup_lang', group='Python/OpenERP')

    wrap_function_trace(module,
                        'WebRequest._call_function',
                        group='Python/OpenERP')

    wrap_function_trace(module, 'Response.render', group='Python/OpenERP')
예제 #42
0
def instrument_openerp_modules_registry(module):

    # NOTICE: this is not captured due to the unkown bug that some of the
    # first request data was not captured.
    wrap_function_trace(module, 'RegistryManager.new', group='Fixture/Create')
예제 #43
0
def instrument_flask_app(module):
    wrap_wsgi_application(module,
                          'Flask.wsgi_app',
                          framework=framework_details())

    wrap_function_wrapper(module, 'Flask.add_url_rule',
                          _bw_wrapper_Flask_add_url_rule_input_)

    if hasattr(module.Flask, 'endpoint'):
        wrap_function_wrapper(module, 'Flask.endpoint',
                              _bw_wrapper_Flask_endpoint_)

    wrap_function_wrapper(module, 'Flask.handle_http_exception',
                          _bw_wrapper_Flask_handle_http_exception_)

    # Use the same wrapper for initial user exception processing and
    # fallback for unhandled exceptions.

    if hasattr(module.Flask, 'handle_user_exception'):
        wrap_function_wrapper(module, 'Flask.handle_user_exception',
                              _bw_wrapper_Flask_handle_exception_)

    wrap_function_wrapper(module, 'Flask.handle_exception',
                          _bw_wrapper_Flask_handle_exception_)

    # The _register_error_handler() method was only introduced in
    # Flask version 0.7.0.

    if hasattr(module.Flask, '_register_error_handler'):
        wrap_function_wrapper(module, 'Flask._register_error_handler',
                              _bw_wrapper_Flask__register_error_handler_)

    # Different before/after methods were added in different versions.
    # Check for the presence of everything before patching.

    if hasattr(module.Flask, 'try_trigger_before_first_request_functions'):
        wrap_function_wrapper(
            module, 'Flask.try_trigger_before_first_request_functions',
            _bw_wrapper_Flask_try_trigger_before_first_request_functions_)
        wrap_function_wrapper(module, 'Flask.before_first_request',
                              _bw_wrapper_Flask_before_first_request_)

    if hasattr(module.Flask, 'preprocess_request'):
        wrap_function_trace(module, 'Flask.preprocess_request')
        wrap_function_wrapper(module, 'Flask.before_request',
                              _bw_wrapper_Flask_before_request_)

    if hasattr(module.Flask, 'process_response'):
        wrap_function_trace(module, 'Flask.process_response')
        wrap_function_wrapper(module, 'Flask.after_request',
                              _bw_wrapper_Flask_after_request_)

    if hasattr(module.Flask, 'do_teardown_request'):
        wrap_function_trace(module, 'Flask.do_teardown_request')
        wrap_function_wrapper(module, 'Flask.teardown_request',
                              _bw_wrapper_Flask_teardown_request_)

    if hasattr(module.Flask, 'do_teardown_appcontext'):
        wrap_function_trace(module, 'Flask.do_teardown_appcontext')
        wrap_function_wrapper(module, 'Flask.teardown_appcontext',
                              _bw_wrapper_Flask_teardown_appcontext_)
예제 #44
0
def instrument_flask_templating(module):
    wrap_function_trace(module, 'render_template')
    wrap_function_trace(module, 'render_template_string')
예제 #45
0
def instrument_cherrypy__cprequest(module):
    wrap_function_trace(module, 'Request.handle_error')