<p>I have a microservice written in Haskell, the compiler is 8.8.3.
I built it with <code>--profile</code> option and ran it with <code>+RTS -p</code>. It is running about 30 minutes, there is <code>&lt;my-service&gt;.prof</code> file but it is empty (literally 0 bytes). Previously I did it on my local machine and I stop the service with CTRL-C and after the exit it produced <code>&lt;my-service&gt;.prof</code> file which was not empty.</p>
<p>So, I have 2 questions:</p>
<ol>
<li>How to collect profiling information when a Haskell microservice runs under Kubernetes in the most correct way (to be able to read this .prof file)?</li>
<li>How to pass run time parameter to Haskell run-time where to save this .prof file (maybe some workaround if no such an option), for 8.8.3 - because I have feeling that the file may be big and I can hit disk space problem. Also I don't know how to flush/read/get this file while microservice is running. I suppose if I will be able to pass full path for this .prof file then I can save it somewhere else on some permanent volume, to &quot;kill&quot; the service with <code>INT</code> signal for example, and to get this .prof file from the volume.</li>
</ol>
<p>What is the usual/convenient way to get this .prof file when the service runs in Kubernetes?</p>
<p>PS. I saw some relevant options in the documentation for newest versions, but I am with 8.8.3</p>

RandomB
<p>I think the only way to do live profiling with GHC is to use the eventlog. You can insert <code>Debug.Trace.traceEvent</code> into your code at the functions that you want to measure and then compile with <code>-eventlog</code> and run with <code>+RTS -l -ol &lt;output-file-name&gt; -RTS</code>. You can use <a href="https://hackage.haskell.org/package/ghc-events-analyze" rel="nofollow noreferrer"><code>ghc-events-analyze</code></a> to analyze and visualize the produced eventlog.</p>
<p>The official eventlog documentation for GHC 8.8.3 is <a href="https://downloads.haskell.org/ghc/8.8.3/docs/html/users_guide/runtime_control.html#tracing" rel="nofollow noreferrer">here</a>.</p>
