def onEnd(self, ret):
     ###############################################################
     if ret:
         pinpointPy.add_clues(PP_HTTP_STATUS_CODE, str(ret.status_code))
     ###############################################################
     super().onEnd(ret)
     return ret
Beispiel #2
0
 def onBefore(self, *args, **kwargs):
     super().onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
     pinpointPy.add_clue(PP_SERVER_TYPE, PP_REMOTE_METHOD)
     arg = self.get_arg(*args, **kwargs)
     pinpointPy.add_clues(PP_ARGS, arg)
     ###############################################################
     return args, kwargs
Beispiel #3
0
 def onBefore(self, *args, **kwargs):
     super().onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
     pinpointPy.add_clue(PP_SERVER_TYPE, PP_REDIS)
     pinpointPy.add_clues(PP_ARGS, ("%s:%s") % (args[1], args[2]))
     ###############################################################
     pinpointPy.add_clue(PP_DESTINATION, str(args[0]))
     return args, kwargs
 def onEnd(self, ret):
     ###############################################################
     pinpointPy.add_clue(PP_NEXT_SPAN_ID,
                         pinpointPy.get_context_key(PP_NEXT_SPAN_ID))
     pinpointPy.add_clues(PP_HTTP_STATUS_CODE, str(ret.status_code))
     pinpointPy.add_clues(PP_RETURN, str(ret))
     ###############################################################
     super().onEnd(ret)
     return ret
 def onBefore(self, *args, **kwargs):
     super().onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(PP_INTERCEPTOR_NAME, args[0].get_view_name())
     pinpointPy.add_clue(PP_SERVER_TYPE, PP_METHOD_CALL)
     ###############################################################
     url = '{%s %r}' % (args[1].method, args[1].get_full_path())
     pinpointPy.add_clues(PP_ARGS, url)
     return args, kwargs
 def onBefore(self,*args, **kwargs):
     args, kwargs = super(PinpointCommonPlugin,self).onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(PP_INTERCEPTOR_NAME,self.getFuncUniqueName())
     pinpointPy.add_clue(PP_SERVER_TYPE,PP_METHOD_CALL)
     arg = self.get_arg(*args, **kwargs)
     pinpointPy.add_clues(PP_ARGS, arg)
     ###############################################################
     # print( threading.currentThread().ident)
     return args,kwargs
 async def pinpoint_trace(*args, **kwargs):
     id = pinpointId.get()
     id = pinpointPy.start_trace(id)
     pinpointId.set(id)
     func_name = func.__name__
     pinpointPy.add_clue('name', func_name, id, 0)
     pinpointPy.add_clues('start', '3434', id)
     ret = await func(*args, **kwargs)
     pinpointPy.add_clue('end', '3434', id)
     id = pinpointPy.end_trace(id)
 def onBefore(self,*args, **kwargs):
     super().onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(PP_INTERCEPTOR_NAME,self.getFuncUniqueName(),self.node_id)
     pinpointPy.add_clue(PP_SERVER_TYPE,PP_METHOD_CALL,self.node_id)
     arg = self.get_arg(*args, **kwargs)
     pinpointPy.add_clues(PP_ARGS, arg,self.node_id)
     ###############################################################
     # print( threading.currentThread().ident)
     return args,kwargs
 def onBefore(self, *args, **kwargs):
     super().onBefore(*args, **kwargs)
     self.url = args[0]
     generatePinpointHeader(self.url, kwargs['headers'])
     ###############################################################
     pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
     pinpointPy.add_clue(PP_SERVER_TYPE, PP_METHOD_CALL)
     pinpointPy.add_clues(PP_ARGS, self.url)
     ###############################################################
     return args, kwargs
Beispiel #10
0
 def onBefore(self, *args, **kwargs):
     args, kwargs = super().onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(FuncName, self.getFuncUniqueName())
     pinpointPy.add_clue(ServerType, PYTHON_METHOD_CALL)
     arg = self.get_arg(*args, **kwargs)
     pinpointPy.add_clues(PY_ARGS, arg)
     ###############################################################
     # print( threading.currentThread().ident)
     return args, kwargs
 def onBefore(self, *args, **kwargs):
     url = args[0]
     target = urlparse(url).netloc
     super().onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
     pinpointPy.add_clue(PP_SERVER_TYPE, PP_REMOTE_METHOD)
     pinpointPy.add_clues(PP_ARGS, url)
     pinpointPy.add_clues(PP_HTTP_URL, url)
     pinpointPy.add_clue(PP_DESTINATION, target)
     ###############################################################
     return args, kwargs
    def onBefore(self, *args, **kwargs):
        super().onBefore(*args, **kwargs)
        self.url = args[0]
        self.target = urlparse(self.url).netloc
        generatePinpointHeader(self.target, kwargs['headers'])
        ###############################################################
        pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_REMOTE_METHOD)
        pinpointPy.add_clues(PP_ARGS, self.url)
        ###############################################################

        return args, kwargs
