Python tracing libraries

Updated Nov 2026

Python tracing libraries record spans that show how a request moves through an application and the services it calls. An SDK creates each span with timing and context before an exporter sends it to a backend such as an OpenTelemetry collector. These libraries let developers find slow calls and failures in web services and AI agent runs.

Popularity

opentelemetry-sdk has the most monthly downloads in this comparison, at 342.4M.

LibraryMonthly downloadsStarsLast releaseLicense
opentelemetry-sdk
342.4M
2.7KOct 2026Apache-2.0
Sentry SDK
157.0M
2.2KNov 2026MIT
LangSmith
94.9M
1.1KNov 2026MIT
ddtrace
48.7M
655Nov 2026BSD-3-Clause
Langfuse
31.7M
516Nov 2026MIT
Logfire
19.0M
4.6KNov 2026MIT
MLflow Tracing
17.5M
28.9KNov 2026Apache-2.0
AWS X-Ray SDK
17.1M
340Oct 2026Apache-2.0
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

opentelemetry-sdk

Creates spans and exports Python application telemetry through configurable processors and exporters.

Downloads / mo
342.4M
Stars
2.7K
Last release
1.45.2
License
Apache-2.0

Strengths

  • Configurable span processing. Choose the span processor and exporter for the tracing pipeline.
  • Exports through standard OTLP. Send traces to an OTLP-compatible collector or backend.

Limitations

  • Auto instrumentation needs extra packages. Install a distro and the instrumentors for the frameworks the application uses.
  • OTLP exporters install separately. Add the HTTP or gRPC exporter package before configuring its endpoint.

Quickstart

From instrumentation.md
$ pip install opentelemetry-sdk
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
tracer = provider.get_tracer(__name__)
with tracer.start_as_current_span('example'):
    pass

opentelemetry-sdk examples

From open-source projects on GitHub

Captures application errors and tracing spans with Python framework integrations.

Downloads / mo
157.0M
Stars
2.2K
Last release
2.75.0
License
MIT

Strengths

  • Instruments supported frameworks automatically. Supported HTTP and database operations become spans through enabled integrations.
  • Adds custom nested spans. Wrap application operations in spans inside an active transaction.

Limitations

  • Custom spans need a transaction. Create a transaction when the framework integration does not create one.
  • Tracing needs sampling configuration. Set traces_sample_rate for the share of traces sent to Sentry.
$ pip install sentry-sdk
import os
import sentry_sdk
sentry_sdk.init(dsn=os.environ['SENTRY_DSN'], traces_sample_rate=1.0)
with sentry_sdk.start_transaction(op='task', name='example'):
    pass
sentry_sdk.flush()

Sentry SDK examples

From open-source projects on GitHub

Connects to the LangSmith observability and evaluation platform.

Downloads / mo
94.9M
Stars
1.1K
Last release
0.15.0
License
MIT

Quickstart

From README.md
$ pip install langsmith
from langsmith import traceable

@traceable
def example(text: str) -> str:
    return text.upper()

example('hello')

LangSmith examples

From open-source projects on GitHub

Adds manual and automatic tracing to Python applications for Datadog.

Downloads / mo
48.7M
Stars
655
Last release
4.17.0
License
BSD-3-Clause

Strengths

  • Wraps selected code blocks. Use the tracer context manager around an operation that needs a span.
  • Propagates context across async tasks. New tasks inherit the active trace context by default.

Limitations

  • Spans belong to their execution. Pass and activate the context when continuing a trace across execution boundaries.
  • Automatic tracing must start early. Import ddtrace.auto before application imports when using that initialization route.

Quickstart

From advanced_usage.html
$ pip install ddtrace
from ddtrace.trace import tracer
with tracer.trace('example'):
    pass
tracer.shutdown()

Traces LLM applications, with datasets, experiments, evaluation, and prompt management.

Downloads / mo
31.7M
Stars
516
Last release
5.2.0
License
MIT

Quickstart

From README.md
$ pip install langfuse
from langfuse import get_client
langfuse = get_client()
with langfuse.start_as_current_observation(as_type='span', name='example'):
    pass
langfuse.flush()

Langfuse examples

From open-source projects on GitHub

Creates structured logs and spans using OpenTelemetry and configurable telemetry backends.

Downloads / mo
19.0M
Stars
4.6K
Last release
5.6.0
License
MIT

Strengths

  • Exports to alternative backends. Configure an OTLP endpoint for a compatible telemetry backend.
  • Traces selected modules automatically. Install auto tracing before importing the application modules to trace.

Limitations

  • Cloud delivery starts enabled. Set send_to_logfire=False when sending only to another backend.
  • Auto tracing precedes module imports. Install auto tracing before importing the modules it should instrument.

Quickstart

From logfire.md
$ pip install logfire
import logfire
logfire.configure(send_to_logfire=False)
with logfire.span('example'):
    pass

Logfire examples

From open-source projects on GitHub
async def main():
    async with AsyncClient() as client:
        logfire.instrument_httpx(client, capture_all=True)
        deps = Deps(client=client)
        result = await weather_agent.run(
            'What is the weather like in London and in Wiltshire?', deps=deps
        )
        print('Response:', result.output)

Instruments code for MLflow tracing with a minimal set of dependencies.

Downloads / mo
17.5M
Stars
28.9K
Last release
3.18.0
License
Apache-2.0

Quickstart

From README.md
$ pip install mlflow-tracing opentelemetry-exporter-otlp
import os
os.environ['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] = 'http://localhost:4318/v1/traces'
os.environ['OTEL_EXPORTER_OTLP_TRACES_PROTOCOL'] = 'http/protobuf'
import mlflow
with mlflow.start_span(name='example'):
    pass

MLflow Tracing examples

From open-source projects on GitHub

Records application data and sends it to AWS X-Ray.

Downloads / mo
17.1M
Stars
340
Last release
2.16.0
License
Apache-2.0

Quickstart

From recorder.py
$ pip install aws-xray-sdk
from aws_xray_sdk.core import xray_recorder
xray_recorder.configure(service='example')
with xray_recorder.in_segment('example'):
    pass

AWS X-Ray SDK examples

From open-source projects on GitHub

FAQ

opentelemetry-sdk suits tracing exported through standard OTLP to compatible backends. Sentry SDK suits applications that track errors and spans together. Langfuse and LangSmith suit tracing LLM applications and agents.

Langfuse is a Python SDK for LLM observability and tracing, with datasets, experiments, evaluation, and prompt management.

LangSmith is a client library that connects to the LangSmith observability and evaluation platform.

Logfire creates structured logs and spans using OpenTelemetry. It sends data to its cloud by default. Its configuration can point to another OTLP backend instead.

opentelemetry-sdk creates spans and exports them through OTLP to compatible collectors and backends. Sentry SDK captures errors and spans for Sentry, with automatic instrumentation for supported frameworks.

ddtrace adds manual and automatic tracing to Python applications for Datadog. Automatic tracing must start early in the process.

For coding agents

Found your tracing library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official