Sampling profiler for Python programs

Overview

py-spy: Sampling profiler for Python programs

Build Status FreeBSD Build Status

py-spy is a sampling profiler for Python programs. It lets you visualize what your Python program is spending time on without restarting the program or modifying the code in any way. py-spy is extremely low overhead: it is written in Rust for speed and doesn't run in the same process as the profiled Python program. This means py-spy is safe to use against production Python code.

py-spy works on Linux, OSX, Windows and FreeBSD, and supports profiling all recent versions of the CPython interpreter (versions 2.3-2.7 and 3.3-3.8).

Installation

Prebuilt binary wheels can be installed from PyPI with:

pip install py-spy

You can also download prebuilt binaries from the GitHub Releases Page. This includes binaries for ARM and FreeBSD, which can't be installed using pip. If you're a Rust user, py-spy can also be installed with: cargo install py-spy. On Arch Linux, py-spy is in AUR and can be installed with yay -S py-spy.

Usage

py-spy works from the command line and takes either the PID of the program you want to sample from or the command line of the python program you want to run. py-spy has three subcommands record, top and dump:

record

py-spy supports recording profiles to a file using the record command. For example, you can generate a flame graph of your python process by going:

py-spy record -o profile.svg --pid 12345
# OR
py-spy record -o profile.svg -- python myprogram.py

Which will generate an interactive SVG file looking like:

flame graph

You can change the file format to generate speedscope profiles or raw data with the --format parameter. See py-spy record --help for information on other options including changing the sampling rate, filtering to only include threads that hold the GIL, profiling native C extensions, showing thread-ids, profiling subprocesses and more.

top

Top shows a live view of what functions are taking the most time in your python program, similar to the Unix top command. Running py-spy with:

py-spy top --pid 12345
# OR
py-spy top -- python myprogram.py

will bring up a live updating high level view of your python program:

console viewer demo

dump

py-spy can also display the current call stack for each python thread with the dump command:

py-spy dump --pid 12345

This will dump out the call stacks for each thread, and some other basic process info to the console:

dump output

This is useful for the case where you just need a single call stack to figure out where your python program is hung on. This command also has the ability to print out the local variables associated with each stack frame by setting the --locals flag.

Frequently Asked Questions

Why do we need another Python profiler?

This project aims to let you profile and debug any running Python program, even if the program is serving production traffic.

While there are many other python profiling projects, almost all of them require modifying the profiled program in some way. Usually, the profiling code runs inside of the target python process, which will slow down and change how the program operates. This means it's not generally safe to use these profilers for debugging issues in production services since they will usually have a noticeable impact on performance.

How does py-spy work?

py-spy works by directly reading the memory of the python program using the process_vm_readv system call on Linux, the vm_read call on OSX or the ReadProcessMemory call on Windows.

Figuring out the call stack of the Python program is done by looking at the global PyInterpreterState variable to get all the Python threads running in the interpreter, and then iterating over each PyFrameObject in each thread to get the call stack. Since the Python ABI changes between versions, we use rust's bindgen to generate different rust structures for each Python interpreter class we care about and use these generated structs to figure out the memory layout in the Python program.

Getting the memory address of the Python Interpreter can be a little tricky due to Address Space Layout Randomization. If the target python interpreter ships with symbols it is pretty easy to figure out the memory address of the interpreter by dereferencing the interp_head or _PyRuntime variables depending on the Python version. However, many Python versions are shipped with either stripped binaries or shipped without the corresponding PDB symbol files on Windows. In these cases we scan through the BSS section for addresses that look like they may point to a valid PyInterpreterState and check if the layout of that address is what we expect.

Can py-spy profile native extensions?

Yes! py-spy supports profiling native python extensions written in languages like C/C++ or Cython, on x86_64 Linux and Windows. You can enable this mode by passing --native on the command line. For best results, you should compile your Python extension with symbols. Also worth noting for Cython programs is that py-spy needs the generated C or C++ file in order to return line numbers of the original .pyx file. Read the blog post for more information.

