Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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
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
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')
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
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
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')
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
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