Beispiel #1
0
 def decorator(*args, **keywords):
     logger.info('injecting AgentMiddleware into django')
     settings = args[0]
     a = original_method(settings, 'MIDDLEWARE_CLASSES')
     a = prepend_to_tuple(a, 'librato_python_web.instrumentor.web.django_.AgentMiddleware')
     settings._wrapped.MIDDLEWARE_CLASSES = a
     logger.info('new middleware stack: %s', str(a))
     a = original_method(*args, **keywords)
     unwrap_method(decorator)
     return a
Beispiel #2
0
def django_inject_middleware(original_method, *args, **keywords):
    if not hasattr(django_inject_middleware, "injected_middleware"):
        # Do this the very first time only
        logger.info("injecting AgentMiddleware into django")
        django_inject_middleware.injected_middleware = True

        try:
            settings = args[0]
            a = original_method(settings, "MIDDLEWARE_CLASSES")
            a = prepend_to_tuple(a, "librato_python_web.instrumentor.web.django_.AgentMiddleware")
            settings._wrapped.MIDDLEWARE_CLASSES = a
            logger.info("new middleware stack: %s", str(a))
        except:
            logger.exception("Error injecting django middleware")

    return original_method(*args, **keywords)
Beispiel #3
0
def django_inject_middleware(original_method, *args, **keywords):
    if not hasattr(django_inject_middleware, 'injected_middleware'):
        # Do this the very first time only
        logger.info('injecting AgentMiddleware into django')
        django_inject_middleware.injected_middleware = True

        try:
            settings = args[0]
            a = original_method(settings, 'MIDDLEWARE_CLASSES')
            a = prepend_to_tuple(
                a,
                'librato_python_web.instrumentor.web.django_.AgentMiddleware')
            settings._wrapped.MIDDLEWARE_CLASSES = a
            logger.info('new middleware stack: %s', str(a))
        except:
            logger.exception("Error injecting django middleware")

    return original_method(*args, **keywords)