If you are going to hard-code the information-gathering, you are going to end up creating a collection module anyway, so you might be better off using a mature well-tested library rather than rolling your own.
My idea of performance logging is that all of those statoshi metrics don't need to be tracked, all listed as a graph in
https://statoshi.info/, just the most important ones such as mempool size. This can be logged with a large interval and then written to disk while bitcoind is
poll()ing for a message to come.
Opentelemetry-cpp seems to be flexible in collecting metrics. I'm wondering if opentelemetry-cpp is stable and worth it...or maybe there's another way.
Whatever you do end up using, it had better lend itself easily to being included in automake/configure builds.