tracing/tracing-attributes
Eliza Weisman ecdb675150
tracing: support no-std + alloc (#263)
## Motivation

Users have expressed interest in using `tracing` on no_std platforms
with `liballoc`. Now that `tracing-core` supports no_std (see #256), 
we can now add no_std support to `tracing` as well.

## Solution

This branch adds `no_std` support to `tracing` by adding a `std`
feature flag (on by default) which can be disabled to use `libcore` +
`liballoc` instead of `libstd`.

When the `std` feature is disabled, `tracing-core` will use
`spin::Once` rather than `std::sync::Once`, and the thread-local
scoped dispatcher will be disabled (since it necessitates a defined OS
threading model, which may not exist on `no_std` platforms).

Some tests, which rely on the thread-local dispatcher, are disabled when
the standard lib is disabled. The alternative is to use
`set_global_default` in those tests, which would necessitate placing
each test in its own separate file. Since the behavior being tested is
otherwise the same regardless of whether or not the standard library is
used, I opted to disable these tests instead.

Refs: #256
Closes: #213

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-09 17:11:07 -07:00
..

tracing-attributes

Macro attributes for application-level tracing.

Crates.io Documentation MIT licensed Build Status Gitter chat

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect structured, event-based diagnostic information. This crate provides the #[instrument] attribute for automatically instrumenting functions using tracing.

Note that this macro is also re-exported by the main tracing crate.

Usage

First, add this to your Cargo.toml:

[dependencies]
tracing-attributes = "0.1.0"

This crate provides the #[instrument] attribute for instrumenting a function with a tracing span. For example:

use tracing_attributes::instrument;

#[instrument]
pub fn my_function(my_arg: usize) {
    // ...
}

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tokio by you, shall be licensed as MIT, without any additional terms or conditions.