The Linux Trace Toolkit Next Generation (LTTng) is a set of open source tools enabling you to simultaneously trace both user and kernel space. A bit ironically, tracing the kernel is easy, whereas tracing user space (apps, libraries, and even scripts) requires the developer to manually insert instrumentation (so-called tracepoints) into the application (the tracepoint instrumentation for the kernel is supplied by LTTng as kernel modules). The high-quality LTTng documentation is available online here: https://lttng.org/docs/v2.12/ (covering version 2.12 as of the time of writing).
We do not cover the installation of LTTng here; the details are available at https://lttng.org/docs/v2.12/#doc-installing-lttng. Once installed (it's kind of heavy – on my native x86_64 Ubuntu system, there are over 40 kernel modules loaded up pertaining to LTTng!), using LTTng - for a system-wide kernel session as we do here - is easy and...