24 Commits

Author SHA1 Message Date
Christopher Durham
a3868af664
chore: fix minimal-versions correctness (#2246)
## Motivation

Fix minimal-versions failure.

## Solution

Upgrade all the dependencies to their most recent semver-compatible
version, adjusting back down as necessary for MSRV.

Essentially a cherry-pick of #2231, but redone by hand.

## Tests

- `cargo minimal-versions msrv verify -- cargo check --all-features`
- `cargo minimal-versions msrv verify -- cargo check --no-default-features`

## Methodology

- `cargo update && cargo upgrade --to-lockfile`
  - Identify [a bug](https://github.com/killercup/cargo-edit/issues/750) and manually resolve it
- loop; upgrade transitive deps
  - `cargo minimal-versions check --all-features`
  - Identify failing dep
  - `cargo minimal-versions tree -i dep --all-features`
  - Find the closest dependency leading to pulling in `dep`
  - `cargo add fixdep --optional` to force a more recent more-minimal-versions-correct version
- loop; downgrade to msrv
  - `cargo minimal-versions msrv verify -- cargo check --all-features`
  - Identify failing dep
  - `cargo minimal-versions tree -i dep --all-features`
  - Find the version that supports MSRV from lib.rs
  - `cargo upgrade dep@msrv`
2022-07-26 15:27:58 -07:00
Eliza Weisman
32225276a9 chore: update MSRVs from 1.42 to 1.49 (#1913)
This updates all crates' MSRVs to 1.49 if they were not already greater
than that (`tracing-appender` is at 1.53). Rust 1.49+ is required to
update `parking_lot` to v0.12 (see #1878). Also, `futures-task` (which I
believe is only needed as a transitive dep) now needs 1.45+, so this
also fixes our CI build.

Because `tracing-opentelemetry` previously required 1.46.0, it had a
separate CI MSRV job. Since 1.49.0 is greater than 1.46.0, the separate
check for `tracing-opentelemetry` is no longer needed.

In the process, I removed deprecated uses of
`core::atomic::spin_loop_hint`, which is replaced with
`core::hint::spin_loop` in 1.49.
2022-02-07 15:39:26 -08:00
Folyd
3a86d4810c chore: fix cargo MSRV field typo (#1742) 2021-11-23 13:50:24 -08:00
Eliza Weisman
e62e7165f4 chore: add MSRV cargo metadata (#1730)
This branch adds the `[package.rust]` metadata to `Cargo.toml` for all
crates. See https://rust-lang.github.io/rfcs/2495-min-rust-version.html
for details.
2021-11-19 16:57:37 -08:00
Eliza Weisman
270de1cde0
docs: fix a bunch of RustDoc warnings/errors (#1524)
This branch fixes some minor RustDoc issues. In particular:

- The `broken_intra_doc_links` lint was renamed to
  `rustdoc::broken_intra_doc_links`. This generates a warning, since the
  old name was deprecated.
- `ignore` code blocks are specifically for _Rust_ code that should not
  be compiled, not for other text blocks. We were using `ignore` on JSON
  blocks, which generates a warning.
- A bunch of links in `tracing-subscriber`'s RustDocs were broken. This
  fixes that.

I also changed the Netlify configuration to run with `-D warnings`, so that
we can surface RustDoc warnings in CI builds.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-08-27 11:23:46 -07:00
Eliza Weisman
5c457e5e73
macros: fix the tracing-macros crate not compiling (#1000)
## Motivation

The `tracing-macros` crate doesn't currently compile with the latest
`tracing` release, because it uses internal private API that changed.
We need to fix this so CI isn't broken.

## Solution

I changed the `dbg!` macro so it no longer uses internal APIs. Ideally,
we would implement `dbg!` using the support for string-literal field
names that was recently added to `tracing`, but I couldn't actually get
it to work --- I think the `event!` macros may not handle string literal
field names properly (we only test them with the `span!` macros >_>).
Will try to fix that later, but for now, this fixes CI and I don't think
anyone actually uses the experimental, unreleased `tracing-macros` 
crate.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-10-02 15:34:58 -07:00
Takayuki Maeda
6f01226570
docs: add deny(broken_intra_doc_links) (#981)
## Motivation

In order to get a compiler warning (or error) when links are broken. 
Closes #940

## Solution

- [x] add `deny(broken_intra_doc_links)`
- [x] add a note to the CONTRIBUTING.md documentation on building docs locally

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-23 10:24:34 -07:00
Eliza Weisman
a4069486b4
macros: fix breakage in experimental tracing-macros crate (#882)
The `tracing-macros` crate uses internal `tracing` APIs that are
unstable. These APIs changed in 0.1.18 (not a breaking change, since
they are explicitly not stable API). `tracing-macros` needed to be
updated to use the new versions of the internal APIs.

As a side note, I'm surprised this wasn't caught before merging the
branch, and only happened on `master`. Are we not checking all crates
for PR builds? If so, we should probably fix that.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-08-03 12:28:19 -07:00
Josh Stone
0de7d51689
chore: Include the LICENSE in every crate (#842)
## Motivation

The MIT license states:

> The above copyright notice and this permission notice
> shall be included in all copies or substantial portions
> of the Software.

## Solution

Therefore the LICENSE files should be present in each crate directory,
so they are included with `cargo publish`.
2020-07-23 12:23:04 -07:00
dependabot-preview[bot]
13344fb621
build(deps): update env_logger requirement from 0.5 to 0.7 (#802)
* build(deps): update env_logger requirement from 0.5 to 0.7

Updates the requirements on [env_logger](https://github.com/sebasmagri/env_logger) to permit the latest version.
- [Release notes](https://github.com/sebasmagri/env_logger/releases)
- [Changelog](https://github.com/sebasmagri/env_logger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sebasmagri/env_logger/commits/v0.7.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* fix compilation (#804)

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Sven <SirWindfield@users.noreply.github.com>
2020-07-11 09:21:50 -07:00
Taiki Endo
18764d149f
Replace local_inner_macros with $crate (#729) 2020-05-22 22:10:03 +09:00
Eliza Weisman
fbcd27e9bf
chore: remove redundant imports (#694)
## Motivation

It looks like Rust 1.43's version of clippy added a new lint for
redundant `use` statements with just a crate name. These are unnecessary
because the root module of an external crate is always available without
imports. Apparently, `tracing-log`, `tracing-subscriber`, `tracing`, and 
`tracing-tower` all had some redundant `use` statements, which clippy now 
warns us about.

## Solution

This PR removes them.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-04-27 12:38:00 -07:00
Eliza Weisman
47d8807b69
chore: clean up old CI stuff (#670)
## Motivation

Currently, `tracing` uses GitHub Actions for CI. However, we have
previously used both Travis and Azure Pipelines CI. Some artifacts of
previous CI configurations, such as badges and config files, still exist
in the repo. This can be confusing, since some of these CI
configurations imply things that aren't currently true (such as old MSRV
versions).

## Solution

This branch removes the following:

- Azure Pipelines badges from cargo metadata. These currently show up 
  as "never built" on crates.io, since the Azure build is turned off. So, we 
  should just remove them. 
- `.travis.yml`. We don't use Travis and there's no sense keeping around
  an old config file.
- `azure-pipelines.yml`. Similarly, we no longer need this.

Fixes: #669

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-04-07 10:52:01 -07:00
Darin Morrison
048b85cf3b Fix clippy lints (#477)
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.
2019-12-20 17:03:34 -08:00
Benjamin Saunders
f0c0a7343c Remove redundant documentation metadata (#408) 2019-10-24 20:51:41 -07:00
Eliza Weisman
c0c61d1cf4
core, tracing: make disabled events way faster (#326)
## Motivation

When `tracing` is not in use, no default subscriber will be set, and
tracing instrumentation points can be skipped. Currently, the
instrumentation macros detect this by testing if the callsite's
`Interest` is `never`. However, this is significantly slower than how
the `log` crate detects that there is no logger: we must call a function
through a trait object, do a relaxed load, construct an `Interest` from
an integer, and then test on the value of the `Interest`. Furthermore,
we must construct the callsite _at all_ in order to do this. Meanwhile, 
when no logger is set, `log` can skip log records with only a single 
relaxed atomic load.

## Solution

This branch adds a new private-API method in `tracing_core::dispatcher`
that allows us to check if a dispatcher has ever been set. If this is
false, then `tracing` has not yet been initialized and the callsite can
be elided entirely. Representing this as an atomic bool lets us perform
a single relaxed load and branch, without having to mess around with
`Interest`s and callsite vtables and so on. In cases where `tracing`
will never be used, this will always be false.

This the event macro performance with no subscriber set on par with the
`log` crate's performance when no logger is set. Spans are a bit slower
because they must still construct a disabled span object, but the span
macros are somewhat faster in this case than they were previously.

## Benchmark results

Before:

![Screen Shot 2019-09-04 at 2 59 06 PM](https://user-images.githubusercontent.com/2796466/64294816-965d9b00-cf24-11e9-9e90-b6d3ee337da8.png)

After:

![Screen Shot 2019-09-04 at 2 58 34 PM](https://user-images.githubusercontent.com/2796466/64294827-9d84a900-cf24-11e9-9223-fa39dfcef46b.png)

Note that when no subscriber is set, skipping an event previously
took an average of around 2 ns, and skipping a span took around 
5 ns. Now, skipping an event takes around 850 ps (about the
same as skipping a `log` macro when there's no logger), while 
skipping a span macro takes around 2 ns.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>

* tracing, core: improve no-subscriber performance significantly

This branch adds a new private API to `tracing-core` for checking if a
subscriber has ever been set. If a subscriber has never been set, we can
elide almost all of the event macro, and more of the span macro than we
were previously able to. Unlike checking a cached interest, which must
synchronize with the callsite registry, checking if a subscriber has
been set may be a relaxed rather than acquire load.

The performance of the `event!` macro (and the related `trace!`,
`info!`, etc macros) when no subscriber has ever been set (i.e., tracing
is not being used) is now comparable with that of the `log` crate, at
approximately 600 picoseconds (on my MacBook). As per `criterion`:

```
no_subscriber/event     time:   [610.43 ps 621.06 ps 633.20 ps]
                        change: [-64.247% -62.295% -60.263%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  1 (1.00%) high mild
  3 (3.00%) high severe

  no_subscriber/log       time:   [689.22 ps 707.34 ps 728.25 ps]
                        change: [+27.149% +33.128% +40.141%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 4 outliers among 100 measurements (4.00%)
  4 (4.00%) high mild

no_subscriber_field/event
                        time:   [623.28 ps 635.73 ps 648.88 ps]
                        change: [-59.666% -58.074% -56.649%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild
no_subscriber_field/log time:   [621.73 ps 632.07 ps 643.30 ps]
                        change: [+1.6194% +4.3288% +7.1454%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe

```

The worse performance of the `log` crate without fields than with fields
is probably statistical noise that criterion failed to eliminate.

The span macros cannot achieve this level of performance currently, as
the callsite must still be constructed in order to emit `log` events
when that feature flag is enabled. Future work will involve tuning the
`span!` macro some more. However, performance is improved by this change.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>

* optimize disabled spans when log support is off
* tracing: add benchmarks for getting the subscriber

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-09-04 18:38:13 -07:00
Eliza Weisman
30c62e02a1
examples: update to use Rust 2018 idioms (#271)
## Motivation

`tracing` is built with Rust's 2018 edition, but some examples use
outdated idioms. Ideally, examples would show code using the currently
preferred idioms. This improves clarity, especially for newer Rust
programmers who may not be familiar with the idioms of earlier editions.
 
## Solution

This branch updates all the examples to use Rust 2018 edition idioms,
and adds `deny` attributes to prevent the use of outdated idioms.

* deny rust 2018 idiom lints in examples
* examples: update to use Rust 2018 idioms
* examples: remove most uses of `extern crate`

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-08-13 11:56:54 -07:00
Arthur Gautier
80a5f492ab meta: fixup missing repository links on crates.io (#228)
Signed-off-by: Arthur Gautier <baloo@gandi.net>
2019-07-31 14:36:35 -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
Eliza Weisman
8ad3e8e437
subscriber: Add a Layer type for composing subscribers (#136)
* add `Layer` trait for composing subscribers

### Motivation

In many cases, it is valuable to compose multiple consumers for trace
events. However, certain aspects of `tracing`'s design --- in
particular, that span IDs are assigned by the subscriber, and that a
single subscriber collects events from multiple threads --- make it
difficult to compose the `Subscriber` trait directly. 

## Solution

This branch introduces a new trait, `Layer`, in `tracing-subscriber`.
`Layer` represents the composable subset of the `Subscriber`
functionality --- it recieves notifications of spans and events, and can
filter callsites, but it does not assign IDs or manage reference counts,
instead being notified on span closure by the underlying subscriber. A
`Layer` can thus be wrapped around another subscriber to add additional
functionality. In addition, this branch adds functionality for composing
layers, and a `filter` module that provides `Layer` implementations for
simple filters.

## Future Work

To have a complete story for multi-subscriber fanout, we will also want
to implement a performant concurrent span store, as I described in #157.
To better support the use of subscriber layers, may wish to consider
having a "registry" subscriber that implements _only_ span storage, ID
generation, and lifecycle management, for composing layers on top of.
Finally, we should consider adding `Layer` implementations to other
crates that currently only expose `Subscriber` impls.

Refs: #135

Signed-off-by: Eliza Weisman <eliza@buoyant.io>

* subscriber: remove ref-counting from Layer (#149)

## Motivation

As I mentioned in https://github.com/tokio-rs/tracing/pull/136#discussion_r300158248, the
`Layer` trait proposed in #136 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. 

## Solution

Adding a callback that's called on closure to `Layer` required modifying
the `Subscriber` trait to allow indicating when a span closes. 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. This function was added in #153. 

This branch updates `tracing-subscriber::Layer` to use `try_close`. 
Rather than having `clone_span`/`drop_span` callbacks on `Layer`, we
now have a `close` function, which is called when the inner subscriber's
`try_close` returns `true`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>

* ensure a Context always refers to a Subscriber

This reworks layer composition a bit, and fixes an issue where
`Context`s were not actually guaranteed to wrap a `Subscriber`, and thus
implemented no methods. Layers now guarantee that `S` implements
`Subscriber`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-07-17 14:17:09 -07:00
Lucio Franco
3dc80c9196
subscriber: Fix tracing path dep (#146) 2019-07-03 18:05: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
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
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