#ffi #tracing #profiling


Simple forwarding tracing subscriber for a FFI host profiler

3 unstable releases

0.2.0 Jul 19, 2023
0.1.1-pre1 Jun 1, 2022
0.1.0 May 24, 2022

#779 in Text processing

Download history 49/week @ 2023-10-29 4/week @ 2023-11-05 7/week @ 2023-11-12 10/week @ 2023-11-19 12/week @ 2023-11-26 11/week @ 2023-12-03 10/week @ 2023-12-10 4/week @ 2023-12-17 7/week @ 2023-12-24 9/week @ 2024-01-07 4/week @ 2024-01-14 8/week @ 2024-01-21 29/week @ 2024-01-28 5/week @ 2024-02-04 41/week @ 2024-02-11

83 downloads per month


275 lines

⏱️ tracing-ext-ffi-subscriber

Subscriber for passing spans from a rust library to a profiling tool in a host application via FFI.

Embark Embark Crates.io Docs dependency status Build status

A simple crate for passing spans generated by the tracing ecosystem to a C or C++ profiling system when Rust is integrated into an existing framework. To help with integration into other tools you can use the environment variable TRACING_FFI_RELATIVE_OUT_DIR to configure where the include file ends relative to the build output (OUT_DIR). For example, TRACING_FFI_RELATIVE_OUT_DIR = "../../../../../include" will normally lead to the files being generated in an include dir next to your Cargo.toml.

Example usage

#include <Profiling.h>
#include <tracing_ffi.h>
#include <myrustlib.h>

int main(int argc, const char* argv[]) {
    tracing_ffi_ReturnCode result = tracing_ffi_install_global_with_enable(

    if (result != tracing_ffi_ReturnCode_Success) {
        return (int)result;

    myrustlib_execute(10, 20);


You can of course also configure this from Rust code; and bypass the C-api. In that case, use subscriber::ExternFFISpanSubscriber directly, and install with your preferred tracing method.


Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started. Please also read our Contributor Terms before you make any contributions.

Any contribution intentionally submitted for inclusion in an Embark Studios project, shall comply with the Rust standard licensing model (MIT OR Apache 2.0) and therefore be dual licensed as described below, without any additional terms or conditions:


This contribution is dual licensed under EITHER OF

at your option.

For clarity, "your" refers to Embark or any other licensee/user of the contribution.


~39K SLoC