opentelemetry-instrumentation 0.59b0


pip install opentelemetry-instrumentation

  Latest version

Released: Oct 16, 2025


Meta
Author: OpenTelemetry Authors
Requires Python: >=3.9

Classifiers

Development Status
  • 4 - Beta

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13

pypi

Installation

pip install opentelemetry-instrumentation

This package provides commands that help automatically instrument a program:

opentelemetry-bootstrap

opentelemetry-bootstrap [-a |--action=][install|requirements]

This command install default instrumentation packages and detects active Python site-packages to figure out which instrumentation packages the user might want to install. By default, it prints out a list of the default and detected instrumentation packages that can be added to a requirements.txt file. It also supports installing the packages when run with --action=install or -a install flag. All default and detectable instrumentation packages are defined here <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py>.

opentelemetry-instrument

opentelemetry-instrument python program.py

The instrument command will try to automatically detect packages used by your python program and when possible, apply automatic tracing instrumentation on them. This means your program will get automatic distributed tracing without having to make any code changes. This will also configure a global tracer and tracing exporter as well as a meter and meter exporter. By default, the instrument command will use the OTLP exporter but this can be overridden.

The command supports the following configuration options as CLI arguments and environment variables:

  • --traces_exporter or OTEL_TRACES_EXPORTER

  • --metrics_exporter or OTEL_METRICS_EXPORTER

  • --distro or OTEL_PYTHON_DISTRO

  • --configurator or OTEL_PYTHON_CONFIGURATOR

The exporter options define what exporter destination to use and can be set to one or more exporter names (see below). You can pass multiple values to configure multiple exporters (e.g., zipkin_json,otlp).

  • Defaults to otlp.

  • Can be set to none to disable automatic tracer initialization.

  • Can be set to ‘console` to display JSON results locally.

Trace exporter names:

  • jaeger_proto

  • jaeger_thrift

  • opencensus

  • otlp

  • otlp_proto_grpc (deprecated)

  • otlp_proto_http (deprecated)

  • zipkin_json

  • zipkin_proto

Metric exporter names:

  • otlp

  • otlp_proto_grpc (deprecated)

  • prometheus

Note: The default transport protocol for otlp is gRPC.

  • --id-generator or OTEL_PYTHON_ID_GENERATOR

Used to specify which IDs Generator to use for the global Tracer Provider. By default, it will use the random IDs generator.

The code in program.py needs to use one of the packages for which there is an OpenTelemetry integration. For a list of the available integrations please check here

  • OTEL_PYTHON_DISABLED_INSTRUMENTATIONS

If set by the user, opentelemetry-instrument will read this environment variable to disable specific instrumentations. e.g OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=”requests,django”

  • OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH

If set by the user to patch_all , opentelemetry instrument will call the gevent monkeypatching method patch_all. This is considered experimental but can be useful to instrument gevent applications. e.g OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH=patch_all

Examples

opentelemetry-instrument --traces_exporter console flask run --port=3000

The above command will pass --traces_exporter console to the instrument command and --port=3000 to flask run.

opentelemetry-instrument --traces_exporter zipkin_json,otlp celery -A tasks worker --loglevel=info

The above command will configure global trace provider, attach zipkin and otlp exporters to it and then start celery with the rest of the arguments.

opentelemetry-instrument --id_generator random flask run --port=3000

The above command will configure the global trace provider to use the Random IDs Generator, and then pass --port=3000 to flask run.

Programmatic Auto-instrumentation

from opentelemetry.instrumentation import auto_instrumentation
auto_instrumentation.initialize()

If you are in an environment where you cannot use opentelemetry-instrument to inject auto-instrumentation you can do so programmatically with the code above. Please note that some instrumentations may require the initialize() method to be called before the library they instrument is imported.

References

0.59b0 Oct 16, 2025
0.58b0 Sep 11, 2025
0.57b0 Jul 29, 2025
0.56b0 Jul 11, 2025
0.55b1 Jun 10, 2025
0.55b0 Jun 04, 2025
0.54b1 May 16, 2025
0.54b0 May 09, 2025
0.53b1 Apr 15, 2025
0.53b0 Apr 10, 2025
0.52b1 Mar 20, 2025
0.52b0 Mar 12, 2025
0.51b0 Feb 04, 2025
0.50b0 Dec 11, 2024
0.49b2 Nov 18, 2024
0.49b1 Nov 08, 2024
0.49b0 Nov 05, 2024
0.48b0 Aug 28, 2024
0.47b0 Jul 25, 2024
0.46b0 May 31, 2024
0.45b0 Mar 28, 2024
0.44b0 Feb 23, 2024
0.43b0 Dec 15, 2023
0.42b0 Nov 08, 2023
0.41b0 Sep 11, 2023
0.40b0 Jul 13, 2023
0.39b0 May 19, 2023
0.38b0 Mar 22, 2023
0.37b0 Feb 17, 2023
0.36b0 Dec 09, 2022
0.35b0 Nov 03, 2022
0.34b0 Sep 27, 2022
0.33b0 Aug 09, 2022
0.32b0 Jul 04, 2022
0.31b0 May 17, 2022
0.30b1 Apr 21, 2022
0.30b0 Apr 18, 2022
0.29b0 Mar 11, 2022
0.28b1 Jan 31, 2022
0.28b0 Jan 26, 2022
0.27b0 Dec 17, 2021
0.26b1 Nov 11, 2021
0.25b2 Oct 19, 2021
0.25b1 Oct 18, 2021
0.25b0 Oct 13, 2021
0.24b0 Aug 26, 2021
0.23b2 Jul 28, 2021
0.23b1 Jul 26, 2021
0.23b0 Jul 21, 2021
0.22b0 Jun 02, 2021
0.21b0 May 12, 2021
0.20b0 Apr 20, 2021
0.19b0 Mar 26, 2021
0.18b0 Feb 16, 2021
0.17b0 Jan 20, 2021
0.16b1 Nov 27, 2020
0.16b0 Nov 26, 2020
0.15b0 Nov 02, 2020
0.14b0 Oct 13, 2020
0.13b0 Sep 17, 2020
0.12b0 Aug 14, 2020
0.11b0 Jul 28, 2020
0.10b0 Jun 23, 2020
0.9b0 Jun 11, 2020
Extras: None
Dependencies:
opentelemetry-api (~=1.4)
opentelemetry-semantic-conventions (==0.59b0)
packaging (>=18.0)
wrapt (<2.0.0,>=1.0.0)