33 Commits

Author SHA1 Message Date
David Barsky
c38c247f53 chore: publish docs tracing for master + PR branches (#322)
chore: build and publish documentation for each branch.

This commit introduces support for:
- building and deploying documentation for the master branch
- building and deploying (preview) documentation for each pull request
  and for each PR
- adds a link in `README.md` pointing to the generated documentation
  for the master branch
- notes the per-PR documentation previews in `CONTRIBUTING.md`

Closes #210
2019-09-04 12:51:30 -07:00
Eliza Weisman
215d0efdbf
core: prepare to release 0.1.5 (#287)
* core: remove `local_inner_macros`

This is unnecessary as we no longer support Rust 1.26

* core: prepare to release 0.1.5

Added:

- `std::error::Error` as a new primitive `Value` type (#277)
- `Event::new` and `Event::new_child_of` to manually construct `Event`s (#281)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-16 16:27:33 -07:00
Eliza Weisman
f6a375e29d
core: add std::error::Error as a new primitive type (#277)
## Motivation

Currently, errors are typically recorded using their `fmt::Display` or
`fmt::Debug` implementations. This doesn't give the subscriber much
control over how the error is recorded --- in particular, it cannot
decide whether to format the error using `Display` or `Debug`, and it
cannot access the error's `source` or downcast it to another error type.
The `std::error::Error` type is implemented by a majority of errors in
both the standard library and in most crates, so its use is fairly
widespread.

## Solution

This commit adds `dyn std::error::Error + 'static` as a new primitive
type. The `'static` bound is included so that the error can be downcast.

Closes: #222

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-15 08:44:10 -07:00
Eliza Weisman
59b57ae7a7
core: allow manually constructing events (#281)
## Motivation

Now that `tracing-subscriber` supports `Layer`ing subscribers, there is
a compelling use-case for constructing events without immediately
dispatching them to the default subscriber. In particular, this can be
used by a layer that aggregates or rolls up events and forwards those
aggregates to the root subscriber.

## Solution

This branch adds `new` and `new_child_of` functions to `Event`.

Fixes: #90 

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-14 15:39:20 -07:00
Eliza Weisman
562bca3c53
core: prepare to release 0.1.4 (#261)
Changes:

### Added

- Support for `no-std` + `liballoc` (#256)

### Fixed

- Broken links in RustDoc (#259)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-09 16:26:52 -07:00
Eliza Weisman
cf0ea3c07b
core: minor doc fixes (#259)
This branch makes some minor tweaks to the `tracing-core` RustDoc,
including fixing some broken links, and using `#[doc(inline)]` on some
of the more important re-exports so they're highlighted front and centre
in the docs.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-09 15:50:50 -07:00
Eliza Weisman
2572f68339
core: support no-std + alloc (#256)
* core: support `no-std` + `alloc`

Motivation

Users have expressed interest in using `tracing` on no_std platforms
with `liballoc`.

Solution

This branch adds `no_std` support to `tracing-core` 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::Mutex` rather than `std::sync::Mutex`, 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).

Refs: #213

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-09 13:27:35 -07:00
Eliza Weisman
069c43b268 core: adopt Rust 2018 edition idioms
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-08 16:30:33 -07:00
Eliza Weisman
375188c27f core: prepare to release 0.1.3
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-08 16:30:33 -07:00
Eliza Weisman
895596fb38
meta: README and badges tweaks (#214)
This branch makes a few small README and Cargo.toml changes:
* Add Azure Pipelines build status badges to Cargo.tomls
* Change README build status badges to Azure Pipelines
* Add "maintenance: experimental" badges to unreleased crates
* Link to `tracing` docs and crates.io page in the root README, 
  rather than `tracing-core`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-23 14:53:46 -07:00
Alexis Mousset
0a5ba16c5f core: add a FromStr implementation for Level (#195)
## Motivation

As mentioned in #189, having a `FromStr` implementation for `Level`
could be useful for various cases (the first one being level parsing for
`fmt` filters).

We will be able to use it in the filter parser once it is released, with
something like:

```rust
        fn parse_level(from: &str) -> Option<LevelFilter> {
            from.parse::<Level>()
                .ok()
                .map(LevelFilter::Level)
                .or_else(|| match from {
                    // Handle special values that are not levels but make sense as filters
                    "0" | "off" => Some(LevelFilter::Off),
                    "" => Some(LevelFilter::Level(Level::ERROR)),
                    _ => None,
                })
        }
```
2019-07-17 16:50:57 -07:00
Alexis Mousset
93269d881b core: add a Display implementation for Level (#194)
## Motivation

Provide a way to get a clean display of a `Level`. It uses the same
strings as displayed in fmt.

Closes: #189
2019-07-17 14:43:24 -07:00
Eliza Weisman
ebacde012f
core: prepare to release 0.1.2 (#173)
# 0.1.2 (July 10, 2019)

### Deprecated

- `Subscriber::drop_span` in favor of new `Subscriber::try_close` (#168)

### Added

- `Into<Option<&Id>>`, `Into<Option<Id>>`, and
  `Into<Option<&'static Metadata<'static>>>` impls for `span::Current` (#170)
- `Subscriber::try_close` method (#153)
- Improved documentation for `dispatcher` (#171)

* core: update changelog for 0.1.2
* core: update version to 0.1.2

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-10 16:25:18 -07:00
Eliza Weisman
e5994dfff1
core: update dispatcher documentation (#171)
## Motivation

The `tracing-core::dispatcher` module is currently somewhat
under-documented, which has caused confusion for many users. There
should be a detailed description of how traces are dispatched, and the
different methods of setting a default subscriber. In addition, the
`tokio` feature flag that enables automatic dispatcher propagation is
undocumented, which has also caused issues (see  #169).

## Solution

This branch adds new module-level docs to the `dispatcher` module,
including examples of how default subscribers are set. It also corrects
a factual error in the documentation for `with_default`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-10 15:47:35 -07:00
Eliza Weisman
0fe4d78d9f
core: deprecate drop_span (#168)
As discussed in [PR 149], we determined that the `Subscriber::drop_span`
method should be deprecated in favour of `try_close`. This commit
deprecates it.

[PR 149]: https://github.com/tokio-rs/tracing/pull/149#discussion_r300802298

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-10 13:30:04 -07:00
Eliza Weisman
3c17140958
core: add Into impls for span::Current (#170)
This commit adds implementations of `Into<Option<Id>>`,
`Into<Option<&'a Id>>`, and `Into<Option<&'static Metadata<'static>>>`.
These should make using `span::Current` with functions like
`Span::record_follows_from` in `tracing` more fluid.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-10 13:29:45 -07:00
Eliza Weisman
417384452a
core: add Subscriber::try_close (#153)
## Motivation

As discussed in #136, a proposed `Layer` trait for composing subscribers
required should probably _not_ be responsible for managing ref-counts
and determining span closures. Instead, the root subscriber should be
responsible for this, and `Layer`s should be able to opt into a callback
that's notified _when_ a span is closed. 

Adding a callback that's called on closure to `Layer` requires modifying
the `Subscriber` trait to allow indicating when a span closes.

## Solution

This branch attempts to do this without a breaking change, by adding a
new `try_close` trait method to `Subscriber`. `try_close` is identical
to `drop_span` except that it returns a boolean value, set to `true` if
the span has closed. 

The `try_close` default implementation simply calls
`self.drop_span(...)` and returns `false`, so that if subscribers don't
care about tracking ref counts, close notifications will never be
triggered. 

The `drop_span` documentation now indicates that it is "soft deprecated"
similarly to `std::error::Error`'s `description` method. This encourages
subscribers to implement the new API, but isn't a breaking change.
Existing _callers_ of `drop_span` are still able to call it without
causing issues. A subsequent PR will mark `drop_span` as deprecated
in favour of `try_close`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-09 12:39:47 -07:00
Eliza Weisman
cdce7437dc
core: prepare for 0.1.1 (#155)
This branch prepares `tracing-core` to release v0.1.1, and makes a few
minor README and crates.io metadata improvements.

Changelog:

### Added

- `Subscriber::current_span` API to return the current span (#148).
- `span::Current` type, representing the `Subscriber`'s view of the current
  span (#148).

### Fixed

- Typos and broken links in documentation (#123, #124, #128, #154)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-06 11:18:03 -07:00
Eliza Weisman
ba841c7588
core: add missing "and" (#154)
This fixes a typo in the `tracing-core` rustdoc. Thanks @jonhoo.


Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-06 10:17:21 -07:00
Eliza Weisman
b9dffecddf
core: add Subscriber::current_span (#148)
## Motivation

In many cases, it is valuable to be able to get the ID and metadata of
the span that the subscriber considers to be "current". This makes
propagating the span across easier, which is vital in cases such as
`tower-buffer`.

## Solution

This branch adds a new type to `tracing-core::span` representing a
subscriber's view of the current span. This type can indicate that there
is no current span, that the subscriber does not track the current span,
or it can contain the current span's ID and metadata. A new method
`current_span` is added to the `Subscriber` trait that returns this
current span type. In order to avoid a breaking change,
`Subscriber::current_span` has a default implementation that returns a
value indicating that the current span is not tracked by the subscriber.

A new `Span::current` function is added to `tracing::Span` that uses the
`tracing-core` API to return a handle to the current span. This is the
primary way users are expected to interact with this feature.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-05 18:32:16 -07:00
Eliza Weisman
872d893333
chore: remove remaining references to tracing-nursery (#144)
This branch removes all remaining references to the
non-existent `tracing-nursery` repository that weren't
removed in #142 and #141.

Closes #125 

* chore: remove nursery mentions from .github
* core: remove references to `tracing-nursery`

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-03 13:27:33 -07:00
Eliza Weisman
7ba800e872
chore: add edition = "2018 to Cargo.tomls (#132)
## Motivation

#122 updated all crates to use Rust 2018 syntax, but I neglected to add
`edition = "2018"` to the `Cargo.toml`s. 

## Solution

This fixes that.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-01 13:34:08 -07:00
Bruce Mitchener
9936b55a61 Fix typos. (#128) 2019-07-01 10:14:14 -07:00
Bruce Mitchener
90b0c6b347 misc: clippy fixes (#126) 2019-06-30 21:26:15 -04:00
Bruce Mitchener
668fc877a6 docs: fix typos (#124) 2019-06-30 21:08:36 -04:00
Eliza Weisman
16c351abde
chore: update all crates to 2018 edition (#122)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-29 22:20:03 -07:00
Bruce Mitchener
f409001ac8 tracing-core: Fix repository link. (#123)
This was still linking to the Tokio repository rather than the
tracing repository.
2019-06-29 21:05:56 -07:00
Eliza Weisman
f5a752f982
tracing: pre-0.1 docs updates (#119)
This branch makes several tweaks and improvements to the `tracing` API
docs and READMEs. I've fixed some broken links in the API docs, tweaked
some wording and added more detail based on some of @jonhoo's earlier
suggestions. Additionally, I've added additional Cargo metadata and
added more links in the READMEs.

Co-Authored-By: Jon Gjengset <jon@thesquareplanet.com>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-28 14:01:26 -07:00
Eliza Weisman
3829901112
core: prepare v0.1.0 release (#112)
0.1.0 (June 27, 2019)

- Initial release

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-27 15:58:41 -07:00
Eliza Weisman
ed06a4ff47
fix html_root_url 2019-06-27 15:38:09 -07:00
Eliza Weisman
2ea0cceca5
core: change Span and Event metadata to be 'static (#110)
## Motivation

Currently, the `span::Attributes` type in `tokio-trace-core` contains a
reference to `Metadata` with a generic lifetime `'a`. This means that if
a `Subscriber` wishes to store span metadata, it cannot simply store a
`&'static Metadata<'static>`. Instead, it must extract the individual
components from the metadata and store them in its own structure. In
addition, while the `name` and `FieldSet` in a `Metadata` are always
`'static`, the target and file path are not.  If the `Subscriber` needs
to store those values, they must be cloned into a `String` on the heap.

This is somewhat unergonomic for subscriber implementors, in comparison
to being able to use a `&'static Metadata<'static>` reference. In
addition, it implies additional overhead when using certain parts of a
span's metadata.

## Solution

This branch changes the `Metadata` fields in `Event` and `Attributes` to
be `'static`, and `Subscriber::register_callsite` to take an
`&'static Metadata<'static>`. Unlike PR #108, this branch leaves
`Metadata` generic over a lifetime, and `Subscriber::enabled` takes an
`&'a Metadata<'a>`.

Since subscribers are provided all span metadata as a static reference
in both `register_callsite` and `new_span`, they can clone _those_
static references, but `Subscriber::enabled` can still be called with
`Metadata` constructed from a `log::Record`. This means that log records
can still be filtered as normal. A different callsite, which does not
have metadata from the log record, is used when actually recording
events constructed from `log::Records`; in a follow-up, we can propagate
the log metadata as fields there.

Closes #78
Closes #108

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-27 15:18:32 -07:00
Eliza Weisman
1af521e7e6
tracing-core: update to use features available on Rust 1.34 (#106)
## Motivation

Since the minimum Rust version is now Rust 1.34, we can address some
long-standing TODOs that were previously not possible to address because
they required features unavailable on Rust 1.26.

## Solution

This branch adds public `const fn` constructors to
`tracing_core::Metadata` and `tracing_core::field::FieldSet`, and
changes the internal representation of `tracing_core::span::Id` to
benefit from non-zero optimization. We cannot add a `const fn`
constructor for `callsite::Identifier` at this time, since trait objects
as const fn parameters are not stable.

Metadata is still constructed using the `metadata!` macro, as it also
uses the `file!()`, `line!()`, and `module_path!()` macros, but the
`const fn` constructor means that `Metadata`'s fields need no longer be
`#[doc(hidden)] pub`.

Closes #105 

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-26 16:31:59 -07:00
Eliza Weisman
6a5cb28a44
meta: rename everything to tracing (#99)
See #95 

This branch renames everything from `tokio-trace` to `tracing`.

Unlike PR #98, the nursery crates still depend on the crates.io
versions of `tokio-trace` and `tokio-trace-core`, but renamed
to `tracing`/`tracing-core` in `Cargo.toml`. We can update the
nursery crates to depend on local path dependencies in a 
subsequent PR, as that will require making code changes to the
nursery crates.

This branch _also_ updates the minimum Rust version to 1.34.0,
to the shock and horror of the millions of `tracing` users still
on Rust 1.26.0. This was necessary in order to allow renaming
crates in `Cargo.toml`, and to resolve that not using the `dyn` 
keyword is now a warning on nightly.

Closes #98 
Closes #95

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-26 11:31:07 -07:00