Hi!
How does one sets up tracing for a future short-lived process pid, that doesn’t exist yet? Ideally, on a live production system, without direct code modification & in-memory module reloading.
For context, I am looking for a way to collect some debug info (function calls, arguments passed & values returned) when processing an HTTP request coming from a particular customer.
I am naively thinking something like this should be possible by OTP tracing capabilities:
- when process handling an HTTP request reaches a function X such that returned an ID of a client made the HTTP request,
- stop execution of a process,
- run my code which will create a [trace session](trace — kernel v10.5) for just current pid and enable extensive (and expensive) tracing on all functions that belong to my application,
- resume execution of a process,
- info is collected, I can proceed with analysis - offline.
Can the above steps be expressed by just calling a bunch functions in a remote shell, while connecting to a production app?
I think I could probably add a bit of extra no-op-like code to achieve exactly this:
- store customer ID globally (for example, using
etsorpersistent_term), - somewhere in the HTTP request processing path, have code that would run an
ifto determine if a tracing session should be created, and if so, create an enable desired tracing,
But I was curious if there’s a way to achieve this without permanently adding any code upfront.
Purpose of this is first and foremost to aid my understanding about tracing capabilities & limitations of of OTP. But I am also considering creating an internal tool in my company’s project, such that would help us debug problems that occur during HTTP interaction faster.
P.S. For context, my app is written in Elixir & uses Bandit web server.