Yup. Not a difficult problem to solve.
In the code define everything as a span with a name, scope (start-end), description and tags... and then you can easily dynamically produce traces, spans, logs or metrics based on what you need.
At some point your monitoring is burning 10x as much CPU as the actual task...
At some point your monitoring is burning 10x as much CPU as the actual task...