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 overridden when needed.

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

  • --traces_exporter or OTEL_TRACES_EXPORTER

  • --metrics_exporter or OTEL_METRICS_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_proto

  • jaeger_thrift

  • opencensus

  • zipkin_json

  • zipkin_proto

  • otlp

  • otlp_proto_grpc (deprecated)

  • otlp_proto_http (deprecated)

Note: The default transport protocol for otlp is gRPC. HTTP is currently supported for traces only, and should be set using OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf

  • --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”

Examples

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

The above command will pass --traces_exporter otlp 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.

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.37b0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file opentelemetry_instrumentation-0.37b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrumentation-0.37b0.tar.gz
Algorithm Hash digest
SHA256 2a172a7ef8d35332f24a97caf6b7b62fe418a48cf841ae2bcdaed338fea37b41
MD5 e48fb8c5fdeeaafb653ac51ca582464f
BLAKE2b-256 d644be396671eb7ce75017d99858420022a6721ae78738ed7aae986c0cfafc5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_instrumentation-0.37b0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dbd4d869608667b9dfaf39914312c5979370d5fc5faa36678f5e25fa54f045b
MD5 bfe8fa28f4417a72aed3520a7b4d5db8
BLAKE2b-256 b57ad79882daf1ba00ea9e34d79bc84a1c91f3f378e09bbe6536d7620d3eb139

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