OpenTelemetry Python

Active
GitHub Python Apache-2.0

Description

CNCF-hosted official Python implementation of OpenTelemetry, providing standardized APIs and SDKs for telemetry data collection (traces, metrics, logs) — the de facto standard for cloud-native application observability.

Key Features

  • Unified telemetry API — Standardized interfaces for traces, metrics, and logs in one cohesive system
  • Flexible SDK configuration — Sampling strategies, batch export, resource attributes, and advanced settings
  • Rich exporter ecosystem — Built-in exporters for Jaeger, Prometheus, Zipkin, OTLP and more
  • Automatic instrumentation — Auto-instrumentation for Flask, Django, requests, SQLAlchemy and other popular libraries
  • OpenTelemetry specification — Fully compliant with OTEL spec, seamless multi-language ecosystem interoperability
  • OpenSSF best practices — Regular security audits and dependency supply-chain assurance

Use Cases

💡 Distributed tracing: Trace full request lifecycle in microservices to identify performance bottlenecks
💡 Metrics monitoring & alerting: Collect business and system metrics, integrate with Prometheus/Grafana dashboards
💡 Log correlation analysis: Correlate logs with trace IDs for full-stack troubleshooting
💡 AI agent observability: Add call-chain monitoring for LLM applications and agent frameworks

Quick Start

# Install core packages
pip install opentelemetry-api opentelemetry-sdk

# Basic usage
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor

provider = TracerProvider()
processor = SimpleSpanProcessor(ConsoleSpanExporter())
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)

# Auto-instrumentation
pip install opentelemetry-instrumentation-flask opentelemetry-instrumentation-requests

Related Projects

Related Articles