pyroscope-rs icon indicating copy to clipboard operation
pyroscope-rs copied to clipboard

pyroscope not working on bare-metal python process with uvloop and numba libraries

Open massiccio opened this issue 4 months ago • 1 comments

Describe the bug

The pyroscope python agent does not work correctly on Mac OS.

To Reproduce

Native libraries being used: "msgspec==0.19.0", "pyroscope-io>=0.8.11", "uvloop>=0.21.0, "numba==0.61.2", "gunicorn>=23.0.0, "uvicorn-worker==0.3.0", "uvicorn[standard]>=0.34.3",

Minimal pyroscope configuration (see below). Spans configured as

with pyroscope.tag_wrapper({"endpoint": "/my-endpoont"}):
 ....

Pyroscope server running as a docker container using docker-compose:

  pyroscope:
    image: grafana/pyroscope:latest
    container_name: pyroscope
    ports:
      - "4040:4040"
    volumes:
      - pyroscope-storage:/var/lib/pyroscope
    command: ["server"]
    restart: unless-stopped
    networks:
      - my_network

volumes:
  pyroscope-storage:

Expected behavior

I would expect the application to report data, but I can't see any of my data in the Grafana Pyroscope data-source.

When i start my process, I either get these logs on console

 2025-08-04T10:51:14.395Z WARN  py_spy::python_process_info > Interpreter address from _PyRuntime symbol is invalid 0000000000000000
 2025-08-04T10:51:14.449Z WARN  py_spy::python_process_info > Interpreter address from _PyRuntime symbol is invalid 0000000000000000

when using a simple configuration such as

pyroscope.configure(
    application_name="my-service",
    server_address=os.getenv("PYROSCOPE_SERVER_ADDRESS", "http://localhost:4040"),
    enable_logging=True
)

or something like

 2025-08-04T10:59:38.562Z WARN  py_spy::sampler > Failed to get initialization status from PythonSpyThread: receiving on a closed channel
 2025-08-04T10:59:38.667Z WARN  py_spy::sampler > Failed to get initialization status from PythonSpyThread: receiving on a closed channel

when adding this option to the configuration

detect_subprocesses=True,

Environment

  • Deployment tool: uv 0.7.13
  • Python version: 3.13.5 (3.13.5 (main, Jun 12 2025, 12:22:43) [Clang 20.1.4 ])
  • Platform: macOS-15.5-arm64-arm-64bit-Mach-O

Additional Context

I have a python application using some native libaries such as msgspec, uvloop, Numba, uvicorn, or gunicorn I am running my application as a Mac OS process

massiccio avatar Aug 04 '25 11:08 massiccio