Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

redhat-opentelemetry-python-contrib

OpenTelemetry Python extensions written at Red Hat

This repository includes:

  • File exporters to export OpenTelemetry data to files when using auto-instrumentation
  • Script instrumentor - Auto instrumentation plugin for wrapping an entire python script run in a tracing span

Installation

pip install redhat-opentelemetry-python-contrib

Using the file exporters

The file exporters can be used by setting the OTEL_*_EXPORTER environment variables to file, or using the equivalent arguments to opentelemetry-instrument.

For example to export span data to a file for a particular Python script:

opentelemetry-instrument --traces_exporter file python myscript.py

The file to which the data will be written to can be customized using the environment variables listed below. Otherwise, the listed default value would be used:

Variable Used for Default value
OTEL_FILE_SPAN_EXPORTER_NAME Trace data otel_traces.log
OTEL_FILE_METRIC_EXPORTER_NAME Metrics otel_metrics.log
OTEL_FILE_LOG_EXPORTER_NAME Logs otel_logs.log

Using the script instrumentor

Once installed, the script instrumentor will automatically wrap any Python script invoked with auto instrumentation enabled in a span that would include the script name, command-line arguments and exit status.

The script instrumentor attempts to propagate the tracing context from the environment it was invoked in, by trying to read environment variables that are capitalized versions of the HTTP headers defined by the W3C Trace Context specification. This typically means that if the TRACEPARENT environment variable is defined in the environment the script runs in, the script span will become a child span of that trace. This is generally compatible with how other tools and systems handle things such as the Ansible OpenTelemetry callback plugin and the Jenkins OpenTelemetry plugin.

The script instrumentor can cause traces to look a bit strange for things that are not meant to be stand-alone Python scripts such as Django and Flask server processes. It can be disabled by setting the OTEL_PYTHON_DISABLED_INSTRUMENTATIONS environment variable:

export OTEL_PYTHON_DISABLED_INSTRUMENTATIONS="__main__"

Metadata

Release files for redhat-opentelemetry-contrib 0.0.0.post6.dev0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redhat-opentelemetry-contrib 0.0.0.post6.dev0
File Size Uploaded
redhat_opentelemetry_contrib-0.0.0.post6.dev0.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for redhat-opentelemetry-contrib 0.0.0.post6.dev0
File Interpreter ABI Platform
redhat_opentelemetry_contrib-0.0.0.post6.dev0-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / redhat_opentelemetry_contrib-0.0.0.post6.dev0.tar.gz

Download URL redhat_opentelemetry_contrib-0.0.0.post6.dev0.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cb2a59540d8a8c9e37ef64ec8e596b22512a0f445e49c10f54dec721415d7c11
BLAKE2b-256 checksum
How to use checksums
d0661741a4141624b372bba16a28ce7e7f2c0e37fc3da9c68a3b55294cfde0b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.9.15 Linux/5.15.0-1023-azure

Release files / redhat_opentelemetry_contrib-0.0.0.post6.dev0-py3-none-any.whl

Download URL redhat_opentelemetry_contrib-0.0.0.post6.dev0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac4169a721390e2cb3c881cdd3270093d7b8f3bc189525620f5c62adbb4c923b
BLAKE2b-256 checksum
How to use checksums
e513bb60d5ad6cb4c26141f05cd217efd4df7fda6c7c4cedfad58222ec64b8df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.9.15 Linux/5.15.0-1023-azure

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page