Beispiel #13
0
    def onBefore(self, *args, **kwargs):
        super(AmqpPlugin, self).onBefore(*args, **kwargs)
        pinpointPy.add_clue(PP_INTERCEPTOR_NAME,self.getFuncUniqueName())
        ###############################################################
        channel =args[0]
        host = channel.connection.client.host
        pinpointPy.add_clue(PP_DESTINATION, host)
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_RABBITMQ_CLIENT)
        pinpointPy.add_clues(PP_RABBITMQ_ROUTINGKEY,kwargs['routing_key'])
        ###############################################################

        return args, kwargs
Beispiel #14
0
    def onBefore(self, *args, **kwargs):
        super(PymemcachePlugin, self).onBefore(*args, **kwargs)
        pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
        ###############################################################
        client = args[0]
        cmd = args[1]
        pinpointPy.add_clue(PP_DESTINATION,
                            self._ClientServerStr(client.servers))
        pinpointPy.add_clues(PP_ARGS, cmd)
        ###############################################################
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_MEMCACHED_FUTURE_GET)

        return args, kwargs
    def onBefore(self, *args, **kwargs):
        super(PyMemcachedPlugin, self).onBefore(*args, **kwargs)
        pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
        ###############################################################
        client = args[0]
        method = args[1]
        host = client.server
        pinpointPy.add_clue(PP_DESTINATION, host)
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_MEMCACHED_FUTURE_GET)
        pinpointPy.add_clues(PP_ARGS, method)
        ###############################################################

        return args, kwargs
Beispiel #16
0
def before_cursor_execute(conn, cursor, statement, parameters, context,
                          executemany):
    pinpointPy.start_trace()
    pinpointPy.add_clue(PP_INTERCEPTOR_NAME, 'before_cursor_execute')
    pinpointPy.add_clue(PP_SQL_FORMAT, statement)
    pinpointPy.add_clues(PP_ARGS, 'user not cared')
    DBUrl = urlparse(str(conn.engine.url))
    if 'mysql' in DBUrl.scheme:
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_MYSQL)

    if 'postgresql' in DBUrl.scheme:
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_POSTGRESQL)

    pinpointPy.add_clue(PP_DESTINATION, DBUrl.hostname)
 def onBefore(self,*args, **kwargs):
     args, kwargs = super(PyMysqlPlugin,self).onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(FuncName,self.getFuncUniqueName())
     pinpointPy.add_clue(ServerType, MYSQL)
     arg = self.get_arg(*args, **kwargs)
     pinpointPy.add_clues(PY_ARGS, arg)
     ###############################################################
     # print( threading.currentThread().ident)
     if self.func_name == 'Connect':
         # self.dst = kwargs['host'] + ":" + kwargs['db']
         self.dst = 'Mysql' + ":" + kwargs['db']
     pinpointPy.add_clue("dst", self.dst)
     return args,kwargs
    def _test_api_flow(self):
        self.assertTrue(pinpointPy.set_agent(collector_host='unix:/tmp/unexist.sock'))
        # self.assertTrue(pinpointPy.enable_debug(None))

        while True:
            id = str(random.randint(1,10000000))
            pinpointPy.set_special_key('sid',id)
            self.assertEqual(pinpointPy.start_trace(),1)
            pinpointPy.add_clue("key","value3")
            pinpointPy.add_clues("key","value3")
            value = pinpointPy.get_special_key('sid')
            self.assertEqual(value,id)
            self.assertEqual(pinpointPy.end_trace(),0)
            pinpointPy.mark_as_error("fghjk","fghjkl",234234)
