Tracing using Zipkin Middleware¶
In microservices architecture, to troubleshoot problems, it is convenient to trace all sub requests and more using a tracer such as Zipkin or Jaeger.
In blacksmith, the zipkin middleware can be added to trace all the sub requests.
Example using starlette_zipkin:
from starlette_zipkin import trace
from blacksmith import (
AbstractTraceContext,
AsyncClientFactory,
AsyncConsulDiscovery,
AsyncZipkinMiddleware,
)
# AbstractTraceContext is an abtract base classe,
# register the class that already implement it.
AbstractTraceContext.register(trace)
sd = AsyncConsulDiscovery()
cli = AsyncClientFactory(sd)
cli.add_middleware(AsyncZipkinMiddleware(trace))
Full example of the zipkin middleware¶
You will find an example using prometheus in the examples directory: