Exemplo n.º 1
0
    def setUp(self):
        super(BaseUrllib3TestCase, self).setUp()

        patch()
        self.http = urllib3.PoolManager()
        Pin.override(urllib3.connectionpool.HTTPConnectionPool,
                     tracer=self.tracer)
Exemplo n.º 2
0
 def enable_tracing(self):
     # enabled tracing:
     #   * middleware
     #   * templates
     trace_app(self.app, self.tracer)
     patch()
     Pin.override(aiohttp_jinja2, tracer=self.tracer)
Exemplo n.º 3
0
 def enable_tracing(self):
     # enabled tracing:
     #   * middleware
     #   * templates
     trace_app(self.app, self.tracer)
     patch()
     Pin.override(aiohttp_jinja2, tracer=self.tracer)
Exemplo n.º 4
0
 def test_user_specified_service(self):
     """
     When a service name is specified by the user
         The algoliasearch integration should use it as the service name
     """
     patch_all()
     Pin.override(self.index, tracer=self.tracer)
     self.perform_search("test search")
     spans = self.get_spans()
     self.reset()
     assert spans, spans
     assert len(spans) == 1
     assert spans[0].service == "mysvc"
     unpatch()
Exemplo n.º 5
0
    def test_patch_all_auto_enable(self):
        patch_all()
        Pin.override(self.index, tracer=self.tracer)
        self.perform_search('test search')

        spans = self.get_spans()
        self.reset()
        assert spans, spans
        assert len(spans) == 1

        unpatch()

        self.perform_search('test search')

        spans = self.get_spans()
        assert not spans, spans
Exemplo n.º 6
0
def test_httpx_service_name(tracer, test_spans):
    """
    When using split_by_domain
        We set the span service name as a text type and not binary
    """
    client = httpx.Client()
    Pin.override(client, tracer=tracer)

    with override_config("httpx", {"split_by_domain": True}):
        resp = client.get(get_url("/status/200"))
    assert resp.status_code == 200

    traces = test_spans.pop_traces()
    assert len(traces) == 1

    spans = traces[0]
    assert len(spans) == 1
    assert isinstance(spans[0].service, six.text_type)
Exemplo n.º 7
0
async def test_user_specified_service(tracer, aiohttp_client, loop):
    """
    When a service name is specified by the user
        The aiohttp integration should use it as the service name
    """
    unpatch()
    with override_global_config(dict(service="mysvc")):
        patch()
        app = setup_app()
        trace_app(app, tracer)
        Pin.override(aiohttp_jinja2, tracer=tracer)
        client = await aiohttp_client(app)
        request = await client.request("GET", "/template/")
        await request.text()
        traces = tracer.pop_traces()
        assert 1 == len(traces)
        assert 2 == len(traces[0])

        request_span = traces[0][0]
        assert request_span.service == "mysvc"

        template_span = traces[0][1]
        assert template_span.service == "mysvc"
Exemplo n.º 8
0
async def test_configure_service_name_pin(tracer, test_spans):
    """
    When setting service name via a Pin
        We use the value from the Pin
    """
    url = get_url("/status/200")

    def assert_spans(test_spans, service):
        test_spans.assert_trace_count(1)
        test_spans.assert_span_count(1)
        assert test_spans.spans[0].service == service
        test_spans.reset()

    # override the tracer on the default sync client
    # DEV: `httpx.get` will call `with Client() as client: client.get()`
    Pin.override(httpx.Client, tracer=tracer)

    # sync client
    client = httpx.Client()
    Pin.override(client, service="sync-client", tracer=tracer)

    # async client
    async_client = httpx.AsyncClient()
    Pin.override(async_client, service="async-client", tracer=tracer)

    resp = httpx.get(url)
    assert resp.status_code == 200
    assert_spans(test_spans, service=None)

    resp = client.get(url)
    assert resp.status_code == 200
    assert_spans(test_spans, service="sync-client")

    async with httpx.AsyncClient() as client:
        resp = await async_client.get(url)
        assert resp.status_code == 200
    assert_spans(test_spans, service="async-client")
Exemplo n.º 9
0
    def setUp(self):
        super(HTTPLibBaseMixin, self).setUp()

        patch()
        Pin.override(httplib, tracer=self.tracer)
Exemplo n.º 10
0
 def get_https_connection(self, *args, **kwargs):
     conn = httplib.HTTPSConnection(*args, **kwargs)
     Pin.override(conn, tracer=self.tracer)
     return conn
Exemplo n.º 11
0
 def enable_tracing(self):
     patch()
     Pin.override(aiohttp_jinja2, tracer=self.tracer)
Exemplo n.º 12
0
 def setUp(self):
     patch()
     self.tracer = get_dummy_tracer()
     Pin.override(httplib, tracer=self.tracer)
Exemplo n.º 13
0
 def enable_tracing(self):
     # aiohttp TestCase with the wrong context provider
     trace_app(self.app, self.tracer)
     patch()
     Pin.override(aiohttp_jinja2, tracer=self.tracer)
     self.tracer.configure(context_provider=DefaultContextProvider())
Exemplo n.º 14
0
 def enable_tracing(self):
     patch()
     Pin.override(aiohttp_jinja2, tracer=self.tracer)
Exemplo n.º 15
0
 async def untraced_app_tracer(tracer, loop):
     patch()
     app = setup_app()
     Pin.override(aiohttp_jinja2, tracer=tracer)
     return app, tracer
Exemplo n.º 16
0
 def get_https_connection(self, *args, **kwargs):
     conn = httplib.HTTPSConnection(*args, **kwargs)
     Pin.override(conn, tracer=self.tracer)
     return conn
Exemplo n.º 17
0
 def patch_algoliasearch(self):
     patch()
     Pin.override(self.index, tracer=self.tracer)
Exemplo n.º 18
0
 async def patched_app_tracer(app_tracer):
     patch()
     app, tracer = app_tracer
     Pin.override(aiohttp_jinja2, tracer=tracer)
     return app, tracer
Exemplo n.º 19
0
 def setUp(self):
     patch()
     self.tracer = get_dummy_tracer()
     Pin.override(httplib, tracer=self.tracer)