Beispiel #19
0
 def onBefore(self, *args, **kwargs):
     args, kwargs = super().onBefore(*args, **kwargs)
     ###############################################################
     pinpointPy.add_clue(FuncName, self.getFuncUniqueName())
     pinpointPy.add_clue(ServerType, PYTHON_METHOD_CALL)
     arg = self.get_arg(*args, **kwargs)
     pinpointPy.add_clues(PY_ARGS, arg)
     if "headers" in kwargs:
         self.handleHttpHeader(args[0], kwargs["headers"])
     else:
         kwargs["headers"] = {}
         self.handleHttpHeader(args[0], kwargs["headers"])
     ###############################################################
     return args, kwargs
Beispiel #20
0
    def onEnd(self, ret):
        ###############################################################
        if ret:
            response = ret
            pinpointPy.add_clues(PP_HTTP_STATUS_CODE,
                                 str(response.status_code))
            if response.status_code > 400:
                pinpointPy.add_clue(
                    PP_ADD_EXCEPTION,
                    "status_code is %d" % (response.status_code))

        ###############################################################
        super(CinderRequestPlugin, self).onEnd(ret)
        return ret
Beispiel #21
0
            async def pinpoint_trace(*args, **kwargs):
                id = pinpointId.get()
                id = pinpointPy.start_trace(id)
                pinpointId.set(id)
                func_name = func.__name__
                pinpointPy.add_clue('name', func_name, id, 0)
                pinpointPy.add_clues('start', '3434', id)
                pinpointPy.set_context_key('sid', '12345', id)
                value = pinpointPy.get_context_key('sid', id)
                self.assertEqual(value, '12345')

                ret = await func(*args, **kwargs)
                pinpointPy.add_clue('end', '3434', id)
                id = pinpointPy.end_trace(id)
 async def pinpoint_trace(*args, **kwargs):
     start_size = pinpointPy.start_trace()
     func_name = func.__name__
     pinpointPy.add_clue('name', func_name)
     pinpointPy.add_clues('sdf', '3434')
     ret = await func(*args, **kwargs)
     pinpointPy.add_clue('sdf', '3434')
     end_size = pinpointPy.end_trace()
     if func_name == 'unit':
         self.assertEqual(start_size, 1)
         self.assertEqual(end_size, 0)
     elif func_name == 'unit2':
         self.assertEqual(start_size, 2)
         self.assertEqual(end_size, 1)
     return ret
Beispiel #23
0
    def _test_api_flow(self):
        self.assertTrue(pinpointPy.set_agent(collector_host='unix:/tmp/unexist.sock'))
        # self.assertTrue(pinpointPy.enable_debug(None))

        while self.thread_running:
            pinpointPy.start_trace()
            pinpointPy.set_special_key('sid','12345678')
            pinpointPy.add_clue("key","value3")
            pinpointPy.add_clues("key","value3")
            value = pinpointPy.get_special_key('sid')
            self.assertEqual(value,'12345678')
            pinpointPy.mark_as_error("fghjk","fghjkl",234234)
            pinpointPy.end_trace()
            value = pinpointPy.get_special_key('sid')
            self.assertFalse(value)
Beispiel #24
0
    def onBefore(self, *args, **kwargs):
        super().onBefore(*args, **kwargs)
        ###############################################################
        pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_REDIS)
        arg = self.get_arg(*args, **kwargs)
        pinpointPy.add_clues(PP_ARGS, arg)
        ###############################################################
        if self.func_name == 'Redis':
            if 'host' in kwargs:
                self.dst = kwargs['host'] + str(kwargs['port'])
            elif 'unix_socket_path' in kwargs:
                self.dst = kwargs['host'] + str(kwargs['port'])

        pinpointPy.add_clue(PP_DESTINATION, self.dst)
        return args, kwargs
    def onBefore(self, *args, **kwargs):
        super().onBefore(*args, **kwargs)
        ###############################################################
        pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_RABBITMQ_CLIENT)

        if 'routing_key' in kwargs and not kwargs['routing_key']:
            pinpointPy.add_clues(PP_RABBITMQ_ROUTINGKEY, kwargs['routing_key'])

        if 'exchange' in kwargs and not kwargs['exchange']:
            pinpointPy.add_clues(PP_RABBITMQ_EXCHANGEKEY, kwargs['exchange'])

        connect = args[0].connection
        pinpointPy.add_clue(PP_DESTINATION, str(connect))
        ###############################################################

        return args, kwargs
