Skip to content

Commit f2b419b

Browse files
authored
Merge pull request #533 from ilnytskyi/add-php-spx-profiler
2 parents defde77 + 5f063a3 commit f2b419b

File tree

9 files changed

+66
-2
lines changed

9 files changed

+66
-2
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,32 @@ body {
695695

696696
Upon saving this file, we will see the Grunt watcher detect the changes, and your browser should automatically load the new style without you needing to refresh the page, and without a full browser refresh.
697697

698+
### PHP-SPX
699+
700+
The images also have additional profiler-tracers built-in to the <a href="https://github.com/NoiseByNorthwest/php-spx/tree/master#web-ui" target="_blank">Web UI.</a>
701+
702+
To access the control panel, just open the following URL: `https://magento.test/?SPX_UI_URI=/`
703+
704+
**Suggested Configuration**
705+
706+
- Enabled: Checked
707+
- Automatic start: Checked
708+
- Profile internal functions: Unchecked
709+
- Sampling: 5ms
710+
- Max profiling depth: Unlimited
711+
- Additional metrics: Unselected
712+
713+
Changing any options on this page set cookies for the domain for these settings. After then visiting a page on the frontend, you can navigate back to the GUI and scroll to the bottom of the page, and click the related request to view the trace of the request & response.
714+
715+
Profiling is also possible via command line, or curl:
716+
717+
```
718+
SPX_REPORT=full SPX_ENABLED=1 SPX_SAMPLING_PERIOD=5000 bin/magento {command_name}
719+
curl --cookie "SPX_REPORT=full; SPX_ENABLED=1; SPX_SAMPLING_PERIOD=5000" https://magento.test/
720+
```
721+
722+
Additional information of how to work with SPX is available at https://www.youtube.com/watch?v=xk-JiBLsKfA
723+
698724
## Credits
699725

700726
### M.academy

images/php/8.1/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RUN apt-get update && apt-get install -y \
3737
strace \
3838
vim \
3939
zip \
40+
zlib1g-dev \
4041
&& rm -rf /var/lib/apt/lists/*
4142

4243
RUN pecl channel-update pecl.php.net && pecl install \
@@ -84,10 +85,18 @@ RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
8485
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
8586
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
8687

88+
RUN git clone --branch v0.4.15 --depth=1 https://github.com/NoiseByNorthwest/php-spx.git /usr/lib/php-spx \
89+
&& cd /usr/lib/php-spx \
90+
&& phpize \
91+
&& ./configure \
92+
&& make \
93+
&& make install
94+
8795
RUN curl -sS https://getcomposer.org/installer | \
8896
php -- --install-dir=/usr/local/bin --filename=composer
8997

9098
COPY conf/blackfire.ini $PHP_INI_DIR/conf.d/blackfire.ini
99+
COPY conf/spx.ini $PHP_INI_DIR/conf.d/spx.ini
91100
COPY conf/msmtprc /etc/msmtprc
92101
COPY conf/php.ini $PHP_INI_DIR
93102
COPY conf/php-fpm.conf /usr/local/etc/

images/php/8.1/conf/php-fpm.conf

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ clear_env = no
2929

3030
; Ensure worker stdout and stderr are sent to the main error log.
3131
catch_workers_output = yes
32+
33+
; This needed to make PHP-SPX work in fpm mode.
34+
process.dumpable = yes

images/php/8.1/conf/php.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
memory_limit = 4G
22
max_execution_time = 1800
3-
zlib.output_compression = On
3+
zlib.output_compression = 1
44
cgi.fix_pathinfo = 0
55
date.timezone = UTC
66

images/php/8.1/conf/spx.ini

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
zlib.output_compression = 0
2+
3+
extension = /usr/lib/php-spx/modules/spx.so
4+
spx.http_enabled = 1
5+
spx.http_key = "dev"
6+
spx.http_ip_whitelist = "*"
7+
spx.data_dir = /var/www/spx_dumps

images/php/8.2/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RUN apt-get update && apt-get install -y \
3737
strace \
3838
vim \
3939
zip \
40+
zlib1g-dev \
4041
&& rm -rf /var/lib/apt/lists/*
4142

4243
RUN pecl channel-update pecl.php.net && pecl install \
@@ -84,10 +85,18 @@ RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
8485
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
8586
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
8687

88+
RUN git clone --branch v0.4.15 --depth=1 https://github.com/NoiseByNorthwest/php-spx.git /usr/lib/php-spx \
89+
&& cd /usr/lib/php-spx \
90+
&& phpize \
91+
&& ./configure \
92+
&& make \
93+
&& make install
94+
8795
RUN curl -sS https://getcomposer.org/installer | \
8896
php -- --install-dir=/usr/local/bin --filename=composer
8997

9098
COPY conf/blackfire.ini $PHP_INI_DIR/conf.d/blackfire.ini
99+
COPY conf/spx.ini $PHP_INI_DIR/conf.d/spx.ini
91100
COPY conf/msmtprc /etc/msmtprc
92101
COPY conf/php.ini $PHP_INI_DIR
93102
COPY conf/php-fpm.conf /usr/local/etc/

images/php/8.2/conf/php-fpm.conf

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ clear_env = no
2929

3030
; Ensure worker stdout and stderr are sent to the main error log.
3131
catch_workers_output = yes
32+
33+
; This needed to make PHP-SPX work in fpm mode.
34+
process.dumpable = yes

images/php/8.2/conf/php.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
memory_limit = 4G
22
max_execution_time = 1800
3-
zlib.output_compression = On
3+
zlib.output_compression = 1
44
cgi.fix_pathinfo = 0
55
date.timezone = UTC
66

images/php/8.2/conf/spx.ini

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
zlib.output_compression = 0
2+
3+
extension = /usr/lib/php-spx/modules/spx.so
4+
spx.http_enabled = 1
5+
spx.http_key = "dev"
6+
spx.http_ip_whitelist = "*"
7+
spx.data_dir = /var/www/spx_dumps

0 commit comments

Comments
 (0)