
- The OpenTelemetry agent applies monkey patches to supported libraries at runtime.
- Patches wrap or modify library functions so requests, DB queries, and messaging calls generate spans and metrics automatically.
- If your app uses supported libraries, traces and metrics appear with no manual SDK calls.

Installation
Install the OpenTelemetry distro and supporting packages, then let the bootstrap tool detect and install instrumentations for the dependencies in your environment.Running the agent
Start your app with theopentelemetry-instrument wrapper to enable auto-instrumentation. Example that exports traces and metrics to the console (for development) and to an OTLP endpoint (typical for sending to an OTel Collector):
For production, send telemetry to an OTLP Collector or backend instead of the console. Use the console exporter only for quick testing or troubleshooting.
Configuration via environment variables
Environment variables are commonly used in containers and CI/CD pipelines. They provide the same control as CLI flags and are typically easier to manage in deployments. Example environment variables:
Supported libraries (auto-instrumentation)
OpenTelemetry Python provides many built-in instrumentations and community-contributed packages. Typical coverage includes web frameworks, HTTP clients, database libraries, and messaging systems.
This coverage gives immediate visibility across web requests, outbound HTTP calls, DB queries, and messaging layers.

Debugging automatic instrumentation
If a library isn’t being instrumented or spans/attributes are missing, enable debug logging to see detailed messages about what instrumentations are applied and any errors:Repository & documentation
Key resources:- Instrumentation libraries and contrib repo: https://github.com/open-telemetry/opentelemetry-python-contrib
- Auto-instrumentation CLI docs: https://opentelemetry.io/docs/instrumentation/python/auto-instrumentation/
- PyPI instrumentation package: https://pypi.org/project/opentelemetry-instrumentation/
- SDK configuration docs: https://opentelemetry.io/docs/reference/specification/sdk-configuration/

Python vs Java (brief comparison)
Summary
OpenTelemetry Python zero-code instrumentation (auto-instrumentation) provides immediate observability for many common libraries without modifying application source code. Workflow summary:- Install distro + exporters + instrumentation packages.
- Run
opentelemetry-bootstrap -a installto add relevant instrumentations. - Start your app with
opentelemetry-instrumentor use equivalent environment variables. - Tune Python-specific options (exclusions, log correlation, disabled instrumentations) as needed.