PHPackages                             zoon/pyrospy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. zoon/pyrospy

ActiveProject[Debugging &amp; Profiling](/categories/debugging)

zoon/pyrospy
============

Adapter from phpspy to pyroscope

v2.5.0(7mo ago)2512.0k—5.5%3MITPHPPHP &gt;=8.1

Since Apr 27Pushed 7mo ago4 watchersCompare

[ Source](https://github.com/zoonru/pyrospy)[ Packagist](https://packagist.org/packages/zoon/pyrospy)[ RSS](/packages/zoon-pyrospy/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (11)Versions (16)Used By (0)

PyroSpy
=======

[](#pyrospy)

Adapter from [phpspy](https://github.com/adsr/phpspy) to [pyroscope.io](https://pyroscope.io)

About Us
--------

[](#about-us)

   [ ![zoon logo](https://camo.githubusercontent.com/e46a09eb9794b395e1d3e1c6c87b843e62920f8f14a75683f7da7cbbce4cae54/68747470733a2f2f636f6d70616e792e7a6f6f6e2e72752f696d616765732f6c6f676f2e737667) ](https://company.zoon.ru)   **[Zoon](https://zoon.ru/)** - it's international service, that helps local businesses grow. - We tell the audience about the services and products of companies
- We promote on dozens of sites: in the catalog on zoon.ru, on partner sites, on Yandex and Google maps
- We help business owners manage marketing from a single personal account

  Phpspy requirements
-------------------

[](#phpspy-requirements)

- `apt install binutils` for Ubuntu/Debian
- To use in docker container it must be `privileged` or with capability `SYS_PTRACE`

Parameters:
-----------

[](#parameters)

```
Usage:
  php pyrospy.php run [options]

Options:
  -s, --pyroscope=STRING     Url of the pyroscope server.
                             Example: https://your-pyroscope-sever.com

  -auth, --pyroscopeAuthToken=STRING
                             Pyroscope Auth Token.
                             Example: psx-BWlqy_dW1Wxg6oBjuCWD28HxGCkB1Jfzt-jjtqHzrkzI

  -m, --memory               Enable memory traces mode
                             Get memory usage from 'mem' tag and send average memory usage for trace group
                             Do not provide this option for CPU mode

  -a, --app=STRING           Name of app.
                             All samples will be saved under given app name.
                             Example: app

  -r, --rateHz=INT           Sample rate in Hz.
                             Used to convert number of samples to CPU time
                             [default: 100]

  -i, --interval=INT         Maximum time between requests to pyroscope server
                             [default: 10]

  -b, --batch=INT            Maximum number of traces in request to pyroscope server
                             [default: 250]

  -t, --tags=STRING=STRING   Add tags to samples. Use to filter data inside one app.
                             Example: host=server1; role=cli
                             (multiple values allowed)

  -p, --plugins=STRING       Load custom class to modify trace and phpspy comments/tags. Can be class or folder with classes.
                             Example: /zoon/pyrospy/app/Plugins/ClearEmptyTags.php
                             (multiple values allowed)

  -h, --help                 Display help for the given command.
                             When no command is given display help for the list command

```

Usage:
------

[](#usage)

```
phpspy --max-depth=-1 --time-limit-ms=59000 --threads=1024 --rate-hz=4 --buffer-size=65536 -J m -P '-x "php|php[0-9]\.[0-9]" | shuf' 2> error_log.log | php pyrospy.php run --pyroscope=https://pyroscope.yourdomain.com --rateHz=4 --app=testApp --tags=host=server39 --tags=role=cli

phpspy --max-depth=-1 --time-limit-ms=59000 --threads=100 --rate-hz=25 --buffer-size=65536 -J m -P '-x "php-fpm|php-fpm[0-9]\.[0-9]" | shuf' 2> error_log.log | php pyrospy.php run --pyroscope=https://pyroscope.yourdomain.com --rateHz=25 --app=testApp --tags=host=server39 --tags=role=web
```

### Memory profiling

[](#memory-profiling)

- add `--memory-usage` option to phpspy command to add current and maximum memory usage to tags
- add `--memory` option to pyrospy command to send average memory usage for traces instead of sum count

```
phpspy --max-depth=-1 --time-limit-ms=59000 --threads=1024 --memory-usage --rate-hz=4 --buffer-size=65536 -J m -P '-x "php|php[0-9]\.[0-9]" | shuf' 2> error_log.log | php pyrospy.php run --pyroscope=https://pyroscope.yourdomain.com --rateHz=4 --app=testAppMemory --tags=host=server39 --tags=role=cli --memory

phpspy --max-depth=-1 --time-limit-ms=59000 --threads=100 --memory-usage --rate-hz=25 --buffer-size=65536 -J m -P '-x "php-fpm|php-fpm[0-9]\.[0-9]" | shuf' 2> error_log.log | php pyrospy.php run --pyroscope=https://pyroscope.yourdomain.com --rateHz=25 --app=testAppMemory --tags=host=server39 --tags=role=web --memory
```

Tee can be used to get memory usage and cpu samples from same phpspy stdout

```
phpspy --max-depth=-1 --time-limit-ms=59000 --threads=1024 --memory-usage --rate-hz=4 --buffer-size=65536 -J m -P '-x "php|php[0-9]\.[0-9]" | shuf' 2> error_log.log | tee >(php pyrospy.php run --pyroscope=https://pyroscope.yourdomain.com --rateHz=4 --app=testAppMemory --tags=host=server39 --tags=role=cli --memory) >(php pyrospy.php run --pyroscope=https://pyroscope.yourdomain.com --rateHz=4 --app=testApp --tags=host=server39 --tags=role=cli) >/dev/null
```

### Plugins

[](#plugins)

1. Create `.php` plugin class. Put it in any place. Make sure it has `namespace Zoon\PyroSpy\Plugins;` and classname match filename.

```
