Пример #1
0
 def enable_tracing(self):
     # enabled tracing:
     #   * middleware
     #   * templates
     trace_app(self.app, self.tracer)
     patch()
     Pin.override(aiohttp_jinja2, tracer=self.tracer)
Пример #2
0
 def enable_tracing(self):
     # enabled tracing:
     #   * middleware
     #   * templates
     trace_app(self.app, self.tracer)
     patch()
     Pin.override(aiohttp_jinja2, tracer=self.tracer)
Пример #3
0
 def test_middleware_applied_twice(self):
     # it should be idempotent
     app = setup_app(self.app.loop)
     # the middleware is not present
     eq_(1, len(app.middlewares))
     eq_(noop_middleware, app.middlewares[0])
     # the middleware is present (with the noop middleware)
     trace_app(app, self.tracer)
     eq_(2, len(app.middlewares))
     # applying the middleware twice doesn't add it again
     trace_app(app, self.tracer)
     eq_(2, len(app.middlewares))
     # and the middleware is always the first
     eq_(trace_middleware, app.middlewares[0])
     eq_(noop_middleware, app.middlewares[1])
Пример #4
0
 def test_middleware_applied_twice(self):
     # it should be idempotent
     app = setup_app(self.app.loop)
     # the middleware is not present
     assert 1 == len(app.middlewares)
     assert noop_middleware == app.middlewares[0]
     # the middleware is present (with the noop middleware)
     trace_app(app, self.tracer)
     assert 2 == len(app.middlewares)
     # applying the middleware twice doesn't add it again
     trace_app(app, self.tracer)
     assert 2 == len(app.middlewares)
     # and the middleware is always the first
     assert trace_middleware == app.middlewares[0]
     assert noop_middleware == app.middlewares[1]
Пример #5
0
 def test_middleware_applied_twice(self):
     # it should be idempotent
     app = setup_app(self.app.loop)
     # the middleware is not present
     eq_(1, len(app.middlewares))
     eq_(noop_middleware, app.middlewares[0])
     # the middleware is present (with the noop middleware)
     trace_app(app, self.tracer)
     eq_(2, len(app.middlewares))
     # applying the middleware twice doesn't add it again
     trace_app(app, self.tracer)
     eq_(2, len(app.middlewares))
     # and the middleware is always the first
     eq_(trace_middleware, app.middlewares[0])
     eq_(noop_middleware, app.middlewares[1])
Пример #6
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"
Пример #7
0
 def enable_tracing(self):
     trace_app(self.app, self.tracer)
Пример #8
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())
Пример #9
0
 async def app_tracer(tracer, loop):
     app = setup_app()
     trace_app(app, tracer)
     return app, tracer
Пример #10
0
 def enable_tracing(self):
     trace_app(self.app, self.tracer)