All Projects → aio-libs → Aiozipkin

aio-libs / Aiozipkin

Licence: apache-2.0
Distributed tracing instrumentation for asyncio with zipkin

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Aiozipkin

tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+5.59%)
Mutual labels:  aiohttp, asyncio, async-await
Opencensus Node
A stats collection and distributed tracing framework
Stars: ✭ 249 (+54.66%)
Mutual labels:  distributed-tracing, zipkin, dapper
Sanic Ms
基于sanic的微服务基础架构
Stars: ✭ 336 (+108.7%)
Mutual labels:  asyncio, aiohttp, zipkin
Aiohttp admin
admin interface for aiohttp application http://aiohttp-admin.readthedocs.io
Stars: ✭ 207 (+28.57%)
Mutual labels:  asyncio, async-await, aiohttp
Opencensus Java
A stats collection and distributed tracing framework
Stars: ✭ 640 (+297.52%)
Mutual labels:  distributed-tracing, zipkin, dapper
Kubernetes asyncio
Python asynchronous client library for Kubernetes http://kubernetes.io/
Stars: ✭ 147 (-8.7%)
Mutual labels:  asyncio, aiohttp
Riprova
Versatile async-friendly library to retry failed operations with configurable backoff strategies
Stars: ✭ 106 (-34.16%)
Mutual labels:  asyncio, async-await
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (-30.43%)
Mutual labels:  asyncio, async-await
Aioelasticsearch
aioelasticsearch-py wrapper for asyncio
Stars: ✭ 127 (-21.12%)
Mutual labels:  asyncio, aiohttp
Ruia
Async Python 3.6+ web scraping micro-framework based on asyncio
Stars: ✭ 1,366 (+748.45%)
Mutual labels:  asyncio, aiohttp
Tgfilestream
A Telegram bot that can stream Telegram files to users over HTTP.
Stars: ✭ 113 (-29.81%)
Mutual labels:  asyncio, aiohttp
Loki
Loki: Simple, Distributed Tracing
Stars: ✭ 127 (-21.12%)
Mutual labels:  distributed-tracing, zipkin
Sockjs
SockJS Server
Stars: ✭ 105 (-34.78%)
Mutual labels:  asyncio, aiohttp
Greenletio
Asyncio integration with sync code using greenlets.
Stars: ✭ 102 (-36.65%)
Mutual labels:  asyncio, async-await
Spring Cloud Sleuth
Distributed tracing for spring cloud
Stars: ✭ 1,531 (+850.93%)
Mutual labels:  distributed-tracing, zipkin
Aioauth
Asynchronous OAuth 2.0 framework and provider for Python 3
Stars: ✭ 102 (-36.65%)
Mutual labels:  asyncio, aiohttp
Aiohttp Sse
Server-sent events support for aiohttp
Stars: ✭ 125 (-22.36%)
Mutual labels:  asyncio, aiohttp
Opencensus Go
A stats collection and distributed tracing framework
Stars: ✭ 1,895 (+1077.02%)
Mutual labels:  distributed-tracing, zipkin
Aiohttp
Asynchronous HTTP client/server framework for asyncio and Python
Stars: ✭ 11,972 (+7336.02%)
Mutual labels:  asyncio, aiohttp
Pymxget
mxget的Python实现
Stars: ✭ 136 (-15.53%)
Mutual labels:  asyncio, aiohttp

aiozipkin

.. image:: https://github.com/aio-libs/aiozipkin/workflows/CI/badge.svg :target: https://github.com/aio-libs/aiozipkin/actions?query=workflow%3ACI .. image:: https://codecov.io/gh/aio-libs/aiozipkin/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/aiozipkin .. image:: https://api.codeclimate.com/v1/badges/1ff813d5cad2d702cbf1/maintainability :target: https://codeclimate.com/github/aio-libs/aiozipkin/maintainability :alt: Maintainability .. image:: https://img.shields.io/pypi/v/aiozipkin.svg :target: https://pypi.python.org/pypi/aiozipkin .. image:: https://readthedocs.org/projects/aiozipkin/badge/?version=latest :target: http://aiozipkin.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/aio-libs/Lobby :alt: Chat on Gitter

