How to use the aiozipkin.get_tracer 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
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 / queue / frontend.py View on Github external
async def index(request):
    span = az.request_span(request)
    tracer = az.get_tracer(request.app)
    session = request.app['session']

    with tracer.new_child(span.context) as span_producer:
        span_producer.kind(az.PRODUCER)
        span_producer.name('produce event click')
        span_producer.remote_endpoint('broker', ipv4='127.0.0.1', port=9011)

        headers = span_producer.context.make_headers()
        message = {'payload': 'click', 'headers': headers}
        resp = await session.post(backend_service, json=message)
        resp = await resp.text()
        assert resp == 'ok'

    await asyncio.sleep(0.01)
    return web.Response(text=page, content_type='text/html')
github aio-libs / aiozipkin / examples / queue / backend.py View on Github external
async def handler(request):
    message = await request.json()
    tracer = az.get_tracer(request.app)
    for _ in range(5):
        asyncio.ensure_future(
            aiojobs.aiohttp.spawn(request, consume_message(message, tracer))
        )

    return web.Response(text='ok')
github aio-libs / aiozipkin / examples / aiohttp_example.py View on Github external
async def handle(request):
    tracer = az.get_tracer(request.app)
    span = az.request_span(request)

    with tracer.new_child(span.context) as child_span:
        child_span.name('mysql:select')
        # call to external service like https://python.org
        # or database query
        await asyncio.sleep(0.01)

    text = """
    
    
        <title>aiohttp simple example</title>
    
    
        <h3>This page was traced by aiozipkin</h3>
        <p><a href="http://127.0.0.1:9001/status">Go to not traced page</a></p>