* tracing: update core version
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
* tracing: prepare to release 0.1.12
Added
- `Span::with_subscriber` method to access the subscriber that tracks a
`Span` (#503)
- API documentation now shows which features are required by
feature-flagged items (#523)
- Improved README examples (#496)
- Documentation links to related crates (#507)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
* Update CHANGELOG.md
These were added while debugging issue #511. They were never intended to
be committed, but apparently I missed a few while removing them, and
they slipped into PR #514 by mistake.
Once this merges, I'll publish `tracing-subscriber` 0.2.0-alpha.4. We may
want to consider yanking alpha.3.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
* subscriber: prepare to release 0.2.0-alpha.3
### Added
- **fmt**: Public `FormattedFields::new` constructor (#478)
- **fmt**: Added examples to `fmt::Layer` documentation (#510)
- Documentation now shows what feature flags are required by each API item (#525)
### Fixed
- **fmt**: Missing space between timestamp and level (#480)
- **fmt**: Incorrect formatting with `with_target(false)` (#481)
- **fmt**: `fmt::SubscriberBuilder::init` not setting up `log` compatibility
(#489)
- **registry**: Spans exited out of order not being closed properly on exit
(#509)
- **registry**: Memory leak when spans are closed by a child span closing (#514)
- **registry**: Spans closed by a child span closing not also closing _their_
parents (#514)
- Compilation errors with `no-default-features` (#499, #500)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
* Get the last bits of tracing-core
* remove unnecessary doc_cfgs
* add doc_cfg for std feature in tracing-futures
* Finish enabling doc_cfg for tracing-futures
* fix tracing-futures doc_cf and start subscriber
* finish doc_cfg for tracing-subscriber
Authored-by: Jane Lusby <jlusby42@gmail.com>
# 0.1.9 (January 10, 2020)
### Added
- API docs now show what feature flags are required to enable each item (#523)
### Fixed
- A panic when the current default subscriber subscriber calls
`dispatcher::with_default` as it is being dropped (#522)
- Incorrect documentation for `Subscriber::drop_span` (#524)
* ci: remove `on: pull_request`
It appears that this setting doesn't actually do what I thought it did.
Having this seems to result in all the CI actions being run one
additional time *when the PR is opened* (which should be identical to
the first push?), and if it fails, it marks the PR as failing
permanently. Subsequent pushes don't appear to change the PR's state.
This is clearly not what we want — I think `on: pull_request` was
intended for stuff like labeling the PR or posting a welcome message for
new contributors, not for running CI jobs.
Therefore, I've removed it.
* make clippy not hate dispatcher doctests
these were copied from the wrong SHA, my bad
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Starts on #440.
This branch adds `doc_cfg` attributes to `tracing` and `tracing-core`,
when a `docsrs` cfg flag is passed to rustdoc. It also adds
docs.rs crate metadata to configure docs.rs to set that flag, and adds
it to the Netlify config as well.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
The docs for `drop_span` incorrectly state that the method is
"soft-deprecated", when it's actually...normal deprecated. The RustDoc
says that "using this method won't cause a compilation warning", but
this is incorrect.
This branch updates the doc comment.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This branch updates the `tracing-subscriber` tests for
span closure and removal from the registry. The test layer
used to make assertions about close orders is made more
flexible, so we can write more tests in the future, and the
tests are now a bit simpler.
With this change we replace DefaultGuard's drop implementation with a
version that no longer drops the previous dispatch object while the
comprising RefCell is borrowed mutably. In issue #521 we have seen how
this can back fire and result in a panic.
This patch is based on a suggestion by @hawkw (thanks for the quick
feedback!).
Fixes: #521
This branch fixes a couple of issues which might result in child spans
not correctly triggering their parents to close:
* subscriber: fix spans closed by their children not being removed
The issue here is that the `CloseGuard` removes the span from the
registry (dropping the `DataInner`) *before* it decrements CLOSE_COUNT.
Dropping the `DataInner` will decrement the parent span's ref count,
potentially allowing it to close. When the new close for the parent span
starts, CLOSE_COUNT will be 1, not 0, and it will not be decremented
until after the try_close call completes. This means that although the
close is processed and all the layers see `on_close` calls for that
span, the span's data is never removed from the registry, effectively
leaking it.
This commit fixes the problem by decrementing CLOSE_COUNT *before* we
trigger the parent to close.
Fixes#511
* subscriber: fix child spans not closing grandparents
Currently, in situations where multiple parent spans are kept open by a
child, only the first parent will be successfully closed. This is
because calling `dispatcher::get_default` unsets the default dispatcher
temporarily, so that nested `get_default` calls will receive a no-op
subscriber. This was intended to prevent infinite dispatch loops when a
subscriber calls into code that emits its own traces. Unfortunately,
this means that if dropping the parent span would then trigger an
additional span to drop, the dispatcher is now unset.
This commit fixes this by cloning the dispatcher out of the
`get_default` closure _before_ trying to close the parent span. This
means that the `get_default` calls are no longer nested. This does have
the disadvantage of introducing an additional `Arc` increment/decrement
to the span-closing path. The impact of that shouldn't be too big, but
if necessary we can try to optimize this in the future.
I've also added tests for these issues.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
* Add examples for layers
* Reorganize and shrink examples
* Apply suggestions from code review
Co-Authored-By: Eliza Weisman <eliza@buoyant.io>
* Clean up imports
* remove module specific filtering
* add an explanation
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Closes#430
This is a follow up PR for #477 that runs clippy on CI.
* Switch from hecrj/setup-rust-action to actions-rs/toolchain
* Fix remaining clippy lints
* Switch to minimal rustup profile
* Replace warning step with clippy
* Remove #![feature(async_await)]
* subscriber: traverse SpanStack on pop
In cases where spans are not popped in FILO (first-in-last-out) order,
`pop` would return `None`. This would cause issues in `Registry` where
spans that are exited out of order would not be closed properly.
Fixes#495
* PR comments
* Import super deps explicitly
* Use ClosingLayer in test
* s/pub(crate) mod tests/mod tests
* docs: add third-party crates to docs
This branch adds a list of related crates not in this repository to the
`tracing` RustDoc, the `tracing` README, and the root repository README.
(cc @jonhoo, @jtescher, @pkinsky, @GregBowyer, @zanria, @hlb8122)
Closes#373
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
## Motivation
Being able to trace futures in platforms that do not support
stdlib would be nice.
## Solution
* futures: no_std support
* futures: gate support of with_subscriber to std
* futures: document no_std support
## Motivation
I've found multiple compilation error involving non-default features.
## Solution
cargo-hack was a suggested solution (by @davidbarsky and @hawkw) to run
compilation checks on all features.
* ci: try cargo-hack
* ci: split cargo-hack execution in multiple jobs
* ci: try splitting checks of tracing-subscriber in dedicated job
Fixes#501
* subscriber: compilation errors w/ nodefault + ansi
when compiling with -no-default-features --features "ansi", the
following compilation error would come up:
```
error[E0599]: no method named `with_env_filter` found for type `fmt::SubscriberBuilder` in the current scope
--> tracing-subscriber/src/fmt/mod.rs:663:10
|
146 | / pub struct SubscriberBuilder<
147 | | N = format::DefaultFields,
148 | | E = format::Format<format::Full>,
149 | | F = LevelFilter,
... |
153 | | inner: LayerBuilder<Registry, N, E, W>,
154 | | }
| |_- method `with_env_filter` not found for this
...
663 | .with_env_filter(crate::EnvFilter::from_default_env())
| ^^^^^^^^^^^^^^^ method not found in `fmt::SubscriberBuilder`
```
* subscriber: compilation errors w/ nodefault + fmt
when compiling with -no-default-features --features "fmt", the following
compilation error would come up:
```
error[E0107]: wrong number of type arguments: expected 2, found 1
--> tracing-subscriber/src/fmt/format/mod.rs:603:30
|
603 | impl<'a, N> fmt::Display for FullCtx<'a, N>
| ^^^^^^^^^^^^^^ expected 2 type arguments
```
* subscriber: compilation errors w/ nodefault + env-filter + fmt
when compiling with -no-default-features --features "env-filter fmt", the
following compilation error would come up:
```
error[E0277]: the trait bound `for<'lookup> <S as registry::LookupSpan<'_>>::Data: registry::LookupSpan<'lookup>` is not satisfied
--> tracing-subscriber/src/fmt/format/mod.rs:304:44
|
279 | ) -> fmt::Result {
| - help: consider further restricting the associated type: `where for<'lookup> <S as registry::LookupSpan<'_>>::Data: registry::LookupSpan<'lookup>`
...
304 | write!(writer, "{} {}", fmt_level, fmt_ctx)?;
| ^^^^^^^ the trait `for<'lookup> registry::LookupSpan<'lookup>` is not implemented for `<S as registry::LookupSpan<'_>>::Data`
|
= note: required because of the requirements on the impl of `std::fmt::Display` for `fmt::format::FmtCtx<'_, S, N>`
= note: required by `std::fmt::Display::fmt`
error[E0593]: closure is expected to take 1 argument, but it takes 2 arguments
--> tracing-subscriber/src/fmt/format/mod.rs:530:18
|
530 | self.ctx.visit_spans(|_, span| {
| ^^^^^^^^^^^ --------- takes 2 arguments
| |
| expected closure that takes 1 argument
```
Closes#494
This fixes the following compilation error:
```
error[E0433]: failed to resolve: use of undeclared type or module `registry`
--> tracing-subscriber/src/layer.rs:844:25
|
844 | S: for<'lookup> registry::LookupSpan<'lookup>,
| ^^^^^^^^ use of undeclared type or module `registry`
error[E0412]: cannot find type `Scope` in this scope
--> tracing-subscriber/src/layer.rs:842:28
|
842 | pub fn scope(&self) -> Scope<'_, S>
| ^^^^^ not found in this scope
error[E0425]: cannot find function, tuple struct or tuple variant `Scope` in this scope
--> tracing-subscriber/src/layer.rs:850:9
|
850 | Scope(scope)
| ^^^^^ help: a local variable with a similar name exists (notice the capitalization): `scope`
```
This PR fixes all reported clippy lints. In most cases I have made the
suggested changes. In a few cases (e.g., `blacklisted_name` and
`cognitive_complexity`) I've just silenced the warning.
I can make stylistic changes or discard some of the lint fixes if
preferred.
* tracing: prepare to release 0.1.11
Added
- `Span::is_none` method (#475)
- `LevelFilter::into_level` method (#470)
- `LevelFilter::from_level` function and `From<Level>` impl (#471)
- Documented minimum supported Rust version (#482)
Fixed
- Incorrect parameter type to `Span::follows_from` that made it
impossible to call (#467)
- Missing whitespace in `log` records generated when enabling the `log`
feature flag (#484)
- Typos and missing links in documentation (#405, #423, #439)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Added
- `Default` impl for `Dispatch` (#411)
Fixed
- Removed duplicate `lazy_static` dependencies (#424)
- Fixed no-std dependencies being enabled even when `std` feature flag
is set (#424)
- Broken link to `Metadata` in `Event` docs (#461)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This branch updates all the README links and badges. In particular, it:
* Changes build status badges to GitHub Actions, since we've turned off
the Azure Pipelines CI build,
* Removes Gitter links, since nobody is on Gitter these days and we
probably don't want to point new users to an empty chat room,
* Make Discord links "actually work"
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
## Motivation
When using the `tracing/log` feature flag to emit log records from
tracing events which contain a message and fields, there is missing
whitespace between the message and the rest of the fields.
For example, events like
```rust
tracing::trace!(
sz,
old = self.window_size.0,
new = val,
"inc_window"
);
```
and
```rust
tracing::trace!(
sz,
window = self.window_size.0,
available = self.available.0,
"send_data",
);
```
result in `log` records like this:
```
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: inc_windowsz=65535 old=0 new=65535
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: inc_windowsz=65535 old=0 new=65535
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: inc_windowsz=65535 old=0 new=65535
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: send_datasz=16384 window=65535 available=65535
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: send_datasz=16384 window=65535 available=65535
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: send_datasz=16384 window=49151 available=49151
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: send_datasz=16384 window=49151 available=49151
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: send_datasz=10 window=32767 available=32767
TRACE 2019-12-05T18:26:56Z: h2::proto::streams::flow_control: inc_windowsz=32778 old=32757 new=65535
```
Note how the messages ("inc_window" and "send_data") appear concatenated
with the name of the next field ("sz").
## Solution
This branch adds the missing whitespace, fixing the issue.
Closes#459
## Motivation
I stumbled upon this issue when trying to get tracing-log working with
env_logger. The comments in-code are right, but the README uses a hyphen
instead of an underscore.
## Solution
Switched the hyphen for an underscore :)
## Motivation
There is currently no way to detect when a span is "empty" (i.e., it was
created with `Span::none`). This would be handy in cases where you want
to perform some (perhaps costly) additional metric-gathering when a
particular request _is_ being traced (i.e., it has a `Span`).
## Solution
This branch adds `Span::is_none`.
Closes#469
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
## Motivation
Can't create a filter for a specific level without having to `match` on
a `Level`.
## Solution
Add `LevelFilter::from_level` `const` function and `From<Level> for
LevelFilter` impl
## Motivation
Makes it possible to get a `Level` without having to check which
`LevelFilter` is being used.
## Solution
Simply moves the inner `Option<Level>` out of the `LevelFilter`.
Added:
- `LookupSpans` implementation for `Layered` (#448)
- `SpanRef::from_root` to iterate over a span's parents from the root
(#460)
- `Context::scope`, to iterate over the current context from the root
(#460)
- `Context::lookup_current`, which returns a `SpanRef` to the current
span's data (#460)
Changed:
- Lifetimes on some new `Context` methods to be less restrictive (#460)
Fixed:
- `Layer::downcast_ref` returning invalid references (#454)
- Compilation failure on 32-bit platforms (#462)
- Compilation failure with ANSI formatters (#438)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
## Motivation
PR #443 added a `Context::scope` function, as described in issue #427.
In the issue, the desired change was described as follows:
> - The method `FmtContext::visit_spans` should be moved to
> `layer::Context`.
> - The new `layer::Context::visit_spans` should be renamed to
> something along the lines of `parents()`, **and be made to return
> a newtype implementing `std::iter::Iterator`.**
(emphasis mine)
Unfortunately, #443 only implemented the first bullet point — the new
`layer::Context::scope` method was just a copy of the old
`visit_spans`. The branch was merged before a thorough review could
determine that the change made there was incomplete.
## Solution
This branch changes the `Context::scope` function to return an
iterator, as it was supposed to, and rewrites `visit_spans` to consume
that iterator.
Additionally, I've added some new toys:
- `SpanRef::from_root`, which returns an iterator over a span's
parents, starting from the root (rather than from the direct parent
like `SpanRef::parents`)
- `Context::lookup_current`, which returns a `SpanRef` to the current
span's data
- Easier to use lifetimes on a couple of the new `Context` methods
enabled by the "registry" feature (not a breaking change, as these
aren't yet released)
Co-authored-by: David Barsky <me@davidbarsky.com>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
## Motivation
PR #441 increased the minimum supported Rust version, but it only
changed the Azure Pipelines CI configuration, and not the GitHub Actions
one. Additionally, upstream changes to `tower` has broken some of the
examples.
## Solution
This branch bumps the MSRV on GitHub Actions as well, and comments
out examples that depend on code broken upstream.
Additionally, it turns out that — due to Cool Cargo Semver Reasons —
it's more or less impossible to depend on both tokio 0.2.0-alpha.6 *and*
tokio 0.2 release versions. This branch therefore just drops the 0.2.0-alpha.6
support; the next `tracing-futures` will be a breaking change anyway.
Co-authored-by: David Barsky <me@davidbarsky.com>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Currently tracing-subscriber doesn't compile on 32-bit platforms as
discussed here: https://github.com/hawkw/sharded-slab/issues/9
The underlying issue has been fixed by @hawkw. This pull simply updates
the dependency inside this project. Thanks for your work on this!