How to use the aiozipkin.setup function in aiozipkin

To help you get started, we’ve selected a few aiozipkin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aiozipkin / tests / test_aiohttp_helpers.py View on Github external
async def test_middleware_cleanup_app(tracer):
    fut = asyncio.Future()
    fut.set_result(None)
    with patch.object(tracer, 'close', return_value=fut) as mocked_close:
        app = web.Application()
        az.setup(app, tracer)
        app.freeze()
        await app.cleanup()
        assert mocked_close.call_count == 1
github aio-libs / aiozipkin / tests / test_aiohttp_helpers.py View on Github external
async def test_middleware_with_invalid_ip(tracer, version, address):
    app = web.Application()
    az.setup(app, tracer)

    # Fake transport
    transp = Mock()
    transp.get_extra_info.return_value = (address, '0')

    async def handler(request):
        return web.Response(body=b'data')

    req = make_mocked_request('GET', '/',
                              headers={'token': 'x'},
                              transport=transp, app=app)

    middleware = middleware_maker()
    with patch('aiozipkin.span.Span.remote_endpoint') as mocked_remote_ep:
        await middleware(req, handler)
        assert mocked_remote_ep.call_count == 0
github aio-libs / aiozipkin / tests / test_aiohttp_helpers.py View on Github external
def test_basic_setup(tracer):
    app = web.Application()
    az.setup(app, tracer)

    fetched_tracer = az.get_tracer(app)
    assert len(app.middlewares) == 1
    assert tracer is fetched_tracer
github aio-libs / aiozipkin / examples / microservices / service_b.py View on Github external
async def make_app():
    app = web.Application()
    app.router.add_get('/api/v1/data', handler)

    zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
    endpoint = az.create_endpoint('service_b', ipv4=host, port=port)
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
    az.setup(app, tracer)

    trace_config = az.make_trace_config(tracer)

    session = aiohttp.ClientSession(trace_configs=[trace_config])
    app['session'] = session

    async def close_session(app):
        await app['session'].close()

    app.on_cleanup.append(close_session)
    return app
github aio-libs / aiozipkin / examples / queue / frontend.py View on Github external
async def make_app(host, port):
    app = web.Application()
    app.router.add_get('/', index)

    session = aiohttp.ClientSession()
    app['session'] = session

    zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
    endpoint = az.create_endpoint('frontend', ipv4=host, port=port)
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
    az.setup(app, tracer)
    return app
github aio-libs / aiozipkin / examples / aiohttp_example.py View on Github external
async def make_app(host, port):
    app = web.Application()
    app.router.add_get('/', handle)
    # here we aquire reference to route, so later we can command
    # aiozipkin not to trace it
    skip_route = app.router.add_get('/status', not_traced_handle)

    endpoint = az.create_endpoint('aiohttp_server', ipv4=host, port=port)

    zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
    az.setup(app, tracer, skip_routes=[skip_route])
    return app
github aio-libs / aiozipkin / examples / microservices / service_d.py View on Github external
async def make_app():
    app = web.Application()
    app.router.add_get('/api/v1/data', handler)

    zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
    endpoint = az.create_endpoint('service_d', ipv4=host, port=port)
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
    az.setup(app, tracer)
    return app
github aio-libs / aiozipkin / examples / queue / backend.py View on Github external
async def make_app(host, port):
    app = web.Application()
    app.router.add_post('/consume', handler)
    aiojobs.aiohttp.setup(app)

    zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
    endpoint = az.create_endpoint('backend_broker', ipv4=host, port=port)
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
    az.setup(app, tracer)
    return app