Skip to main content

OpenTelemetry auto-instrumentation for Python applications using sitecustomize

Project description

OpenTelemetry SiteCustomize Instrumentation

Automatic OpenTelemetry instrumentation via Python's sitecustomize mechanism. Designed for environments where modifying the application startup command is difficult or impossible: managed runtimes, serverless platforms, job schedulers, and similar constrained settings. Install the package and instrumentation is applied automatically at Python startup, no wrapper command required.

When to Use This

The opentelemetry-instrument CLI is the standard way to auto-instrument a Python application. This package is for situations where wrapping your command with the CLI is not feasible, or requires tedious workarounds.

Note: If you control your application's startup command, prefer the opentelemetry-instrument CLI. This package is specifically designed for cases where that is not practical.

Installation

pip install opentelemetry-sitecustomize

or

uv add opentelemetry-sitecustomize

You will also need to install the OpenTelemetry instrumentors for the libraries you use. For example:

pip install opentelemetry-instrumentation-flask opentelemetry-instrumentation-requests

Usage

With the package installed, simply run your application as usual:

python app.py

No need for:

opentelemetry-instrument python app.py

OpenTelemetry instrumentation is applied automatically at Python startup.

Configuration

This package uses the same initialization path as the opentelemetry-instrument CLI, so all standard OpenTelemetry environment variables apply:

  • OTEL_SERVICE_NAME - set the service name for your traces
  • OTEL_TRACES_EXPORTER - choose the trace exporter (e.g., otlp, console, none)
  • OTEL_METRICS_EXPORTER - choose the metrics exporter
  • OTEL_LOGS_EXPORTER - choose the logs exporter
  • OTEL_EXPORTER_OTLP_ENDPOINT - set the OTLP collector endpoint
  • OTEL_PYTHON_DISABLED_INSTRUMENTATIONS - comma-separated list of instrumentations to skip

See the OpenTelemetry Python documentation for the full list of supported environment variables.

How It Works

This package registers a sitecustomize entrypoint that calls opentelemetry.instrumentation.auto_instrumentation:initialize during Python's site initialization. This is the same initialization function used by the opentelemetry-instrument CLI, but triggered automatically via the sitecustomize-entrypoints library.

Requirements

License

Apache-2.0

Project details


Download files

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

Source Distribution

opentelemetry_sitecustomize-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opentelemetry_sitecustomize-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file opentelemetry_sitecustomize-0.1.0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_sitecustomize-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef1c747342f4edb5060159e38a1ae2d1fe35667af84e3124d911123c17f546b0
MD5 cb1297d88a08e4a211ae0d6afb912236
BLAKE2b-256 dabdbfde2da5d93aed482db2c19addc41d065bd9eca4fbac8267ea8b08f8044e

See more details on using hashes here.

Provenance

The following attestation bundles were made for opentelemetry_sitecustomize-0.1.0.tar.gz:

Publisher: publish.yml on herin049/opentelemetry-sitecustomize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opentelemetry_sitecustomize-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_sitecustomize-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d467634f5d611a44c474ccf3f1cd9380d3bfbbf350f8f233554190348374d5c
MD5 ea1a09184f6586a70b175ded822a4157
BLAKE2b-256 bf71eb207e9b84910f39fd5b5c05042d8e8f083ea572f0c8b2fc9e00b7e84221

See more details on using hashes here.

Provenance

The following attestation bundles were made for opentelemetry_sitecustomize-0.1.0-py3-none-any.whl:

Publisher: publish.yml on herin049/opentelemetry-sitecustomize

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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