Exemplo n.º 1
0
    def extract(self, *args, **kwargs):
        try:
            object = meth(self, *args, **kwargs)
            user = self.get('AUTHENTICATED_USER')
            username = user.getUserName()
            if username == 'Anonymous User':
                partition = 'Anonymous'
            else:
                partition = 'Authenticated'

            kv = {'Partition': partition, 'Class': object.__class__}

            # Old school CMF style page template
            if isinstance(object, PageTemplate):
                kv['Action'] = object.getId()
                kv['Template'] = object.pt_source_file()
                parent = object.getParentNode()
                kv['Controller'] = parent.meta_type

            # Z3 style views
            elif isinstance(object, BrowserView):
                kv['Action'] = object.__name__
                if hasattr(object.context, 'meta_type'):
                    kv['Controller'] = object.context.meta_type

            if 'Controller' not in kv:
                kv['Controller'] = 'Unknown'

            oboe.log('info', None, keys=kv, store_backtrace=False)
            return object

        except:
            raise
Exemplo n.º 2
0
def AsyncHTTPClient_start(request):
    """ takes 'request' param, which is the outgoing HTTPRequest, not the request currently being handled """
    # this is called from AsyncHTTPClient.fetch(), which runs from the RequestHandler's context
    oboe.log("entry", "cURL", keys={'cURL_URL':request.url, 'Async':True})
    ctx = oboe.Context.get_default()
    if hasattr(request, 'headers'):
        if (hasattr(request.headers, '__setitem__')): # could be dict or tornado.httputil.HTTPHeaders
            request.headers['X-Trace'] = str(ctx) # add X-Trace header to outgoing request

    request._oboe_ctx = ctx.copy()
Exemplo n.º 3
0
 def process_view(self, request, view_func, view_args, view_kwargs):
     if not oboe.Context.get_default().is_valid():
         return
     try:
         kvs = {'Controller': view_func.__module__,
                # XXX Not Python2.4-friendly
                'Action': view_func.__name__ if hasattr(view_func, '__name__') else None}
         oboe.log('process_view', None, keys=kvs, store_backtrace=False)
     except Exception, e:
         print >> sys.stderr, "Oboe middleware error:", self._singleline(e)
Exemplo n.º 4
0
def AsyncHTTPClient_start(request):
    """ takes 'request' param, which is the outgoing HTTPRequest, not the request currently being handled """
    # this is called from AsyncHTTPClient.fetch(), which runs from the RequestHandler's context
    oboe.log("entry", "cURL", keys={'cURL_URL': request.url, 'Async': True})
    ctx = oboe.Context.get_default()
    if hasattr(request, 'headers'):
        if (hasattr(request.headers, '__setitem__')
            ):  # could be dict or tornado.httputil.HTTPHeaders
            request.headers['X-Trace'] = str(
                ctx)  # add X-Trace header to outgoing request

    request._oboe_ctx = ctx.copy()
Exemplo n.º 5
0
    def wrapper(*f_args, **f_kwargs):
        ret = func(*f_args, **f_kwargs)
        try:
            conn_obj = f_args[0]
            if 'path' in dir(conn_obj):
                host = 'localhost'
            else:
                host = conn_obj.host + ':' + str(conn_obj.port)

            oboe.log('info', layer_name, keys={'RemoteHost': host}, 
                store_backtrace=oboe._collect_backtraces('redis'))
        except Exception, e:
            print >> sys.stderr, "Oboe error: %s" % e
Exemplo n.º 6
0
    def wrapper(*f_args, **f_kwargs):
        ret = func(*f_args, **f_kwargs)
        try:
            conn_obj = f_args[0]
            if 'path' in dir(conn_obj):
                host = 'localhost'
            else:
                host = conn_obj.host + ':' + str(conn_obj.port)

            oboe.log('info',
                     layer_name,
                     keys={'RemoteHost': host},
                     store_backtrace=oboe._collect_backtraces('redis'))
        except Exception, e:
            print >> sys.stderr, "Oboe error: %s" % e
Exemplo n.º 7
0
    def wrapper(*f_args, **f_kwargs):
        ret = func(*f_args, **f_kwargs)
        try:
            args = {'KVKey' : f_args[1]}
            (host, _) = ret
            if host:
                if host.family == socket.AF_INET:
                    args['RemoteHost'] = host.ip
                elif host.family == socket.AF_UNIX:
                    args['RemoteHost'] = 'localhost'

            oboe.log('info', layer_name, keys=args,
                store_backtrace=oboe._collect_backtraces('memcache'))
        except Exception, e:
            print >> sys.stderr, "Oboe error: %s" % e
Exemplo n.º 8
0
    def wrapper(*f_args, **f_kwargs):
        ret = func(*f_args, **f_kwargs)
        try:
            args = {'KVKey' : f_args[1]}
            (host, _) = ret
            if host:
                if host.family == socket.AF_INET:
                    args['RemoteHost'] = host.ip
                elif host.family == socket.AF_UNIX:
                    args['RemoteHost'] = 'localhost'

            oboe.log('info', layer_name, keys=args,
                store_backtrace=oboe._collect_backtraces('memcache'))
        except Exception, e:
            print >> sys.stderr, "Oboe error: %s" % e
Exemplo n.º 9
0
    def extract(self, *args, **kwargs):

        try:
            object = meth(self, *args, **kwargs)
            user = self.get('AUTHENTICATED_USER')
            username = user.getUserName()
            if username == 'Anonymous User':
                partition = 'Anonymous'
            else:
                partition = 'Authenticated'

            if detailed_partition:
                partition = "%s %s %s" % (partition, SYSINFO['hostname'],
                                          SYSINFO['procname'])

            kv = {'Partition': partition, 'Class': object.__class__}

            # Old school CMF style page template
            if isinstance(object, PageTemplate):
                kv['Action'] = object.getId()
                kv['Template'] = object.pt_source_file()
                parent = object.getParentNode()
                kv['Controller'] = parent.meta_type

            # Z3 style views
            elif isinstance(object, BrowserView):
                kv['Action'] = object.__name__
                if hasattr(object.context, 'meta_type'):
                    kv['Controller'] = object.context.meta_type

            if 'Controller' not in kv:
                kv['Controller'] = 'Unknown'

            oboe.log('info', None, keys=kv, store_backtrace=False)
            return object

        except:
            raise
Exemplo n.º 10
0
    def extract(self, key):
        kv = {'KVOp': 'get', 'KVKey': key}
        oboe.log('entry', 'memoize', keys=kv, store_backtrace=False)

        try:
            val = meth(self, key)
            kv = {'KVHit': True}
            oboe.log('exit', 'memoize', keys=kv, store_backtrace=False)
            return val

        except:
            kv = {'KVHit': False}
            oboe.log('exit', 'memoize', keys=kv, store_backtrace=False)
            raise
Exemplo n.º 11
0
    def extract(self, key):
        kv = {'KVOp': 'get', 'KVKey': key}
        oboe.log('entry', 'memoize', keys=kv, store_backtrace=False)

        try:
            val = meth(self, key)
            kv = {'KVHit': True}
            oboe.log('exit', 'memoize', keys=kv, store_backtrace=False)
            return val

        except:
            kv = {'KVHit': False}
            oboe.log('exit', 'memoize', keys=kv, store_backtrace=False)
            raise