Skip to main content

Instrumentation Tools & Auto Instrumentation for OpenTelemetry Python

Project description

pypi

Installation

pip install opentelemetry-instrumentation

This package provides a couple of commands that help automatically instruments a program:

opentelemetry-bootstrap

opentelemetry-bootstrap --action=install|requirements

This commands inspects the active Python site-packages and figures out which instrumentation packages the user might want to install. By default it prints out a list of the suggested instrumentation packages which can be added to a requirements.txt file. It also supports installing the suggested packages when run with --action=install flag.

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 for free without having to make any code changes at all. This will also configure a global tracer and tracing exporter without you having to make any code changes. By default, the instrument command will use the OTLP exporter but this can be overriden when needed.

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

  • --exporter or OTEL_EXPORTER

Used to specify which trace exporter to use. Can be set to one or more of the well-known exporter names (see below).

  • Defaults to otlp.

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

You can pass multiple values to configure multiple exporters e.g, zipkin,prometheus

Well known trace exporter names:

  • jaeger

  • opencensus

  • otlp

  • otlp_span

  • otlp_metric

  • zipkin

otlp is an alias for otlp_span,otlp_metric.

  • --service-name or OTEL_SERVICE_NAME

When present the value is passed on to the relevant exporter initializer as service_name argument.

  • --ids-generator or OTEL_IDS_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”

Examples

opentelemetry-instrument -e otlp flask run --port=3000

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

opentelemetry-instrument -e zipkin,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 --ids-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.

References

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentelemetry-instrumentation-0.17b0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file opentelemetry-instrumentation-0.17b0.tar.gz.

File metadata

  • Download URL: opentelemetry-instrumentation-0.17b0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for opentelemetry-instrumentation-0.17b0.tar.gz
Algorithm Hash digest
SHA256 2c9b76b65325129f998e64fc12baa892146c0010d198d86d65ed5bc5f1f82011
MD5 74caf3dfdf3482e3b7dbe144f0ae06b6
BLAKE2b-256 12b1c6ca680d49f0e7b78f4545e9f3a96281d3873ea540750992b441782f8770

See more details on using hashes here.

File details

Details for the file opentelemetry_instrumentation-0.17b0-py3-none-any.whl.

File metadata

  • Download URL: opentelemetry_instrumentation-0.17b0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for opentelemetry_instrumentation-0.17b0-py3-none-any.whl
Algorithm Hash digest
SHA256 865fbfc12e58a94820dd6ae517ee2fd3c85449047e59551e39c118ae32afbfe4
MD5 7a3de7d03f0c7faef3076a5a17f03fe7
BLAKE2b-256 577d615df23eef424ff133b76308f62fade9f451e37885c5a145cee4b0e7056e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page