py-zipkin
Library for using Zipkin in Python.
What it is and what it does
py_zipkin is a Python library that integrates Zipkin distributed tracing into your applications. It provides the zipkin_span context manager and decorator to wrap code blocks or functions, automatically creating and sending trace spans to a Zipkin collector. The library handles span creation, sampling, and context propagation across service boundaries.
You supply a transport handler (HTTP, Kafka, or custom) that encodes spans in thrift format and sends them to your Zipkin backend. py_zipkin manages the trace context using thread-local storage by default, with support for explicit Stack and SpanStorage instances in multithreaded or async environments. It also offers utilities to add binary annotations, mark remote service calls, and generate HTTP headers for propagating trace context to downstream services.
Use it for:
- Instrument a microservice to trace requests end-to-end across multiple services by propagating trace headers.
- Add sampling-based tracing to high-throughput services to monitor latency and service dependencies without capturing every request.
- Record custom span metadata (binary annotations) during request processing to track business logic or debug information.
- Mark calls to non-instrumented external services with remote endpoint annotations so the trace graph shows the full call chain.
- Implement firehose mode to capture 100% of spans for a subset of traffic and route them to a separate retention backend.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
py_zipkin provides context managers and decorators to instrument Python applications with Zipkin distributed tracing, sending span data to a central collector via pluggable transport handlers.
Yes, if you are already running Zipkin and need Python instrumentation. The library is actively maintained, has low install friction, and provides a clean API for both simple and complex tracing scenarios. The Apache v2 license poses no restrictions. Consider it essential for microservice observability in a Zipkin-based infrastructure; not relevant if you use a different tracing backend (Jaeger, DataDog, etc.).
Install
py-zipkin on PyPI
pip
pip install py-zipkinuv
uv add py-zipkinpoetry
poetry add py-zipkinInstalling py-zipkin
Before you install
Low install friction with a single runtime dependency (typing-extensions). Maintenance status is active with recent commits as of 2026-04-02, though the latest release was 2023-03-24.
License in practice
Licensed under Apache v2 (permissive). No restrictions on commercial or private use; modifications and redistribution are allowed under Apache terms.
Quickstart
pip install py_zipkin
from py_zipkin.zipkin import zipkin_span
from py_zipkin.transport import BaseTransportHandler
class MyTransport(BaseTransportHandler):
def get_max_payload_bytes(self):
return None
def send(self, encoded_span):
pass # Send to Zipkin collector
with zipkin_span(
service_name='my_service',
span_name='my_operation',
transport_handler=MyTransport(),
port=9411,
sample_rate=0.05,
):
# Your code here
pass
Requires a transport handler implementation to send spans; without one, spans are created but not exported. Zipkin collector endpoint must be accessible from your application.
Verify before relying
- Whether the package supports async/await patterns beyond the experimental multithreading guidance in the documentation.
- Current compatibility with Python versions beyond 3.7 and 3.8 (classifiers list only those two, but requires_python states >=3.7).
- Whether firehose mode overhead is acceptable for production workloads at scale.
Package facts
| License | Copyright Yelp 2019 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 1,239 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 484,185/month — #6,404 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: py_zipkin-1.2.8-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
opentelemetry-exporter-zipkin-proto-httpExports OpenTelemetry tracing data to Zipkin…
permissive · top 15,000 on PyPI
opentelemetry-exporter-zipkinInstalls a convenience bundle of OpenTelemetry…
permissive · top 15,000 on PyPI
opentelemetry-exporter-zipkin-jsonExports OpenTelemetry tracing data to Zipkin…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-aiokafkaAdds distributed tracing instrumentation to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-kafka-pythonAdds distributed tracing instrumentation to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-confluent-kafkaAdds distributed tracing to confluent-kafka…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-httpxAdds distributed tracing to HTTP requests made…
permissive · top 1,000 on PyPI
jaeger-clientJaeger-client instruments Python applications…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-ollamaAdds distributed tracing to Ollama Python…
permissive · top 5,000 on PyPI
opentracingProvides the OpenTracing API for Python,…
permissive · top 5,000 on PyPI