https://github.com/badoo/funcmap
PHP extension that logs all called userspace functions/methods
https://github.com/badoo/funcmap
Last synced: about 1 year ago
JSON representation
PHP extension that logs all called userspace functions/methods
- Host: GitHub
- URL: https://github.com/badoo/funcmap
- Owner: badoo
- License: other
- Created: 2020-02-14T10:02:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-06T02:17:32.000Z (over 2 years ago)
- Last Synced: 2024-04-20T17:45:50.956Z (about 2 years ago)
- Language: C
- Size: 20.5 KB
- Stars: 39
- Watchers: 12
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## funcmap PHP extension
Problem: how to detect unused/dead legacy functions in production code?
Solution: collect all the functions that ARE used and remove them from the list of functions available. What's left is unused.
funcmap is a simple PHP extension that collects names of all userspace functions that's been called and writes them down to a text file from time to time.
To reduce the resource usage, you can limit the probability of that event.
## Configuration
* **funcmap.enabled bool** (PHP\_INI\_SYSTEM) - enable/disable the extension. The extension won't do anything at all if this setting is set to false. Default value: false
* **funcmap.logfile string** (PHP\_INI\_ALL) - path to the logfile. File must be writable by PHP process user, otherwise you'll get an error in the logs. The filename may contain '%pid%' pattern, so that each child could write to its own file. Adding the '%pid%' pattern is strongly recommended for multiprocess PHP installations, otherwise you'll most likely end up with garbage results. Default value: ""
* **funcmap.probability int** (PHP\_INI\_SYSTEM) - enable data collection with this probability. This is probablity in percents, so any valuu greater than 100 will be treated as 100, i.e. "always enabled". Setting it to a value <= 0 will result in no data being written ever. Default value: 100
* **funcmap.flush\_interval\_sec int** (PHP\_INI\_ALL) - write collected data to the disk each N seconds (and on process shutdown). Zero value means "write on process shutdown only" (PHP-FPM processes are shut down, for example, when they reach their request limit). Default value: 0
## Example configuration
```
funcmap.enabled=1 # enable the extension
funcmap.logfile=/tmp/logs/funcmap_%pid%.log # each PHP process writes to its own log file
funcmap.flush_interval_sec=200 # write data each 200 seconds if the process lives longer than that
funcmap.probability=2 # collect data for 2% script executions only
```