Example #1
0
    def test_client_send_annotation(self, mock_annotation):
        agent = TracingAgent(self.agent, self.trace)

        agent.request('GET', 'https://google.com')

        mock_annotation.client_send.assert_called_with()
        self.trace.child.return_value.record.assert_any_call(
            mock_annotation.client_send.return_value)
Example #2
0
    def test_uri_annotation(self, mock_annotation):
        agent = TracingAgent(self.agent, self.trace)

        agent.request('GET', 'https://google.com')

        mock_annotation.string.assert_any_call(
            'http.uri', 'https://google.com')

        self.trace.child.return_value.record.assert_any_call(
            mock_annotation.string.return_value)
Example #3
0
    def test_no_parent(self, mock_trace):
        mock_trace.return_value.trace_id = 1
        mock_trace.return_value.span_id = 2
        mock_trace.return_value.parent_span_id = 3

        agent = TracingAgent(self.agent)
        agent.request('GET', 'https://google.com')

        # Constructs a new trace object.
        mock_trace.assert_called_with('GET')
Example #4
0
    def test_delgates_to_agent(self):
        agent = TracingAgent(self.agent, self.trace)

        agent.request('GET', 'https://google.com')

        self.agent.request.assert_called_with(
            'GET', 'https://google.com',
            Headers({'X-B3-TraceId': ['0000000000000001'],
                     'X-B3-SpanId': ['0000000000000003'],
                     'X-B3-ParentSpanId': ['0000000000000002']}),
            None)
    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        a = TracingAgent(Agent(reactor))
        d = a.request('GET', 'http://google.com')

        # Print the response code when receive the response.
        d.addCallback(lambda r: print("Received {0} response.".format(r.code)))

        # stop the reactor.
        d.addBoth(lambda _: reactor.callLater(1, reactor.stop))
Example #6
0
    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        a = TracingAgent(Agent(reactor))
        d = a.request('GET', 'http://localhost:8080/README.rst')

        # Print the response code when receive the response.
        d.addCallback(lambda r: print("Received {0} response.".format(r.code)))

        # stop the reactor.
        d.addBoth(lambda _: reactor.callLater(1, reactor.stop))
    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        # to used with zipkin ui, endpoint must be set
        endpoint = Endpoint(ipv4='127.0.0.1', port=1582, service_name="tryfer-example")
        a = TracingAgent(Agent(reactor), endpoint=endpoint)
        d = a.request('GET', 'http://google.com')

        # Print the response code when receive the response.
        d.addCallback(lambda r: print("Received {0} response.".format(r.code)))

        # stop the reactor.
        d.addBoth(lambda _: reactor.callLater(1, reactor.stop))
Example #8
0
    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        # to used with zipkin ui, endpoint must be set
        endpoint = Endpoint(ipv4='127.0.0.1',
                            port=1582,
                            service_name="tryfer-example")
        a = TracingAgent(Agent(reactor), endpoint=endpoint)
        d = a.request('GET', 'http://google.com')

        # Print the response code when receive the response.
        d.addCallback(lambda r: print("Received {0} response.".format(r.code)))

        # stop the reactor.
        d.addBoth(lambda _: reactor.callLater(1, reactor.stop))
Example #9
0
    def test_with_parent(self):
        agent = TracingAgent(self.agent, self.trace)

        agent.request('GET', 'https://google.com')

        self.trace.child.assert_called_with('GET')
Example #10
0
    def test_sets_endpoint(self, mock_trace):
        endpoint = Endpoint('127.0.0.1', 0, 'client')
        agent = TracingAgent(self.agent, endpoint=endpoint)

        agent.request('GET', 'https://google.com')
        mock_trace.return_value.set_endpoint.assert_called_with(endpoint)