예제 #1
0
    def test_agent_client_split(self):
        agent_client = jaeger_exporter.AgentClientUDP(
            host_name="localhost",
            port=6354,
            max_packet_size=250,
            split_oversized_batches=True,
        )

        translator = jaeger_exporter.Translate((self._test_span, ))
        small_batch = jaeger.Batch(
            # pylint: disable=protected-access
            spans=translator._translate(ThriftTranslator()),
            process=jaeger.Process(serviceName="xxx"),
        )

        with unittest.mock.patch("socket.socket.sendto",
                                 autospec=True) as fake_sendto:
            agent_client.emit(small_batch)
            self.assertEqual(fake_sendto.call_count, 1)

        translator = jaeger_exporter.Translate([self._test_span] * 2)
        large_batch = jaeger.Batch(
            # pylint: disable=protected-access
            spans=translator._translate(ThriftTranslator()),
            process=jaeger.Process(serviceName="xxx"),
        )

        with unittest.mock.patch("socket.socket.sendto",
                                 autospec=True) as fake_sendto:
            agent_client.emit(large_batch)
            self.assertEqual(fake_sendto.call_count, 2)
예제 #2
0
    def test_agent_client(self):
        agent_client = jaeger_exporter.AgentClientUDP(host_name="localhost",
                                                      port=6354)

        translate = Translate([self._test_span])
        # pylint: disable=protected-access
        spans = translate._translate(ThriftTranslator())

        batch = jaeger.Batch(
            spans=spans,
            process=jaeger.Process(serviceName="xxx"),
        )

        agent_client.emit(batch)