How can I profile subprocesses?

By passing in the --subprocesses flag to either the record or top view, py-spy will also include the output from any python process that is a child process of the target program. This is useful for profiling applications that use multiprocessing or gunicorn worker pools. py-spy will monitor for new processes being created, and automatically attach to them and include samples from them in the output. The record view will include the PID and cmdline of each program in the callstack, with subprocesses appearing as children of their parent processes.

When do you need to run as sudo?

py-spy works by reading memory from a different python process, and this might not be allowed for security reasons depending on your OS and system settings. In many cases, running as a root user (with sudo or similar) gets around these security restrictions. OSX always requires running as root, but on Linux it depends on how you are launching py-spy and the system security settings.

On Linux the default configuration is to require root permissions when attaching to a process that isn't a child. For py-spy this means you can profile without root access by getting py-spy to create the process (py-spy -- python myprogram.py) but attaching to an existing process by specifying a PID will usually require root (sudo py-spy --pid 123456). You can remove this restriction on Linux by setting the ptrace_scope sysctl variable.

How do you detect if a thread is idle or not?

py-spy attempts to only include stack traces from threads that are actively running code, and exclude threads that are sleeping or otherwise idle. When possible, py-spy attempts to get this thread activity information from the OS: by reading in /proc/PID/stat on Linux, by using the mach thread_basic_info call on OSX, and by looking if the current SysCall is known to be idle on Windows.

There are some limitations with this approach though that may cause idle threads to still be marked as active. First off, we have to get this thread activity information before pausing the program, because getting this from a paused program will cause it to always return that this is idle. This means there is a potential race condition, where we get the thread activity and then the thread is in a different state when we get the stack trace. Querying the OS for thread activity also isn't implemented yet for FreeBSD and i686/ARM processors on Linux. On Windows, calls that are blocked on IO also won't be marked as idle yet, for instance when reading input from stdin. Finally, on some Linux calls the ptrace attach that we are using may cause idle threads to wake up momentarily, causing false positives when reading from procfs. For these reasons, we also have a heuristic fallback that marks known certain known calls in python as being idle.

You can disable this functionality by setting the --idle flag, which will include frames that py-spy considers idle.

How does GIL detection work?

We get GIL activity by looking at the threadid value pointed to by the _PyThreadState_Current symbol for Python 3.6 and earlier and by figuring out the equivalent from the _PyRuntime struct in Python 3.7 and later. These symbols might not be included in your python distribution, which will cause resolving which thread holds on to the GIL to fail. Current GIL usage is also shown in the top view as %GIL.

Passing the --gil flag will only include traces for threads that are holding on to the Global Interpreter Lock. In some cases this might be a more accurate view of how your python program is spending its time, though you should be aware that this will miss activity in extensions that release the GIL while still active.

Why am I having issues profiling /usr/bin/python on OSX?

OSX has a feature called System Integrity Protection that prevents even the root user from reading memory from any binary located in /usr/bin. Unfortunately, this includes the python interpreter that ships with OSX.

There are a couple of different ways to deal with this:

  • You can install a different Python distribution. The built-in Python will be removed in a future OSX, and you probably want to migrate away from Python 2 anyways =).
  • You can use virtualenv to run the system python in an environment where SIP doesn't apply.
  • You can disable System Integrity Protection.

How do I run py-spy in Docker?

Running py-spy inside of a docker container will also usually bring up a permissions denied error even when running as root.

This error is caused by docker restricting the process_vm_readv system call we are using. This can be overridden by setting --cap-add SYS_PTRACE when starting the docker container.

Alternatively you can edit the docker-compose yaml file

your_service:
   cap_add:
     - SYS_PTRACE

Note that you'll need to restart the docker container in order for this setting to take effect.

You can also use py-spy from the Host OS to profile a running process running inside the docker container.

