#bp3d #tracing-subscriber

bp3d-tracing

Tracing subscriber implementations for use with BP3D software. Supports traditional logging through bp3d-logger and supports remote profiling through TCP.

3 releases

1.0.0-alpha-2.0.0 Apr 27, 2022
1.0.0-alpha-1.0.1 Apr 25, 2022

#437 in Profiling

BSD-3-Clause

75KB
1K SLoC

logo

Tracing

Implementations of tracing Subscriber for use with BP3D software. Supports traditional logging through bp3d-logger and supports remote profiling through TCP.

Status

This crate is currently highly experimental and may not work on all systems. Currently, this is fully tested on macOS 12.3.1 only. It may work on other unix systems.

Additionally, this is currently broken on Windows systems.

Usage

In code

fn main() {
    let _guard = bp3d_tracing::initialize("my-application");
    //Application code using `tracing` or `log` utilities.
}

NOTE: this library uses threads to perform logging and profiling. As such you shouldn't call std::process::exit() without first dropping the _guard guard variable. Failing to do so will result in truncated logs with the logger backend and data loss with the profiler backend.

Running

To configure the behavior of bp3d-tracing some environment variables are used:

Name Type Possible values Behavior Default
PROFILER boolean 1, 0, true, false, on, off Enables remote profiling. off
LOG enum trace, debug, info, warning, error Maximum log level for logger backend. info
LOG_DISABLE boolean 1, 0, true, false, on, off Disables the logger backend. off
LOG_STDOUT boolean 1, 0, true, false, on, off Always print log messages to stdout. off
LOG_COLOR boolean 1, 0, true, false, on, off Enables color output. isatty

On systems where configuring environment variables is not expected or too complicated, this library supports bp3d-env.

bp3d-env supports loading files as fallback to environment variables. This library appends the following default path to bp3d-env bp3d-fs::App::new("my-application").get_documents()?.join("environment") which corresponds to the following paths:

OS Path
macOS ~/Library/Application Support/my-application/Documents/environment
Linux ~/.local/share/my-application/Documents/environment
Windows %APPDATA%/my-application/Documents/environment
iOS Files App/my-application/environment

Dependencies

~7–22MB
~275K SLoC