Expand description
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(
profiling_begin_named_scope,
profiling_end_named_scope,
profiling_is_enabled,
);
if (result != tracing_ffi_ReturnCode_Success) {
return (int)result;
}
myrustlib_execute(10, 20);
profiling_write_file("profile.json");
}
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.
Modules§
- subscriber
- The subscriber implementation provided by tracing-ext-ffi-subscriber.
Structs§
- Configuration
- Configuration used for setting up both tracing and events.
Enums§
- LogLevel
- Return
Code - Simple error codes used for FFI calls.
Functions§
- tracing_
ffi_ ⚠install_ global - Install the tracing hook globally with the provided enter and exit functions.
- tracing_
ffi_ ⚠install_ global_ with_ config - Install the tracing hook globally with the provided configuration.
- tracing_
ffi_ ⚠install_ global_ with_ enabled - Install the tracing hook globally with the provided enter, exit, and enabled functions.
Type Aliases§
- EndTrace
Scope Fn - Function to be called when exiting a tracing scope.
- IsEnabled
Fn - Function to call to check whether tracing is enabled.
- IsEvent
Enabled Fn - Function to call to check whether the provided level should be logged.
- OnEvent
Fn - Function called for each event.
- Optional
EndTrace Scope Fn - Optional
IsEnabled Fn - Optional
IsEvent Enabled Fn - Optional
OnEvent Fn - Optional
Start Trace Scope Fn - Start
Trace Scope Fn - Function to be called when entering a tracing scope.