How do I run py-spy in Kubernetes?

py-spy needs SYS_PTRACE to be able to read process memory. Kubernetes drops that capability by default, resulting in the error

Permission Denied: Try running again with elevated permissions by going 'sudo env "PATH=$PATH" !!'

The recommended way to deal with this is to edit the spec and add that capability. For a deployment, this is done by adding this to Deployment.spec.template.spec.containers

securityContext:
  capabilities:
    add:
    - SYS_PTRACE

More details on this here: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container Note that this will remove the existing pods and create those again.

How do I install py-spy on Alpine Linux?

Alpine python opts out of the manylinux wheels: pypa/pip#3969 (comment). You can override this behaviour to use pip to install py-spy on Alpine by going:

echo 'manylinux1_compatible = True' > /usr/local/lib/python3.7/site-packages/_manylinux.py

Alternatively you can download a musl binary from the GitHub releases page.

How can I avoid pausing the Python program?

By setting the --nonblocking option, py-spy won't pause the target python you are profiling from. While the performance impact of sampling from a process with py-spy is usually extremely low, setting this option will totally avoid interrupting your running python program.

With this option set, py-spy will instead read the interpreter state from the python process as it is running. Since the calls we use to read memory from are not atomic, and we have to issue multiple calls to get a stack trace this means that occasionally we get errors when sampling. This can show up as an increased error rate when sampling, or as partial stack frames being included in the output.

How are you distributing Rust executable binaries over PyPI?

Ok, so no-one has ever actually asked me this - but I wanted to share since it's a pretty terrible hack that might be useful to other people.

I really wanted to distribute this package over PyPI, since installing with pip will make this much easier for most Python programmers to get installed on their system. Unfortunately, installing executables as python scripts isn't something that setuptools supports.

To get around this I'm using setuptools_rust package to build the py-spy binary, and then overriding the distutils install command to copy the built binary into the python scripts folder. By doing this with prebuilt wheels for supported platforms means that we can install py-spy with pip, and not require a Rust compiler on the machine that this is being installed onto.

Does py-spy support 32-bit Windows? Integrate with PyPy? Work with USC2 versions of Python2?

Not yet =).

If there are features you'd like to see in py-spy either thumb up the appropriate issue or create a new one that describes what functionality is missing.

Credits

py-spy is heavily inspired by Julia Evans excellent work on rbspy. In particular, the code to generate flamegraph and speedscope files is taken directly from rbspy, and this project uses the read-process-memory and proc-maps crates that were spun off from rbspy.

License

py-spy is released under the MIT License, see the LICENSE file for the full text.

