Skip to main content
Pre-release

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

OpenTelemetry SDK Extension for Python Profiling

This package provides a Python profiling runtime for OpenTelemetry auto-instrumentation. The current implementation exports profiles via OTLP and supports multiple collector types:

  • stack sampling

  • handled exceptions

  • threading and asyncio lock contention

  • threading and asyncio condition wait time

  • heap snapshots via tracemalloc

  • child-process restart after fork()

Installation

pip install opentelemetry-sdk-extension-profiling

or install it through the distro extra:

pip install opentelemetry-distro[profiling]

Usage

Enable profiling for applications launched via opentelemetry-instrument:

export OTEL_PROFILING_ENABLED=true
opentelemetry-instrument python app.py

Programmatic usage:

from opentelemetry.sdk.extension.profiling import Profiler

profiler = Profiler()
profiler.start()

Configuration

The following environment variables are supported:

  • OTEL_PROFILING_ENABLED

  • OTEL_PROFILING_EXPORTER (otlp or pprof)

  • OTEL_PROFILING_SAMPLE_INTERVAL

  • OTEL_PROFILING_EXPORT_INTERVAL

  • OTEL_PROFILING_MAX_FRAMES

  • OTEL_PROFILING_INCLUDE_TRACE_CONTEXT

  • OTEL_PROFILING_EXCEPTION_ENABLED

  • OTEL_PROFILING_EXCEPTION_SAMPLING_INTERVAL

  • OTEL_PROFILING_EXCEPTION_COLLECT_MESSAGE

  • OTEL_PROFILING_LOCK_ENABLED

  • OTEL_PROFILING_MEMORY_ENABLED

  • OTEL_PROFILING_MEMORY_INTERVAL

  • OTEL_PROFILING_MEMORY_TOP_STATS

  • OTEL_PROFILING_MEMORY_IGNORE_PROFILER

  • OTEL_EXPORTER_OTLP_PROFILES_PROTOCOL

  • OTEL_EXPORTER_OTLP_PROFILES_ENDPOINT

  • OTEL_EXPORTER_OTLP_PROFILES_HEADERS

  • OTEL_EXPORTER_OTLP_PROFILES_TIMEOUT

  • OTEL_EXPORTER_OTLP_PROFILES_COMPRESSION

  • OTEL_EXPORTER_OTLP_PROFILES_CERTIFICATE

  • OTEL_EXPORTER_OTLP_PROFILES_CLIENT_KEY

  • OTEL_EXPORTER_OTLP_PROFILES_CLIENT_CERTIFICATE

  • OTEL_PROFILING_PPROF_PATH

  • OTEL_PROFILING_PPROF_UPLOAD_URL

  • OTEL_PROFILING_PPROF_HEADERS

Service metadata should be configured with standard OpenTelemetry resource settings such as OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES.

Examples

Collect stack, exception, lock, and heap profiles and export them with OTLP/HTTP:

export OTEL_PROFILING_ENABLED=true
export OTEL_PROFILING_EXCEPTION_ENABLED=true
export OTEL_PROFILING_LOCK_ENABLED=true
export OTEL_PROFILING_MEMORY_ENABLED=true
export OTEL_EXPORTER_OTLP_PROFILES_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_PROFILES_ENDPOINT=http://localhost:4318/v1development/profiles
opentelemetry-instrument python app.py

To dump pprof files instead of OTLP, set:

export OTEL_PROFILING_EXPORTER=pprof
export OTEL_PROFILING_PPROF_PATH=/tmp/otel-profile

To POST pprof directly to a compatible agent endpoint and keep a local copy:

export OTEL_PROFILING_PPROF_UPLOAD_URL=http://localhost:9529/profiling/v1/input
export OTEL_PROFILING_PPROF_HEADERS="X-API-Key:xxx"
opentelemetry-instrument python app.py

When OTEL_PROFILING_EXPORTER is unset and OTEL_PROFILING_PPROF_UPLOAD_URL is configured, the runtime defaults to a legacy-compatible pprof upload layout. Set OTEL_PROFILING_EXPORTER=otlp to force OTLP profile export.

Metadata

Release files for opentelemetry-sdk-extension-profiling 0.63b4

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

Source distribution (sdist)

Source distribution for opentelemetry-sdk-extension-profiling 0.63b4
File Size Uploaded Provenance Actions
opentelemetry_sdk_extension_profiling-0.63b4.tar.gz 35.3 kB Without provenance Details for opentelemetry_sdk_extension_profiling-0.63b4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-sdk-extension-profiling 0.63b4
File Interpreter ABI Platform Actions
opentelemetry_sdk_extension_profiling-0.63b4-py3-none-any.whl Python 3 none any Details for opentelemetry_sdk_extension_profiling-0.63b4-py3-none-any.whl

Total release size: 75.1 kB

Release files / opentelemetry_sdk_extension_profiling-0.63b4.tar.gz

Download URL opentelemetry_sdk_extension_profiling-0.63b4.tar.gz
Size 35.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4507907eb3b90d04dfada66c81f07d313cf7c5890b64593678adc33d00d06bfe
BLAKE2b-256 checksum
How to use checksums
b6b3f36ac1db7c4c2393521ec97bddc2738a2744cbac4afb5053466f9558382a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / opentelemetry_sdk_extension_profiling-0.63b4-py3-none-any.whl

Download URL opentelemetry_sdk_extension_profiling-0.63b4-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f3f59b3dd86a5c4a6f39e474845251ca47dc76bd29a01deceee8e818093b29a
BLAKE2b-256 checksum
How to use checksums
19744643d24fc6f41c98dea02f81259fc6027f98f0dd4a6d5b343c8a75e2b45b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for opentelemetry-sdk-extension-profiling 0.63b4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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