def _handleCmd(self, msg, cmdIter): try: if msg.HasField('commandEcho'): pass elif msg.HasField('commandActiveThreadCount'): self.thread_count = threading.Thread( target=self._send_thread_count, args=(msg.requestId, )) self.thread_count.start() elif msg.HasField('commandActiveThreadDump'): pass elif msg.HasField('commandActiveThreadLightDump'): lightDumpRes = PCmdActiveThreadLightDumpRes() lightDumpRes.commonResponse.responseId = msg.requestId lightDumpRes.type = 'java' lightDumpRes.subType = 'oracle' lightDumpRes.version = '1.8.105' self.cmd_sub.CommandActiveThreadLightDump(lightDumpRes) else: TCLogger.warn("msg type not support:%s", msg) except Exception as e: TCLogger.error(e)
def loopTheQueue(self): while True: body = self.mpQueue.get() if body == None: TCLogger.info("agent: %s stopping", self.agent_meta) break else: content = body.decode('utf-8') try: TCLogger.debug(content) stack = json.loads(content) except Exception as e: TCLogger.error("json is crash") return super().sendSpan(stack, body) try: pSpan = self.span_factory.makeSpan(stack) spanMesg = PSpanMessage(span=pSpan) except Exception as e: TCLogger.warn("interrupted by %s", e) continue self.span_helper.sendSpan(spanMesg)
def sendSpan(self, stack, body): try: pSpan = self.span_factory.makeSpan(stack) spanMesg = PSpanMessage(span=pSpan) except Exception as e: TCLogger.warn(" interrupted by %s",e) return False if self._sendSpan(spanMesg): return True else: if len(self.span_sender_list) < self.max_span_sender_size: TCLogger.warn("try to create a new span_sender") self._startSpanSender() else: TCLogger.warn("span_processes extend to max size") return True