Comments
  • ptrace errors on linux kernel older than v4.7

    ptrace errors on linux kernel older than v4.7

    Profiling this works fine:

    while True:
        pass
    

    But when I run py-spy on this, it no longer shows any output (clears the screen, then stays empty; no top view):

    import numpy as np
    
    while True:
        pass
    

    Any ideas?

    bug 
    opened by jonasrauber 23
  • Profile Native Extensions

    Profile Native Extensions

    Right now we are figuring out the call stack of the Python program by inspecting the PyInterpreterState/PyThreadState/PyFrameObject variables found in the target python program. This means we don't get information about time spent in non-python threads and time spent in native extensions to python (like extension code written in Cython or C++)

    It could be useful to profile these native extensions in addition to the Python call stacks. It might be possible to use something like libunwind to augment the Python call stack to get this information.

    edit: There is a prerelease here pip install py-spy==0.2.0.dev4 that can profile native extensions of 64-bit Linux/Windows.

    enhancement 
    opened by benfred 21
  • "Killed: 9"?

    Hello there,

    Thank you for your work on the tool! I'm very excited to use it, but seem to have hit a snag:

    17:12 ~/code/optimizely/src/www
    $ pstree 98465
    --- 98465 swilson /Users/swilson/code/optimizely/.virtualenv/www/test/bin/python /Users/swilson/code/optimizely/.virtualenv/www/test/bin/pytest --pdb services_test/client_tes [truncated]
    
    17:13 ~/code/optimizely/src/www
    $ sudo py-spy --pid 98465 -f hottt
    Killed: 9
    

    I've ensured that the PID of pytest isn't moving around; i.e., it's a long-running process with no child processes. Yet while it's running, I get the output Killed: 9, exit status 137.

    Python 2.7.12 py-spy 0.1.8 macOS 12.13.6

    Let me know if I can provide any other details!

    opened by spencerwilson-optimizely 20
  • Upgrade goblin to 0.4.1

    Upgrade goblin to 0.4.1

    Encountered this error:

    Error: Failed to parse python binary
    Reason: Malformed entity: Section 106 size (4277144) + addr (120) is out of bounds. Overflowed: false
    

    (installed "python", which is Python 2.7.6, on an ubuntu:14.04 Docker).

    I started looking in goblin, and found this commit 84062ff966c98d390 ("Fix size check for section headers") which appears to fix this problem, so I just upgraded to the newest goblin version available (although 0.3.x also solves the issue).

    Possibly solves: https://github.com/benfred/py-spy/issues/405 and https://github.com/benfred/py-spy/issues/403.

    @benfred , I see that remoteprocess depends on goblin 0.3.0, so perhaps I can upgrade remoteprocess before this PR, and then we won't need remoteprocess to use a different version from py-spy?

    opened by Jongy 14
  • os error 299 on Windows 10

    os error 299 on Windows 10

    When I run py-spy -- python xx.py,I got a os error 299,I also try run it with administrator but get the same error. Windows Version:10 64bit Python Version:3.6.6 64bit

    opened by asypost 13
  • Sometimes profiled program is left suspended

    Sometimes profiled program is left suspended

    This is intermittent, but: sometimes, once a py-spy record -d <duration> completes, the program being profiled is left in a suspended state.

    for example:

    [email protected]:~$ sudo ./env/bin/py-spy record -f raw -p 20463 -d 5 -g
    py-spy> Sampling process 100 times a second for 5 seconds. Press Control-C to exit.
    
    py-spy> Wrote raw flamegraph data to '20463-2021-05-07T10:32:48Z.txt'. Samples: 412 Errors: 0
    py-spy> You can use the flamegraph.pl script from https://github.com/brendangregg/flamegraph to generate a SVG
    [email protected]:~$ ps 20463
      PID TTY      STAT   TIME COMMAND
    20463 ?        Tsl   43:28 /opt/sygnal/env/bin/python -m sygnal.sygnal
    
    opened by richvdh 12
  • In

    In "Ubuntu" docker container on Joyent's Triton platform, py-spy exits with os error 38

    Triton implements the docker API and can run sort of faux-Linux containers that are (to the best of my non-expert understanding) actually built on top of Solaris zones, as the host OS of Triton compute nodes is SmartOS, which is based on illumos, which is based on OpenSolaris, which is based on BSD and proprietary UNIX implementations.

    The README says BSD is not yet supported, so I'm not surprised that it didn't work. It'd be awfully nice if it did, though, and I thought I'd open an issue in case anyone else is trying to use py-spy in a SmartOS container or another BSD or BSD-like environment.

    The specific error message I get is:

    Error: Function not implemented (os error 38)
    
    opened by jgysland 12
  • freeBSD 12.2-RELEASE not working

    freeBSD 12.2-RELEASE not working

    Even though it seems there is logic to push a freeBSD binary to the releases page, there doesn't seem to be one there. (Unless I'm just missing it).

    However, running a stock 12.2 release system FreeBSD fbsd12.2-build 12.2-RELEASE FreeBSD 12.2-RELEASE r366954 GENERIC amd64, I downloaded the latest py-spy source (3.8 at time of writing) and compiled without any problems. However, if I run the program I get this:

    [2021-08-04T01:36:52.756370714Z INFO  py_spy::python_spy] Got virtual memory maps from pid 12904:
    [2021-08-04T01:36:52.756381030Z WARN  py_spy::python_spy] Failed to find '/usr/local/bin/python3.7m' in virtual memory maps, falling back to first map region
    [2021-08-04T01:36:52.756432265Z INFO  py_spy::python_spy] Getting version from python binary BSS
    [2021-08-04T01:36:52.756443081Z INFO  py_spy::python_spy] Failed to get version from BSS section: failed to find version string
    [2021-08-04T01:36:52.756446871Z INFO  py_spy::python_spy] Trying to get version from path: /usr/local/bin/python3.7m
    

    I'm just starting a standard interpreter session, nothing fancy.

    [email protected]:~/build # python3
    Python 3.7.9 (default, Feb  4 2021, 01:17:36)
    [Clang 10.0.1 ([email protected]:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611a on freebsd12
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    

    I also tried on another freebsd machine 12.2-RELEASE-p6 trying to profile a complex long-running python program (version python 3.9.5) and get this instead

    [2021-08-03T23:14:33.055404370Z INFO  py_spy::python_spy] Got virtual memory maps from pid 4397:
    [2021-08-03T23:14:33.055424910Z WARN  py_spy::python_spy] Failed to find '/usr/local/bin/python3.9' in virtual memory maps, falling back to first map region
    [2021-08-03T23:14:33.055651030Z INFO  py_spy::python_spy] Getting version from python binary BSS
    [2021-08-03T23:14:33.055681460Z INFO  py_spy::python_spy] Failed to get version from BSS section: failed to find version string
    [2021-08-03T23:14:33.055690820Z INFO  py_spy::python_spy] Trying to get version from path: /usr/local/bin/python3.9
    [2021-08-03T23:14:33.055714970Z INFO  py_spy::python_spy] python version 3.9.0 detected
    [2021-08-03T23:14:33.055739050Z INFO  py_spy::python_spy] Failed to get interp_head from symbols, scanning BSS section from main binary
    Error: Failed to find a python interpreter in the .data section
    

    Not sure if I'm doing something wrong, but seems like all documentation points to freeBSD being supported so I'm assuming the issue is me 😄

    opened by yocalebo 11
  • Windows: profiling inside a venv?

    Windows: profiling inside a venv?

    I'm having trouble running py-spy inside a venv on Windows 10 x64 1909, Python 3.8.1. It errors out with Error: Failed to find python version from target process. Admin privileges don't help. I presume the python.exe inside venv\Scripts is not what py-spy expects, so I copied over the actual EXE and DLL from the global Python38 folder. Profiling then works, but runs extremely slowly with considerable sampling lag.

    Is this a known unsupported use-case?

    opened by madig 11
  • py-spy on host unable to trace python process running in container

    py-spy on host unable to trace python process running in container

    From the host, I tried to trace a python process running in a docker container. It failed with the following error.

    # py-spy --pid 3676
    Error: No such file or directory (os error 2)
    

    strace shows it dies at open("/usr/local/bin/python2.7", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory). I see that it got that path via readlink("/proc/3676/exe", "/usr/local/bin/python2.7", 256) = 24

    python2.7 is only available at that path in the container's mount namespace. From outside the namespace it's in one of the filesystems mounted under /var/lib/docker.

    opened by sciurus 11
  • Windows 7: ANSI code to clear the rest of the line gives additional characters: `←[K`

    Windows 7: ANSI code to clear the rest of the line gives additional characters: `←[K`

    On a German Windows cmd the output looks like this:

    Collecting samples from 'pid: 17092' (python vX.Y.Z)←[K
    Total Samples 598500←[K
    GIL: 0.00%, Active: 200.00%, Threads: 2←[K
    ←[K
      %Own   %Total  OwnTime  TotalTime  Function (filename:line)
     99.40%  99.40%   572.4s    572.4s   run (foo.py:733)←[K[K
     84.10%  84.10%   109.4s    109.4s   foo (foo:4698)←[K
     11.50%  11.50%   13.13s    13.13s   foo (foo:4681)←[KK
      1.80%   1.80%    2.09s     2.09s   foo (foo:4676)←[KK
      0.90%   0.90%   0.791s    0.791s   foo (foo:4693)←[KK
      0.60%   0.60%   26.03s    26.03s   run (foo.py:728)←[K)←[KK
      0.40%   0.40%   0.555s    0.555s   foo (foo:4700)←[KK
      0.30%   0.30%   0.558s    0.558s   foo (foo:4694)←[KK2031)←[K
      0.30%   0.30%   0.508s    0.508s   foo (foo:4701)←[KK2031)←[K
      0.30%   0.30%   0.276s    0.276s   foo (foo:4695)←[KK2031)←[K
      0.20%   0.20%   0.043s    0.043s   foo (foo:4674)←[KK2031)←[K
      0.10%   0.10%   0.102s    0.102s   foo (foo:4691)←[K[K031)←[K
      0.10%   0.10%   0.035s    0.035s   foo (foo:4699)←[K[K031)←[K4)←[K
    ←[K
    Press Control-C to quit, or ? for help.←[K
    ←[K
    ←[K
    

    They seem to come from the macro out!: https://github.com/benfred/py-spy/blob/c2813e57a5807a3718233914eea13c31b80a3a1b/src/console_viewer.rs#L128

    opened by kud1ing 11
  • speedgraph startValue is always 0

    speedgraph startValue is always 0

    Hello,

    I am trying to debug a concurrency problem in psycopg 3, namely the fact that thread don't seem to run in parallel as much as in psycopg 2. In py-spy flamegraphs of multithread runs I can see long spells of time spent trying to acquire the GIL after sections in which it was released.

    image

    What I need is to answer the question: "when thread t is locked on GIL acquisition, which thread has the control, and what is it doing?"

    I have tried to use the speedgraph to answer this question. Unfortunately it seems that the startValue for each Profile is always 0:

    https://github.com/benfred/py-spy/blob/master/src/speedscope.rs#L144

    As a consequence, two threads' profiles cannot be aligned precisely and the question of what a thread is doing cannot be answered consistently.

    Would it be possible to set startValue either to the absolute start time of the thread, or to a relative time starting from the first thread start, so that the threads profiles can be aligned?

    opened by dvarrazzo 0
  • NVIDIA GPU profiling support

    NVIDIA GPU profiling support

    Feature Request

    Support for GPU profiling similar to what's currently being offered for CPU.

    Alternative solutions

    1. Sentry's (OSS) OpenTelemetry Collector collects GPU metrics
    2. Framework-specific like PyTorch Profiler or TensorFlow Profiler that could be incorporated into this product to provide it as a service out of the box.

    Is there a use case or business reason for this request?

    The CPU market is growing at a compound annual growth rate (CAGR) of 4.36% while the GPU market grows at a CAGR of 33.4%. Also NVIDIA has the biggest market share at 80%.

    opened by elgalu 0
  • Python 3.11 Support is broken on OSX

    Python 3.11 Support is broken on OSX

    We added python3.11 support based on a pre-release version of python 3.11 - but the released version doesn't seem to work in OSX , and is blocking PR's like https://github.com/benfred/py-spy/pull/533

    opened by benfred 1
Releases(v0.3.14)
Owner
Ben Frederickson
Ben Frederickson
Call-graph profiling for TwinCAT 3

Twingrind This project brings profiling to TwinCAT PLCs. The general idea of the implementation is as follows. Twingrind is a TwinCAT library that inc

stefanbesler 10 Oct 12, 2022
Cross-platform lib for process and system monitoring in Python

Home Install Documentation Download Forum Blog Funding What's new Summary psutil (process and system utilities) is a cross-platform library for retrie

Giampaolo Rodola 9k Jan 02, 2023
ASGI middleware to record and emit timing metrics (to something like statsd)

timing-asgi This is a timing middleware for ASGI, useful for automatic instrumentation of ASGI endpoints. This was developed at GRID for use with our

Steinn Eldjárn Sigurðarson 99 Nov 21, 2022
Was an interactive continuous Python profiler.

☠ This project is not maintained anymore. We highly recommend switching to py-spy which provides better performance and usability. Profiling The profi

What! Studio 3k Dec 27, 2022
ScoutAPM Python Agent. Supports Django, Flask, and many other frameworks.

Scout Python APM Agent Monitor the performance of Python Django apps, Flask apps, and Celery workers with Scout's Python APM Agent. Detailed performan

Scout APM 59 Nov 26, 2022
Prometheus integration for Starlette.

Starlette Prometheus Introduction Prometheus integration for Starlette. Requirements Python 3.6+ Starlette 0.9+ Installation $ pip install starlette-p

José Antonio Perdiguero 229 Dec 21, 2022
Automatically monitor the evolving performance of Flask/Python web services.

Flask Monitoring Dashboard A dashboard for automatic monitoring of Flask web-services. Key Features • How to use • Live Demo • Feedback • Documentatio

663 Dec 29, 2022
Linux/OSX/FreeBSD resource monitor

Index Documents Description Features Themes Support and funding Prerequisites (Read this if you are having issues!) Dependencies Screenshots Installat

9k Jan 08, 2023
Real-time metrics for nginx server

ngxtop - real-time metrics for nginx server (and others) ngxtop parses your nginx access log and outputs useful, top-like, metrics of your nginx serve

Binh Le 6.4k Dec 22, 2022
System monitor - A python-based real-time system monitoring tool

System monitor A python-based real-time system monitoring tool Screenshots Installation Run My project with these commands pip install -r requiremen

Sachit Yadav 4 Feb 11, 2022
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.

starlette context Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automat

Tomasz Wójcik 300 Dec 26, 2022
Prometheus instrumentation library for Python applications

Prometheus Python Client The official Python 2 and 3 client for Prometheus. Three Step Demo One: Install the client: pip install prometheus-client Tw

Prometheus 3.2k Jan 07, 2023
Exports osu! user stats to prometheus metrics for a specified set of users

osu! to prometheus exporter This tool exports osu! user statistics into prometheus metrics for a specified set of user ids. Just copy the config.json.

Peter Oettig 1 Feb 24, 2022
🚴 Call stack profiler for Python. Shows you why your code is slow!

pyinstrument Pyinstrument is a Python profiler. A profiler is a tool to help you 'optimize' your code - make it faster. It sounds obvious, but to get

Joe Rickerby 5k Jan 01, 2023
Monitor Memory usage of Python code

Memory Profiler This is a python module for monitoring memory consumption of a process as well as line-by-line analysis of memory consumption for pyth

Fabian Pedregosa 80 Nov 18, 2022
Development tool to measure, monitor and analyze the memory behavior of Python objects in a running Python application.

README for pympler Before installing Pympler, try it with your Python version: python setup.py try If any errors are reported, check whether your Pyt

996 Jan 01, 2023
Cobalt Strike random C2 Profile generator

Random C2 Profile Generator Cobalt Strike random C2 Profile generator Author: Joe Vest (@joevest) This project is designed to generate malleable c2 pr

Threat Express 482 Jan 08, 2023
pprofile + matplotlib = Python program profiled as an awesome heatmap!

pyheat Profilers are extremely helpful tools. They help us dig deep into code, find and understand performance bottlenecks. But sometimes we just want

Vishwas B Sharma 735 Dec 27, 2022
Sampling profiler for Python programs

py-spy: Sampling profiler for Python programs py-spy is a sampling profiler for Python programs. It lets you visualize what your Python program is spe

Ben Frederickson 9.5k Jan 08, 2023