15 Commits

Author SHA1 Message Date
Lucio Franco
1a3f365965
fmt,futures,tower,tower-http: Use crates.io instead of local pat… (#139)
Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
2019-07-03 17:11:20 -04: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
ce37de8982 trace-fmt: use dyn attribute to make nightly happy (#127) 2019-06-30 21:42:08 -04: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
Jon Gjengset
36356ee98a
Remove need to typehint Timer (#118)
With the previous implementation of `Default` for
`fmt::default::Format`, users would have to explicitly type out what
timer they want when calling `Format::default`, even if they then
immediately go on to use `with_timer`. This PR changes the
implementation of `Default` to use `SystemTime` like the default generic
types on `Format` itself.
2019-06-28 23:44:25 -04:00
Jon Gjengset
d5bd0da841
Undo #113 and re-enable git dependencies (#114)
Revert "update crates to depend on core from crates.io (#113)" and let tracing-core use tracing from crates.io

This reverts commit 1c6b4388d49aa3202ae39fd396500677cb3c5730.
2019-06-27 21:15:34 -04:00
Eliza Weisman
1c6b4388d4
update crates to depend on core from crates.io (#113)
This branch updates `tracing`, `tracing-fmt`, and `tracing-log`
to depend on `tracing-core` 0.1 from crates.io.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-27 17:05:18 -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
26a4317003
fmt: fix flakey test (#111)
## Motivation

The `reload_handle` test in `tracing-fmt` is flakey. This is because
reloading a filter now triggers a callsite registry rebuild; and using
functions as filters means that the call counters are incremented when
the registry is rebuilt.

## Solution

This branch replaces the functions with an enum implementing `Filter`,
which doesn't increment the call counters when `register_callsite` is
called. This should make the tests no longer be flakey.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-27 14:57:51 -07:00
Eliza Weisman
94d87ae072
fmt, log: fix API breakage (#107)
## Motivation

PR #106 broke some APIs that the nursery crates `tracing-fmt` and
`tracing-log` depended on. At the time, we didn't catch this, as those
crates still depended on `tokio-trace`/`tokio-trace-core` from
crates.io. However, after merging #101, which updated those crates to
use path dependencies on `tracing`/`tracing-core`, those crates broke. 

## Solution

This branch updates `tracing-fmt` and `tracing-log` to compile with the
changed APIs. `tracing-log` was also changed to depend on `tracing-core`
rather than `tracing`, as only the `core API is required by that crate,
and the `identify_callsite!` macro is not publically re-exported by 
`tracing`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-27 13:05:19 -07:00
Eliza Weisman
3081a19812
chore: update nursery crates to use path deps on tracing (#101)
This branch updates the "nursery" crates to depend on `tracing` and
`tracing-core` as path dependencies, rather than depending on the
crates.io releases of `tokio-trace` and `tokio-trace-core`. When
`tracing` and `tracing-core` are released, we will change these from
path dependencies to crates.io dependencies.

This branch also updates those crates to track API changes in `tracing`
and `tracing-core`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-06-26 16:42:10 -07:00
Jon Gjengset
7bc97b1abe
fmt: Timestamped log messages (#96)
Currently there is no good way to get timestamped log entries with the
`tracing-fmt` subscriber. Even with `full`, timestamps are not included.
This is surprising to those coming from other logging crates. It is also
inconvenient to work around, as you would either need to add a custom
field to _all_ spans and events across all your crates, or write your
own subscriber which sort of reduces the usefulness of `fmt`.

This patch introduces a trait for event formatters (`FormatEvent`) so
that it is easier to write more complex formatters (previously they were
just `Fn(...) -> fmt::Result` which would require boxing a closure to
produce). It then implements this new trait for `default::Format`, which
is the new default formatter. It implements "compact"/full formatting
exactly like before, except that is also generic over a timer. The timer
must implement `default::FormatTime`, which has a single method that
writes the current time out to a `fmt::Write`. This method is
implemented for a two new unit structs `SystemTime` and `Uptime`.
`SystemTime` is pretty-printed using `chrono` with the new default
feature `chrono`, and `Debug` of `std::net::SystemTime` is used if the
feature is turned off. `Uptime` prints the fractional number of seconds
since an epoch. Users can also provide `()` as the time formatter to not
produce timestamps in logged entries (accessible through
`default::Format::without_time`).

This patch also switches the default output to the verbose format, with
`compact` offered to return to the compact output format.

Closes #94.
2019-06-26 16:41:31 -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