How to use the aiozipkin.create_endpoint 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_jaeger.py View on Github external
async def test_basic(jaeger_url, jaeger_api_url, client, loop):
    endpoint = az.create_endpoint('simple_service', ipv4='127.0.0.1', port=80)
    interval = 50
    tracer = await az.create(jaeger_url, endpoint, sample_rate=1.0,
                             send_interval=interval, loop=loop)

    with tracer.new_trace(sampled=True) as span:
        span.name('jaeger_span')
        span.tag('span_type', 'root')
        span.kind(az.CLIENT)
        span.annotate('SELECT * FROM')
        await asyncio.sleep(0.1)
        span.annotate('start end sql')

    # close forced sending data to server regardless of send interval
    await tracer.close()
    trace_id = span.context.trace_id[-16:]
    url = URL(jaeger_api_url) / 'api' / 'traces' / trace_id
github aio-libs / aiozipkin / tests / test_zipkin.py View on Github external
async def test_basic(zipkin_url, client, loop):
    endpoint = az.create_endpoint('simple_service', ipv4='127.0.0.1', port=80)
    interval = 50
    tracer = await az.create(zipkin_url, endpoint, sample_rate=1.0,
                             send_interval=interval, loop=loop)

    with tracer.new_trace(sampled=True) as span:
        span.name('root_span')
        span.tag('span_type', 'root')
        span.kind(az.CLIENT)
        span.annotate('SELECT * FROM')
        await asyncio.sleep(0.1)
        span.annotate('start end sql')

    # close forced sending data to server regardless of send interval
    await tracer.close()

    trace_id = span.context.trace_id
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_c.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_c', 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 / minimal.py View on Github external
async def run():
    # setup zipkin client
    zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
    # address and name of current machine for better trace information
    endpoint = az.create_endpoint('minimal_example', ipv4='127.0.0.1')

    # creates tracer object that tracer all calls if you want sample
    # only 50% just set sample_rate=0.5
    async with az.create(zipkin_address, endpoint, sample_rate=1.0) as tracer:
        # create and setup new trace
        with tracer.new_trace() as span:
            # here we just add name to the span for better search in UI
            span.name('root::span')
            # imitate long SQL query
            await asyncio.sleep(0.1)

    print('Done, check zipkin UI')
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 / 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 / simple.py View on Github external
async def run():
    # setup zipkin client
    zipkin_address = 'http://127.0.0.1:9411/api/v2/spans'
    endpoint = az.create_endpoint(
        'simple_service', ipv4='127.0.0.1', port=8080
    )

    # creates tracer object that traces all calls, if you want sample
    # only 50% just set sample_rate=0.5
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)

    # create and setup new trace
    with tracer.new_trace(sampled=True) as span:
        span.name('root_span')
        span.tag('span_type', 'root')
        span.kind(az.CLIENT)
        span.annotate('SELECT * FROM')
        # imitate long SQL query
        await asyncio.sleep(0.1)
        span.annotate('start end sql')
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
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