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