Beispiel #26
0
    def onBefore(self, *args, **kwargs):
        super().onBefore(*args, **kwargs)
        ###############################################################
        pinpointPy.add_clue(PP_INTERCEPTOR_NAME, self.getFuncUniqueName())
        pinpointPy.add_clue(PP_SERVER_TYPE, PP_RABBITMQ_CLIENT)
        if 'exchange' in kwargs and not kwargs['exchange']:
            pinpointPy.add_clues(PP_RABBITMQ_EXCHANGEKEY, kwargs['exchange'])

        if 'routing_key' in kwargs and not kwargs['routing_key']:
            if kwargs['routing_key'] == 'worker.heartbeat':
                pinpointPy.drop_trace()
            pinpointPy.add_clues(PP_RABBITMQ_ROUTINGKEY, kwargs['routing_key'])
        target = kwargs['headers']['task']
        generatePPRabbitMqHeader(target, kwargs['headers'])

        uri = args[0].connection.as_uri()
        pinpointPy.add_clue(PP_DESTINATION, str(uri))
        ###############################################################
        return args, kwargs
    def test_trace_life(self):
        self.assertFalse(pinpointPy.trace_has_root())
        pinpointPy.start_trace()
        self.assertTrue(pinpointPy.trace_has_root())
        pinpointPy.start_trace()
        self.assertTrue(pinpointPy.trace_has_root())
        pinpointPy.start_trace()
        pinpointPy.start_trace()
        # self.assertRaises(Exception,lambda: pinpointPy.trace_has_root(1025))
        # self.assertRaises(Exception,lambda: pinpointPy.trace_has_root(-1025))

        pinpointPy.add_clue("key", "value")
        pinpointPy.add_clue("key", "value3")
        pinpointPy.set_context_key('sid', '12345')
        value = pinpointPy.get_context_key('sid')
        self.assertEqual(value, '12345')
        pinpointPy.add_clues("key", "values")
        pinpointPy.add_clues("key", "values")
        pinpointPy.add_clues("key", "values")

        pinpointPy.end_trace()
        pinpointPy.end_trace()
        pinpointPy.end_trace()
        pinpointPy.end_trace()
        pinpointPy.force_flush_trace(10)
        self.assertFalse(pinpointPy.trace_has_root())
 def onEnd(self,ret):
     ###############################################################
     pinpointPy.add_clue(PP_DESTINATION, urlparse(self.url)['netloc'])
     pinpointPy.add_clue(PP_SERVER_TYPE, PP_REMOTE_METHOD)
     pinpointPy.add_clue(PP_NEXT_SPAN_ID, pinpointPy.get_context_key(PP_NEXT_SPAN_ID))
     pinpointPy.add_clues(PP_HTTP_URL, self.url)
     pinpointPy.add_clues(PP_HTTP_STATUS_CODE, str(ret.status_code))
     pinpointPy.add_clues(PP_RETURN, str(ret))
     ###############################################################
     super(UrlOpenPlugin,self).onEnd(ret)
     return ret
Beispiel #29
0
    def onEnd(self, ret):
        ###############################################################
        pinpointPy.add_clue("dst", self.getHostFromURL(self.url))
        pinpointPy.add_clue("stp", PYTHON_REMOTE_METHOD)
        pinpointPy.add_clue('nsid', self.get_nsid())
        pinpointPy.add_clues(HTTP_URL, self.url)
        pinpointPy.add_clues(HTTP_STATUS_CODE, str(ret.status_code))
        pinpointPy.add_clues(PY_RETURN, str(ret))

        ###############################################################
        super().onEnd(ret)
        return ret
Beispiel #30
0
    def test_trace_life(self):
        self.assertEqual(pinpointPy.start_trace(), 1)
        self.assertEqual(pinpointPy.start_trace(), 2)
        self.assertEqual(pinpointPy.start_trace(), 3)
        self.assertEqual(pinpointPy.start_trace(), 4)
        pinpointPy.add_clue("key", "value")
        pinpointPy.add_clue("key", "value3")

        pinpointPy.add_clues("key", "values")
        pinpointPy.add_clues("key", "values")
        pinpointPy.add_clues("key", "values")

        self.assertEqual(pinpointPy.end_trace(), 3)
        self.assertEqual(pinpointPy.end_trace(), 2)
        self.assertEqual(pinpointPy.end_trace(), 1)
        self.assertEqual(pinpointPy.end_trace(), 0)