Skip to main content

Guance profiling SDK extension for OpenTelemetry Python

Project description

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 guance-sdk-extension-profiling

or install it through the distro extra:

pip install guance-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.

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

guance_sdk_extension_profiling-0.63b5.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file guance_sdk_extension_profiling-0.63b5.tar.gz.

File metadata

File hashes

Hashes for guance_sdk_extension_profiling-0.63b5.tar.gz
Algorithm Hash digest
SHA256 8867f8c9efb028b4dc49801f20ed9bf6d528caf14c4db7cfdd2d6356217b7b4f
MD5 8391bfd3c3eab55bf0c79c31e8ae9b6d
BLAKE2b-256 38e46090b9902e2a205c5fdd438ce7f6247ea24aba066e7d6e2b75dc929ef146

See more details on using hashes here.

File details

Details for the file guance_sdk_extension_profiling-0.63b5-py3-none-any.whl.

File metadata

File hashes

Hashes for guance_sdk_extension_profiling-0.63b5-py3-none-any.whl
Algorithm Hash digest
SHA256 945639eabe4c45c16af95de321ff2ba628c9880231a6bdfbc10f0e7ce0776d8a
MD5 bde83953308244be1a26b60e39431fff
BLAKE2b-256 99cb4e5af1d65f8296660783865c8d92b1cee243ad4d7aeddd7021a122c7af58

See more details on using hashes here.

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