瀏覽代碼

Merge pull request #533 from ilnytskyi/add-php-spx-profiler

Mark Shust 1 年之前
父節點
當前提交
f2b419bee8

+ 26 - 0
README.md

@@ -695,6 +695,32 @@ body {
 
 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.
 
+### PHP-SPX
+
+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>
+
+To access the control panel, just open the following URL: `https://magento.test/?SPX_UI_URI=/`
+
+**Suggested Configuration**
+
+- Enabled: Checked
+- Automatic start: Checked
+- Profile internal functions: Unchecked
+- Sampling: 5ms
+- Max profiling depth: Unlimited
+- Additional metrics: Unselected
+
+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.
+
+Profiling is also possible via command line, or curl:
+
+```
+SPX_REPORT=full SPX_ENABLED=1 SPX_SAMPLING_PERIOD=5000 bin/magento {command_name}
+curl --cookie "SPX_REPORT=full; SPX_ENABLED=1; SPX_SAMPLING_PERIOD=5000" https://magento.test/
+```
+
+Additional information of how to work with SPX is available at https://www.youtube.com/watch?v=xk-JiBLsKfA
+
 ## Credits
 
 ### M.academy

+ 9 - 0
images/php/8.1/Dockerfile

@@ -37,6 +37,7 @@ RUN apt-get update && apt-get install -y \
     strace \
     vim \
     zip \
+    zlib1g-dev \
   && rm -rf /var/lib/apt/lists/*
 
 RUN pecl channel-update pecl.php.net && pecl install \
@@ -84,10 +85,18 @@ RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
     && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
     && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
 
+RUN git clone --branch v0.4.15 --depth=1 https://github.com/NoiseByNorthwest/php-spx.git /usr/lib/php-spx \
+    && cd /usr/lib/php-spx \
+    && phpize \
+    && ./configure \
+    && make \
+    && make install
+
 RUN curl -sS https://getcomposer.org/installer | \
   php -- --install-dir=/usr/local/bin --filename=composer
 
 COPY conf/blackfire.ini $PHP_INI_DIR/conf.d/blackfire.ini
+COPY conf/spx.ini $PHP_INI_DIR/conf.d/spx.ini
 COPY conf/msmtprc /etc/msmtprc
 COPY conf/php.ini $PHP_INI_DIR
 COPY conf/php-fpm.conf /usr/local/etc/

+ 3 - 0
images/php/8.1/conf/php-fpm.conf

@@ -29,3 +29,6 @@ clear_env = no
 
 ; Ensure worker stdout and stderr are sent to the main error log.
 catch_workers_output = yes
+
+; This needed to make PHP-SPX work in fpm mode.
+process.dumpable = yes

+ 1 - 1
images/php/8.1/conf/php.ini

@@ -1,6 +1,6 @@
 memory_limit = 4G
 max_execution_time = 1800
-zlib.output_compression = On
+zlib.output_compression = 1
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 

+ 7 - 0
images/php/8.1/conf/spx.ini

@@ -0,0 +1,7 @@
+zlib.output_compression = 0
+
+extension = /usr/lib/php-spx/modules/spx.so
+spx.http_enabled = 1
+spx.http_key = "dev"
+spx.http_ip_whitelist = "*"
+spx.data_dir = /var/www/spx_dumps

+ 9 - 0
images/php/8.2/Dockerfile

@@ -37,6 +37,7 @@ RUN apt-get update && apt-get install -y \
     strace \
     vim \
     zip \
+    zlib1g-dev \
   && rm -rf /var/lib/apt/lists/*
 
 RUN pecl channel-update pecl.php.net && pecl install \
@@ -84,10 +85,18 @@ RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
     && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
     && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz
 
+RUN git clone --branch v0.4.15 --depth=1 https://github.com/NoiseByNorthwest/php-spx.git /usr/lib/php-spx \
+    && cd /usr/lib/php-spx \
+    && phpize \
+    && ./configure \
+    && make \
+    && make install
+
 RUN curl -sS https://getcomposer.org/installer | \
   php -- --install-dir=/usr/local/bin --filename=composer
 
 COPY conf/blackfire.ini $PHP_INI_DIR/conf.d/blackfire.ini
+COPY conf/spx.ini $PHP_INI_DIR/conf.d/spx.ini
 COPY conf/msmtprc /etc/msmtprc
 COPY conf/php.ini $PHP_INI_DIR
 COPY conf/php-fpm.conf /usr/local/etc/

+ 3 - 0
images/php/8.2/conf/php-fpm.conf

@@ -29,3 +29,6 @@ clear_env = no
 
 ; Ensure worker stdout and stderr are sent to the main error log.
 catch_workers_output = yes
+
+; This needed to make PHP-SPX work in fpm mode.
+process.dumpable = yes

+ 1 - 1
images/php/8.2/conf/php.ini

@@ -1,6 +1,6 @@
 memory_limit = 4G
 max_execution_time = 1800
-zlib.output_compression = On
+zlib.output_compression = 1
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 

+ 7 - 0
images/php/8.2/conf/spx.ini

@@ -0,0 +1,7 @@
+zlib.output_compression = 0
+
+extension = /usr/lib/php-spx/modules/spx.so
+spx.http_enabled = 1
+spx.http_key = "dev"
+spx.http_ip_whitelist = "*"
+spx.data_dir = /var/www/spx_dumps