aiozipkin is Python 3.6+ module that adds distributed tracing capabilities from asyncio_ applications with zipkin (http://zipkin.io) server instrumentation.

zipkin_ is a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in microservice architectures. It manages both the collection and lookup of this data. Zipkin’s design is based on the Google Dapper paper.

Applications are instrumented with aiozipkin report timing data to zipkin_. The Zipkin UI also presents a Dependency diagram showing how many traced requests went through each application. If you are troubleshooting latency problems or errors, you can filter or sort all traces based on the application, length of trace, annotation, or timestamp.

.. image:: https://raw.githubusercontent.com/aio-libs/aiozipkin/master/docs/zipkin_animation2.gif :alt: zipkin ui animation

Features

  • Distributed tracing capabilities to asyncio applications.
  • Support zipkin_ v2 protocol.
  • Easy to use API.
  • Explicit context handling, no thread local variables.
  • Can work with jaeger_ and stackdriver_ through zipkin compatible API.

zipkin vocabulary

Before code lets learn important zipkin_ vocabulary, for more detailed information please visit https://zipkin.io/pages/instrumenting

.. image:: https://raw.githubusercontent.com/aio-libs/aiozipkin/master/docs/zipkin_glossary.png :alt: zipkin ui glossary

  • Span represents one specific method (RPC) call
  • Annotation string data associated with a particular timestamp in span
  • Tag - key and value associated with given span
  • Trace - collection of spans, related to serving particular request

Simple example

.. code:: python

import asyncio
import aiozipkin as az


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)
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)

    # create and setup new trace
    with tracer.new_trace(sampled=True) as span:
        # give a name for the span
        span.name("Slow SQL")
        # tag with relevant information
        span.tag("span_type", "root")
        # indicate that this is client span
        span.kind(az.CLIENT)
        # make timestamp and name it with START SQL query
        span.annotate("START SQL SELECT * FROM")
        # imitate long SQL query
        await asyncio.sleep(0.1)
        # make other timestamp and name it "END SQL"
        span.annotate("END SQL")

    await tracer.close()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())

aiohttp example

aiozipkin includes aiohttp server instrumentation, for this create web.Application() as usual and install aiozipkin plugin:

.. code:: python

import aiozipkin as az

def init_app():
    host, port = "127.0.0.1", 8080
    app = web.Application()
    endpoint = az.create_endpoint("AIOHTTP_SERVER", ipv4=host, port=port)
    tracer = await az.create(zipkin_address, endpoint, sample_rate=1.0)
    az.setup(app, tracer)

That is it, plugin adds middleware that tries to fetch context from headers, and create/join new trace. Optionally on client side you can add propagation headers in order to force tracing and to see network latency between client and server.

.. code:: python

import aiozipkin as az

endpoint = az.create_endpoint("AIOHTTP_CLIENT")
tracer = await az.create(zipkin_address, endpoint)

with tracer.new_trace() as span:
    span.kind(az.CLIENT)
    headers = span.context.make_headers()
    host = "http://127.0.0.1:8080/api/v1/posts/{}".format(i)
    resp = await session.get(host, headers=headers)
    await resp.text()

Documentation

http://aiozipkin.readthedocs.io/

Installation

Installation process is simple, just::

$ pip install aiozipkin

Support of other collectors

aiozipkin can work with any other zipkin_ compatible service, currently we tested it with jaeger_ and stackdriver_.

Jaeger support

jaeger_ supports zipkin_ span format as result it is possible to use aiozipkin with jaeger_ server. You just need to specify jaeger server address and it should work out of the box. Not need to run local zipkin server. For more informations see tests and jaeger_ documentation.

.. image:: https://raw.githubusercontent.com/aio-libs/aiozipkin/master/docs/jaeger.png :alt: jaeger ui animation

Stackdriver support

Google stackdriver_ supports zipkin_ span format as result it is possible to use aiozipkin with this google_ service. In order to make this work you need to setup zipkin service locally, that will send trace to the cloud. See google_ cloud documentation how to setup make zipkin collector:

.. image:: https://raw.githubusercontent.com/aio-libs/aiozipkin/master/docs/stackdriver.png :alt: jaeger ui animation

Requirements

  • Python_ 3.6+
  • aiohttp_

.. _PEP492: https://www.python.org/dev/peps/pep-0492/ .. _Python: https://www.python.org .. _aiohttp: https://github.com/KeepSafe/aiohttp .. _asyncio: http://docs.python.org/3.5/library/asyncio.html .. _uvloop: https://github.com/MagicStack/uvloop .. _zipkin: http://zipkin.io .. _jaeger: http://jaeger.readthedocs.io/en/latest/ .. _stackdriver: https://cloud.google.com/stackdriver/ .. _google: https://cloud.google.com/trace/docs/zipkin

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].