{"library":"pyroscope-otel","title":"Pyroscope OpenTelemetry Python Integration","description":"The `pyroscope-otel` library for Python provides functionalities to link OpenTelemetry tracing data with Grafana Pyroscope's continuous profiling data. It offers a `SpanProcessor` implementation that automatically attaches profiling identifiers to trace spans, enabling users to correlate traces with detailed performance profiles. The library is actively maintained by Grafana, with its current version being 1.0.0. Releases appear to be somewhat regular, reflecting ongoing development.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyroscope-otel"],"cli":null},"imports":["from pyroscope.otel import PyroscopeSpanProcessor","from pyroscope import configure as pyroscope_configure","from opentelemetry.sdk.trace import TracerProvider"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport time\n\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor\n\nfrom pyroscope import configure as pyroscope_configure\nfrom pyroscope.otel import PyroscopeSpanProcessor\n\n# 1. Configure Pyroscope profiler first\npyroscope_configure(\n    app_name=\"my-python-app\",\n    server_address=os.environ.get(\"PYROSCOPE_SERVER_ADDRESS\", \"http://localhost:4040\"),\n    auth_token=os.environ.get(\"PYROSCOPE_AUTH_TOKEN\", \"\"), # Optional for Grafana Cloud\n    sample_rate=100, # Default sample rate\n)\n\n# 2. Configure OpenTelemetry TracerProvider\nprovider = TracerProvider()\n\n# Add PyroscopeSpanProcessor to link traces and profiles\nprovider.add_span_processor(PyroscopeSpanProcessor())\n\n# Optional: Add a console exporter for visibility of spans\nprovider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))\n\ntrace.set_tracer_provider(provider)\n\n# 3. Get a tracer and create spans\ntracer = trace.get_tracer(__name__)\n\ndef my_function():\n    with tracer.start_as_current_span(\"my-function-span\") as span:\n        print(\"Executing my_function...\")\n        time.sleep(0.05)\n        with tracer.start_as_current_span(\"inner-operation\"):\n            print(\"Executing inner_operation...\")\n            time.sleep(0.02)\n        print(\"my_function finished.\")\n\nif __name__ == \"__main__\":\n    print(\"Starting application with Pyroscope-OpenTelemetry integration...\")\n    my_function()\n    print(\"Application finished.\")\n    # Give some time for exporters to send data\n    time.sleep(1)\n","lang":"python","description":"This quickstart demonstrates the essential steps to integrate `pyroscope-otel`. It configures the core Pyroscope profiler, sets up an OpenTelemetry `TracerProvider`, and then registers the `PyroscopeSpanProcessor` to automatically link trace spans with profiling data. Ensure a Pyroscope server is running and accessible at the configured `server_address` (default `http://localhost:4040`).","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.4.1","pypi_latest":"1.0.0","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":90,"avg_install_s":2.6,"avg_import_s":0.4,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.31,"mem_mb":13.1,"disk_size":"42.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.22,"mem_mb":13.1,"disk_size":"42M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.45,"mem_mb":13.8,"disk_size":"44.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.38,"mem_mb":13.8,"disk_size":"45M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.67,"mem_mb":13.9,"disk_size":"36.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.63,"mem_mb":13.9,"disk_size":"37M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.34,"mem_mb":14.1,"disk_size":"36.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.33,"mem_mb":14.1,"disk_size":"36M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyroscope-otel","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyroscope-otel","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3,"import_time_s":0.26,"mem_mb":12.8,"disk_size":"33M"}]}}