···11+# Blackfire profiler {#module-services-blackfire}
22+33+*Source:* {file}`modules/services/development/blackfire.nix`
44+55+*Upstream documentation:* <https://blackfire.io/docs/introduction>
66+77+[Blackfire](https://blackfire.io) is a proprietary tool for profiling applications. There are several languages supported by the product but currently only PHP support is packaged in Nixpkgs. The back-end consists of a module that is loaded into the language runtime (called *probe*) and a service (*agent*) that the probe connects to and that sends the profiles to the server.
88+99+To use it, you will need to enable the agent and the probe on your server. The exact method will depend on the way you use PHP but here is an example of NixOS configuration for PHP-FPM:
1010+```
1111+let
1212+ php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [
1313+ blackfire
1414+ ]));
1515+in {
1616+ # Enable the probe extension for PHP-FPM.
1717+ services.phpfpm = {
1818+ phpPackage = php;
1919+ };
2020+2121+ # Enable and configure the agent.
2222+ services.blackfire-agent = {
2323+ enable = true;
2424+ settings = {
2525+ # You will need to get credentials at https://blackfire.io/my/settings/credentials
2626+ # You can also use other options described in https://blackfire.io/docs/up-and-running/configuration/agent
2727+ server-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
2828+ server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
2929+ };
3030+ };
3131+3232+ # Make the agent run on start-up.
3333+ # (WantedBy= from the upstream unit not respected: https://github.com/NixOS/nixpkgs/issues/81138)
3434+ # Alternately, you can start it manually with `systemctl start blackfire-agent`.
3535+ systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ];
3636+}
3737+```
3838+3939+On your developer machine, you will also want to install [the client](https://blackfire.io/docs/up-and-running/installation#install-a-profiling-client) (see `blackfire` package) or the browser extension to actually trigger the profiling.
+2
nixos/modules/services/development/blackfire.nix
···1111in {
1212 meta = {
1313 maintainers = pkgs.blackfire.meta.maintainers;
1414+ # Don't edit the docbook xml directly, edit the md and generate it:
1515+ # `pandoc blackfire.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart --lua-filter ../../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua --lua-filter ../../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua > blackfire.xml`
1416 doc = ./blackfire.xml;
1517 };
1618
+34-23
nixos/modules/services/development/blackfire.xml
···11-<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="module-services-blackfire">
22- <title>Blackfire profiler</title>
33- <para>
44- <emphasis>Source:</emphasis>
55- <filename>modules/services/development/blackfire.nix</filename>
66- </para>
77- <para>
88- <emphasis>Upstream documentation:</emphasis>
99- <link xlink:href="https://blackfire.io/docs/introduction"/>
1010- </para>
1111- <para>
1212- <link xlink:href="https://blackfire.io">Blackfire</link> is a proprietary tool for profiling applications. There are several languages supported by the product but currently only PHP support is packaged in Nixpkgs. The back-end consists of a module that is loaded into the language runtime (called <emphasis>probe</emphasis>) and a service (<emphasis>agent</emphasis>) that the probe connects to and that sends the profiles to the server.
1313- </para>
1414- <para>
1515- To use it, you will need to enable the agent and the probe on your server. The exact method will depend on the way you use PHP but here is an example of NixOS configuration for PHP-FPM:
1616-<programlisting>
11+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="module-services-blackfire">
22+ <title>Blackfire profiler</title>
33+ <para>
44+ <emphasis>Source:</emphasis>
55+ <filename>modules/services/development/blackfire.nix</filename>
66+ </para>
77+ <para>
88+ <emphasis>Upstream documentation:</emphasis>
99+ <link xlink:href="https://blackfire.io/docs/introduction" role="uri">https://blackfire.io/docs/introduction</link>
1010+ </para>
1111+ <para>
1212+ <link xlink:href="https://blackfire.io">Blackfire</link> is a
1313+ proprietary tool for profiling applications. There are several
1414+ languages supported by the product but currently only PHP support is
1515+ packaged in Nixpkgs. The back-end consists of a module that is
1616+ loaded into the language runtime (called <emphasis>probe</emphasis>)
1717+ and a service (<emphasis>agent</emphasis>) that the probe connects
1818+ to and that sends the profiles to the server.
1919+ </para>
2020+ <para>
2121+ To use it, you will need to enable the agent and the probe on your
2222+ server. The exact method will depend on the way you use PHP but here
2323+ is an example of NixOS configuration for PHP-FPM:
2424+ </para>
2525+ <programlisting>
1726let
1827 php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [
1928 blackfire
···3039 settings = {
3140 # You will need to get credentials at https://blackfire.io/my/settings/credentials
3241 # You can also use other options described in https://blackfire.io/docs/up-and-running/configuration/agent
3333- server-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
3434- server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
4242+ server-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
4343+ server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
3544 };
3645 };
37463847 # Make the agent run on start-up.
3948 # (WantedBy= from the upstream unit not respected: https://github.com/NixOS/nixpkgs/issues/81138)
4049 # Alternately, you can start it manually with `systemctl start blackfire-agent`.
4141- systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ];
5050+ systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ];
4251}
4352</programlisting>
4444- </para>
4545- <para>
4646- On your developer machine, you will also want to install <link xlink:href="https://blackfire.io/docs/up-and-running/installation#install-a-profiling-client">the client</link> (see <literal>blackfire</literal> package) or the browser extension to actually trigger the profiling.
4747- </para>
5353+ <para>
5454+ On your developer machine, you will also want to install
5555+ <link xlink:href="https://blackfire.io/docs/up-and-running/installation#install-a-profiling-client">the
5656+ client</link> (see <literal>blackfire</literal> package) or the
5757+ browser extension to actually trigger the profiling.
5858+ </para>
4859</chapter>