The Medooze media server is being instrumented with Perfetto, a production grade tracing SDK. Tracing can help you find bottlenecks in the media server pipeline as well as debug a range of issues.
At the time of this writing, Perfetto seems to be aimed at application binaries and there isn't a clear, documented way for libraries to provide instrumentation.
However it is supported to some degree. Therefore, the current approach is:
-
The media server itself doesn't expose any tracing APIs. The code is only instrumented with the appropriate macros to:
- record events (
TRACE_EVENT
and siblings) - register categories and its static storage, but in a different namespace so that the application can also define their own (see above)
- all categories have a
medooze.
prefix (can be overriden by definingMEDOOZE_TRACING_PREFIX
)
- all categories have a
- record events (
-
Such code is hidden behind a
MEDOOZE_TRACING
define. -
Applications wishing to use tracing need to:
- build Medooze with the define in place, supplying the tracing SDK as an include directory (so that
perfetto.h
can be included). - add
perfetto.cc
from that directory to the source list - initialize the tracing SDK
- register Medooze's TrackEvent data source by calling
MedoozeTrackEventRegister()
from theMedoozeTracing.h
header
- build Medooze with the define in place, supplying the tracing SDK as an include directory (so that
This gives the most control to final applications and lets them add their own events into the trace as well.
Unfortunately we are currently unable to guarantee stability with respect to the instrumentation code. In practice, the main user for the tracing is going to be the Node.js addon, see Tracing there for more info.
There's some set of guidelines that should be respected for consistency:
- For events that span (almost) a whole function, event names are the method path (i.e.
EventLoop::Run
if it's theRun
method in classEventLoop
) - For events that span part of a function, append another token to the path (i.e.
EventLoop::Run::ProcessIn
) but just one, no nesting (if an event spans part of theProcessIn
slice, it would beEventLoop::Run::DequeueIn
notEventLoop::Run::ProcessIn::Dequeue
)