If you were to build a large multi-purpose single deployable (as oppose to multiple fine grained deployables), what would you to get runtime stats (e.g. memory, CPU, locks) for each "component" within your app?
In Java world of yesteryear I would have exposed these via JMX and mbeans - I know tokio has its new console, and tracing is excellent, but these are all lower level than "components".
Do you end up rolling your own or is there an existing crate for this stuff?
Memory and CPU usage of individual components is going to be hard to measure accurately within a single process. As far as Rust and the OS are concerned, it's all the same code.
Rust libraries make great use of shared thread-pools, so even measuring individual threads may not be isolated enough.
I use cap to read currently allocated Rust memory, but that's a process-global counter.
For domain-specific components I rely more on DIY monitoring via custom counters and timing, and report them using prometheus.
I've also used a more specialized setup where a specific component had to be isolated from the rest (similar to how web browsers sandbox renderer), and that's doable with fork or Command + os_pipe sending bincode'd messages. This gives an opportunity to get per-process stats specific to the sandboxed component, but process isolation is a hassle.