def test_tcollector_submit(trace_server): tchannel = TChannel(name='test', known_peers=[trace_server.hostport]) trace = Trace(endpoint=Endpoint("1.0.0.1", 1111, "tcollector")) anns = [client_send()] results = yield TChannelZipkinTracer(tchannel).record([(trace, anns)]) assert results[0].ok
def test_span_host_field(): tchannel = TChannel('test') tchannel.listen() tracer = TChannelZipkinTracer(tchannel) host_span = tracer.parse_host_port() thrift_obj = thrift_formatter( trace=Trace(name='test', endpoint=Endpoint('0.0.0.1', 90, 'test1')), annotations=[annotation.client_send()], isbased64=False, span_host=host_span, ) assert thrift_obj.spanHost.ipv4 == ipv4_to_int(host_span.ipv4) assert thrift_obj.spanHost.port == host_span.port assert thrift_obj.spanHost.serviceName == host_span.service_name
def parse_host_port(self): ip, _, port = self._tchannel.hostport.rpartition(':') return Endpoint(ip, int(port), self._tchannel.name)