コード例 #1
0
    def handle(self, client):
        itrans = self.inputTransportFactory.getTransport(client)
        otrans = self.outputTransportFactory.getTransport(client)
        iprot = self.inputProtocolFactory.getProtocol(itrans)
        oprot = self.outputProtocolFactory.getProtocol(otrans)

        try:
            while True:
                start_time = time.time() * 1000000
                self.processor.process(iprot, oprot)
                end_time = time.time() * 1000000

                tctx = thread_storage.getTraceContext()
                if tctx.isEnabled():
                    name = span_util.createSpanName(self.service_name, \
                                                    tctx.getRPCMethod())
                    span = span_util.createSpan(name, tctx.getTraceID(), \
                                                tctx.getSpanID(), tctx.getSpanParentID())
                    span.server_host = self.server_ip
                    span.events = [span_util.createEvent(start_time, EventType.SERVER_RECV), \
                                   span_util.createEvent(end_time, EventType.SERVER_SEND)]

                    if self.debug:
                        logging.debug(span)

                    tctx.addSpan(span)
                    self.logSpans(tctx)

        except TTransport.TTransportException, tx:
            pass
コード例 #2
0
    def logSpan(self, rpc_method, start_time, end_time):
        trace_id = self.trace_context.getTraceID()
        span_id = self.trace_context.getSpanID()
        span_parent_id = self.trace_context.getSpanParentID()
        name = span_util.createSpanName(self.service_name, rpc_method)
        span = span_util.createSpan(name=name,
                                     trace_id=trace_id,
                                     span_id=span_id,
                                     span_parent_id=span_parent_id)

        span.client_host = self.client_ip
        span.events = [span_util.createEvent(long(start_time), EventType.CLIENT_RECV), \
                       span_util.createEvent(long(end_time), EventType.CLIENT_SEND)]
        self.trace_context.addSpan(span)