tracing.rs Library
This library implements a backend for the popular rust tracing framework tracing.rs (opens new window) to directly stream data to Modality. It provides a tracing.rs Layer
to process trace data. The library reference documentation can be found here. (opens new window)
# Integration Steps
- Add
tracing-modality
to yourcargo.toml
dependencies. - Use
TracingModality::init()
(opens new window) to registerTracingModality
as the global default tracer.- Note that
TracingModality
requires a Modality auth token. It will either read one from the default location (~/.config/modality_cli/.user_auth_token
) or you can provide one in anOptions
struct (opens new window) and use theinit_with_options()
function. (opens new window) - You may also need to configure the URL where
TracingModality
will send data. You can do this by setting the server address (opens new window) and usinginit_with_options()
. (opens new window)
- Note that
- Record trace data with
tracing.rs
macros. - Use the
modality
CLI to explore the data you have collected.modality log
is a good place to get started viewing data.
# Concepts
This library was built with multi-threaded applications in mind. As such, it automatically creates a timeline per OS thread in your application. If, when you spawn a thread, you give it a name, that name will automatically be used as the name of the timeline.
To record interactions between timelines, use the special attributes. The library automatically generates a logical time for each event but these logical times are not currently exposed to user code. You should therefore generate a nonce for each interaction and use the event.nonce
and event.interaction.remote_nonce
attributes. You can get the timeline ID for a thread with the timeline_id()
function. (opens new window)
# Reference
See the rust docs (opens new window) for the API reference and more information about how the library interfaces with Modality. Examples can be found in the github repository. (opens new window)