#tracing #logging #gstreamer #multimedia


Bridge between gstreamer and the tracing ecosystem

3 unstable releases

0.3.2 Feb 10, 2022
0.3.1 Feb 10, 2022
0.2.2 Feb 10, 2022
0.2.1 Sep 21, 2021
0.1.1 Aug 6, 2021

#73 in Debugging

Download history 37/week @ 2022-06-02 6/week @ 2022-06-09 5/week @ 2022-06-16 16/week @ 2022-06-23 19/week @ 2022-06-30 38/week @ 2022-07-07 142/week @ 2022-07-14 32/week @ 2022-07-21 7/week @ 2022-07-28 36/week @ 2022-08-04 17/week @ 2022-08-11 9/week @ 2022-08-18 19/week @ 2022-08-25 7/week @ 2022-09-01 31/week @ 2022-09-08 19/week @ 2022-09-15

76 downloads per month



This crate provides a bridge between gstreamer and the tracing ecosystem.

The goal is to allow Rust applications utilizing GStreamer to better integrate into application that otherwise use the tracing crate for their observability needs.



To output gstreamer log messages as tracing events, call the [integrate_events] function. Calling it before the call to any other gstreamer call (especially before the gstreamer::init) is most likely to correctly forward all of the messages:

// Set up the tracing subscriber.
// e.g. tracing_subscriber::fmt::init();


Keep in mind that both GST_DEBUG and tracing filters are in effect. The gstreamer side of filters can be relaxed from code via:


Similarly you can use tracing APIs to adjust the filters on the tracing side.


To provide tracing with more contextual information for some of the events, you can also enable support for generating spans via gstreamer's own tracing infrastructure.

This functionality can be enabled by calling the [integrate_spans] function. It must be called after gstreamer::init.


Subscriber showcase

This section demonstrates the results obtained with different kinds of subscribers.


This subscriber is a great replacement for the built-in gstreamer log handler. Here's an example of what the output might look like when using this subscriber:

$ env RUST_LOG=info cargo run --example videoenc
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/examples/videoenc`
Jan 01 00:00:00.000  INFO gstreamer::GST_INIT: Initializing GStreamer Core Library version 1.18.4
Jan 01 00:00:00.000  INFO gstreamer::GST_INIT: initialized GStreamer successfully
Jan 01 00:00:00.000  INFO gstreamer::GST_PIPELINE: parsing pipeline description '
        videotestsrc num-buffers=120
        ! vp9enc
        ! webmmux name=mux
        ! fakesink sync=false

        audiotestsrc num-buffers=120
        ! opusenc
        ! mux.

Certain messages may also provide more information than the built-in logger. While builtin logger does present you with the type and address of the object being logged, tracing-gstreamer may provide more readily useful information such as the element name:

Jan 01 00:00:00.000  INFO gstreamer::GST_STATES: completed state change to READY gobject.address=94331150660528 gobject.type="GstAudioTestSrc" gstobject.name="audiotestsrc0" gstelement.state="ready" gstelement.pending_state="void-pending"

or provide additional context via spans, which may help to figure out which element is logging the message when there is no other way to tell this otherwise, such as in this example:

Jan 01 00:00:00.000  INFO pad_push{gstpad.state={NEED_PARENT} gstpad.parent.name="audiotestsrc0"}: gstreamer::structure: Expected field 'channel-mask' in structure: audio/x-raw, rate=(int)48000, channels=(int)1, format=(string)S16LE, layout=(string)interleaved;


Tracy is a profiler focused primarily on game development workloads, but works fairly well for general purpose code as well. Tracy features a sampling profiler, but works best with applications that have manually instrumented points of interest. tracing is a great source of such manual instrumentation points and tracing-tracy is the bridge between the two. The following video demonstrates the videoenc example from this repository adapted to utilize the tracing-tracy subscriber.

In this video there are a couple of highlights

  • We can quickly see the amount of concurrency our pipeline enables (2 threads; perhaps adding some queues would help?)
  • Overall thread utilization (low for the audio portion and high for the video portion);
  • Investigate the performance of the specific elements and quickly find out why some of them are slow. For example the opusenc0 element sometimes takes an unusually long time because the downstream muxer already has a buffer queued at the time.

Similar results can be achieved with some other subscribers as well.


~158K SLoC