83 Commits

Author SHA1 Message Date
Eliza Weisman
f9a3f17fbb tracing: add an example of tracing in a panic hook (#1375)
It turns out that when using the global dispatcher, emitting tracing
events in a panic hook will capture the span in which the program
panicked. This is very handy for debugging panics! Thanks a lot to
@nate_mara for pointing this out to me on twitter --- I hadn't even
thought of it!

Since it isn't necessarily immediately obvious that this works, I
thought it would be nice to add an example.
2021-04-30 11:27:10 -07:00
Tim
bab71acb28
opentelemetry: support otel 0.13.0 (#1322) (#1330)
This backports #1322 from `master` to `v0.1.x`,

* opentelemetry: support otel 0.13.0

Switches to `Cow<'static, str>` for otel event names and updates docs to
show simplified install methods.

* Add simple vs batch comment

Co-authored-by: Julian Tescher <jatescher@gmail.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2021-03-31 14:45:13 -07:00
Julian Tescher
1a1d5b01f8 opentelemetry: update to otel v0.12.x (#1200) 2021-01-26 10:08:31 -08:00
David Barsky
ea91df3662
examples: backport fmt-multiple-writers.rs to v0.1.0 branch (#1187)
It turns out that this example never existed on v0.1.x, which is my bad.

Resolves https://github.com/tokio-rs/tracing/issues/1179.
2021-01-12 15:46:45 -08:00
Julian Tescher
49b4a589bf
opentelemetry: update to otel v0.11.x (#1161) (#1162)
## Motivation

Support the latest OpenTelemetry specification

## Solution

In order to support the latest spec, this patch makes the following
breaking API changes:

* Update `opentelemetry` to 0.11.x
* Update `OpenTelemetrySpanExt::set_parent` to take a context by value
  as it is now stored and propagated.
* Rename `PreSampledTracer::sampled_span_context` to
  `PreSampledTracer::sampled_context` as it now returns a full otel
  context

Additionally the following doc and example changes:

* Show w3c trace context propagator as recommendation in examples
2020-12-30 12:09:16 -08:00
Julian Tescher
642ad19d62
opentelemetry: update to latest otel release version (#1049) (#1099)
This backports  #1049, which was already approved on master.

## Motivation

Support the latest OpenTelemetry specification

## Solution

In order to support the latest spec, this patch makes the following
breaking API changes:

* Update `opentelemetry` to 0.10.x
* Update `CompatSpan` to reflect changes to `Span` trait
* Record `u64` values as strings as they are no longer supported in
  OpenTelemetry.

Additionally the following non-public api, doc, and example changes:

* Update examples and docs to use new simplified pipeline builder.
* As `opentelemetry::api` no longer exports trace types, internally use
`opentelemetry::trace as otel` to disambiguate from tracing types.
* Remove `rand` dependency as it is no longer needed

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
# Conflicts:
#	examples/examples/opentelemetry-remote-context.rs
#	tracing-opentelemetry/Cargo.toml
#	tracing-opentelemetry/src/layer.rs
#	tracing-opentelemetry/src/span_ext.rs
#	tracing-opentelemetry/src/tracer.rs
2020-11-13 12:16:22 -08:00
Eliza Weisman
8bdc6c367d
subscriber: add Pretty formatter (backports #1067) (#1080)
This backports PR #1067 to v0.1.x. Since this has already been approved
on master, I'm just going to go ahead and merge it when CI passes.

## Motivation

Currently, the `tracing_subscriber::fmt` module contains only
single-line event formatters. Some users have requested a
human-readable, pretty-printing event formatter optimized for
aesthetics.

## Solution

This branch adds a new `Pretty` formatter which uses an _excessively_
pretty output format. It's neither compact, single-line oriented, nor
easily machine-readable, but it looks _quite_ nice, in my opinion. This
is well suited for local development or potentially for user-facing logs
in a CLI application.

Additionally, I tried to improve the docs for the different formatters
currently provided, including example output. Check out [the Netlify
preview][1]!

[1]: https://deploy-preview-1067--tracing-rs.netlify.app/tracing_subscriber/fmt/index.html#formatters

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-02 13:20:46 -08:00
Eliza Weisman
89418ee612
subscriber: prepare to release 0.2.13 (#1024)
### Changed

- Updated `tracing-core` to 0.1.17 ([#992])

### Added

- **env-filter**: Added support for filtering on targets which contain
  dashes ([#1014])
- **env-filter**: Added a warning when creating an `EnvFilter` that
  contains directives that would enable a level disabled by the
  `tracing` crate's `static_max_level` features ([#1021])

Thanks to @jyn514 and @bkchr for contributing to this release!

[#992]: https://github.com/tokio-rs/tracing/pull/992
[#1014]: https://github.com/tokio-rs/tracing/pull/1014
[#1021]: https://github.com/tokio-rs/tracing/pull/1021
2020-10-07 15:06:37 -07:00
David Barsky
a8cc977e01
tracing: Instrument std::future::Future (#808)
Authored-by: David Barsky <dbarsky@amazon.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-09-25 16:15:06 -04:00
Eliza Weisman
3dd5c03d90
subscriber: prepare to release 0.2.12 (#970)
# 0.2.12 (September 8, 2020)

### Fixed

- **env-filter**: Fixed a regression where `Option<Level>` lost its
  `Into<LevelFilter>` impl ([#966])
- **env-filter**: Fixed `EnvFilter` enabling spans that should not be enabled
  when multiple subscribers are in use ([#927])
  
### Changed

- **json**: `format::Json` now outputs fields in a more readable order ([#892])
- Updated `tracing-core` dependency to 0.1.16

### Added

- **fmt**: Add `BoxMakeWriter` for erasing the type of a `MakeWriter`
  implementation ([#958])
- **fmt**: Add `TestWriter` `MakeWriter` implementation to support libtest
  output capturing ([#938])
- **layer**: Add `Layer` impl for `Option<T> where T: Layer` ([#910])
- **env-filter**: Add `From<Level>` impl for `Directive` ([#918])
- Multiple documentation fixes and improvements

Thanks to @Pothulapati, @samrg472, @bryanburgers, @keetonian, 
and @SriRamanujam for contributing to this release!

[#927]: https://github.com/tokio-rs/tracing/pull/927
[#966]: https://github.com/tokio-rs/tracing/pull/966
[#958]: https://github.com/tokio-rs/tracing/pull/958
[#892]: https://github.com/tokio-rs/tracing/pull/892
[#938]: https://github.com/tokio-rs/tracing/pull/938
[#910]: https://github.com/tokio-rs/tracing/pull/910
[#918]: https://github.com/tokio-rs/tracing/pull/918
2020-09-08 20:16:56 -07:00
Eliza Weisman
b3582013d8 examples: disable opentelemetry's default features
The `opentelemetry` crate depends on `prometheus`, which depends on
`protobuf`, a crate which doesn't compile on our MSRV (Rust 1.39). This
was missed due to issues with the MSRV CI checks, which will be fixed
fixed in #934. Therefore, once the MSRV checks work properly, the
`protobuf` dependency will break our builds.

We don't _need_ the `opentelemetry/metrics` feature, which is what
enables the `prometheus` (and thus `protobuf`) dependency.
`tracing-opentelemetry` already has a `default-features = false`
dependency on `opentelemetry`, but the examples don't. Therefore, I've
changed the examples crate to disable `opentelemetry`'s default features
as well.
2020-08-17 10:55:42 -07:00
Maxime Bedard
798ed9d31a
Bump to opentelemetry:0.8, opentelemetry-jaeger:0.7 (#932) 2020-08-14 10:35:52 -07:00
Tarun Pothulapati
e9b6645f0c
subscriber: impl Layer for Option<T:Layer> (#910)
## Motivation

Fixes #894

## Solution

This PR implements Layer for Option, allowing users to wrap a Layer with
an Option, allowing it to be passed internally wherever Layer is used
there by allowing by allowing layers to be enabled or disabled.

Using this with `reload` further allows a Layer to be dynamically
toggled based by using `handle.modify`

This PR also consists of a basic example.

Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
2020-08-14 10:29:16 -07:00
Eliza Weisman
e016e0435b
subscriber: prepare to release 0.2.11 (#916)
### Fixed

- **env-filter**: Incorrect max level hint when filters involving span
  field values are in use (#907)
- **registry**: Fixed inconsistent span stacks when multiple registries
  are in use on the same thread (#901)

### Changed

- **env-filter**: `regex` dependency enables fewer unused feature flags
  (#899)

Thanks to @bdonlan and @jeromegn for contributing to this release!
2020-08-10 17:38:32 -07:00
Eliza Weisman
2dd8fef355
subscriber: prepare to release 0.2.10 (#872)
### Fixed

- **docs**: Incorrect formatting (#862)

### Changed

- **filter**: `LevelFilter` is now a re-export of the
  `tracing_core::LevelFilter` type, it can now be used interchangably
  with the versions in `tracing` and `tracing-core` (#853)
- **filter**: Significant performance improvements when comparing
  `LevelFilter`s  and `Level`s (#853)
- Updated the minimum `tracing-core` dependency to 0.1.12 (#853)

### Added

- **filter**: `LevelFilter` and `EnvFilter` now participate in
  `tracing-core`'s max level hinting, improving performance
  significantly in some use cases where levels are disabled globally
  (#853)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-07-31 11:43:06 -07:00
Julian Tescher
6935338edb
opentelemetry: Upgrade to opentelemetry v0.7.0 (#867)
Upgrade `opentelemetry` to latest release version
2020-07-31 09:29:09 -07:00
Robert Collins
32cf418c3b
tracing: add support literals for field names (#790)
## Motivation

Some opentracing systems use fields with : in the names, which are not
legal rust identifiers. We could special case :, but then we have
complicated double-nested patterns (repeated idents separated by : and a
nested repeat separated by .), and this may by a case of always being
one-step-behind as more cases turn up; so this patch instead just gets
in front and lets users put in whatever they want: as they are not rust
identifiers, they miss out on some niceness. 

## Solution

This permits : in field names but also potentially anything
stringifiable, which may be overly liberal.

Signed-off-by: Robert Collins <robert.collins@cognite.com>
2020-07-29 17:36:44 -07:00
Eliza Weisman
4c36130211
subscriber: prepare to release 0.2.9 (#846)
### Fixed

- **fmt**: Fixed compilation failure on MSRV when the `chrono` feature
  is disabled (#844)

### Added

- **fmt**: Span lookup methods defined by `layer::Context` are now also
  provided by `FmtContext` (#834)
2020-07-23 17:11:18 -07:00
Eliza Weisman
96e9d6d4f0
subscriber: prepare to release 0.2.8 (#823)
### Changed

- **fmt**: When the `chrono` dependency is enabled, the `SystemTime`
  timestamp now emits human-readable timestamps rather than using
  `SystemTime`'s fmt::Debug`implementation (`chrono` is still required
  for customized timestamp formatting) (#807)
- **ansi**: Updated `ansi_term` dependency to 0.12 (#816)

### Added

- **json**: `with_span_list` method to configure the JSON formatter to
  include a list of all spans in the current trace in formatting events
  (similarly to the text formatter) (#741)
- **json**: `with_current_span` method to configure the JSON formatter
  to include a field for the _current_ span (the leaf of the trace) in
  formatted events (#741)
- **fmt**: `with_thread_names` and `with_thread_ids` methods to
  configure `fmt::Subscriber`s and `fmt::Layer`s to include the thread
  name and/or thread ID of the current thread when formatting events
  (#818)

Thanks to new contributors @mockersf, @keetonian, and @Pothulapati for
contributing to this release!
2020-07-17 11:03:23 -07:00
Tarun Pothulapati
c109197c3e
subscriber: allow thread name and ID to be displayed in traces (#818)
## Motivation

Fixes #809 

## Solution

This PR adds two new methods i.e `with_thread_ids` and
`with_thread_names` to the fmt Layer which passed till
the pre-configured Format type, where the check is performed
and these the above values are formatted based on the flags.

The formatting is done by creating to new Types that impl Display
for Id and Name. For Thread Name, we keep track of the max length
of the thread name that occured till now using a thread safe static
type and pad accordingly. For Thread Id, we pad directly with 2
as in most cases we would see a double digit number of threads.

Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
2020-07-17 10:09:59 -07:00
dependabot-preview[bot]
028dfdfe75
build(deps): update inferno requirement from 0.9.4 to 0.10.0 (#815)
Updates the requirements on [inferno](https://github.com/jonhoo/inferno) to permit the latest version.
- [Release notes](https://github.com/jonhoo/inferno/releases)
- [Changelog](https://github.com/jonhoo/inferno/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jonhoo/inferno/compare/v0.9.4...v0.10.0)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-07-14 10:54:17 -07:00
dependabot-preview[bot]
9c5d740649
build(deps): update humantime requirement from 1.2 to 2.0 (#814)
Updates the requirements on [humantime](https://github.com/tailhook/humantime) to permit the latest version.
- [Release notes](https://github.com/tailhook/humantime/releases)
- [Commits](https://github.com/tailhook/humantime/compare/v1.2.0...v2.0.1)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-07-13 09:34:20 -07:00
dependabot-preview[bot]
207d8ec2d6
build(deps): update ansi_term requirement from 0.11 to 0.12 (#816)
Updates the requirements on [ansi_term](https://github.com/ogham/rust-ansi-term) to permit the latest version.
- [Release notes](https://github.com/ogham/rust-ansi-term/releases)
- [Commits](https://github.com/ogham/rust-ansi-term/compare/v0.11.0...v0.12.1)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-07-13 08:47:02 -07:00
Jane Lusby
f939141602
remove unused dependencies (#810) 2020-07-12 15:31:48 -07:00
Sven
c99f05b5b7
chore(crates): rename examples crate (#798)
`examples` is actually not a valid crate identifier. This prevents dependabot from working correctly
2020-07-10 13:46:17 -07:00
Sven
f9b0a063c8
chore(deps): update env_logger dependency (#794)
## Motivation

The usage of the older version prevents crates from using newer
`env_logger` versions, as they aren't compatible with each other during
compilation. 

## Solution

Move to `env_logger@0.7`
2020-07-10 09:03:15 -07:00
Eliza Weisman
68556f2fe8
subscriber: prepare to release 0.2.7 (July 1, 2020) (#775)
### Changed

- **parking_lot**: Updated the optional `parking_lot` dependency to
  accept the latest `parking_lot` version (#774)

### Fixed

- **fmt**: Fixed events with explicitly overridden parent spans being
  formatted  as though they were children of the current span (#767)

### Added

- **fmt**: Added the option to print synthesized events when spans are
  created, entered, exited, and closed, including span durations (#761)
- Documentation clarification and improvement (#762, #769)

Thanks to @rkuhn, @greenwoodcm, and @Ralith for contributing to this
release!

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-07-01 09:43:54 -07:00
Benjamin Saunders
8c0ef97bd4
journald: add tracing-journald crate implementing a simple journald layer (#691)
## Motivation

Support for writing tracing-based logs directly to their standard
destination while preserving both standard and custom metadata on Linux
systems. Improves usability of Linux services and for Linux applications
executing outside of a terminal.

## Solution

It turns out [journald's native protocol][1] is very simple and spoken
over a Unix datagram socket at a fixed location (see [discussion of
stability of these interfaces][2], allowing high quality native support
with ~100LoC.

[journald conventions][3] for structured field names differ from typical
tracing idioms, and journald discards fields which violate its
conventions. Hence, this layer automatically sanitizes field names by
translating `.`s into `_`s, stripping leading `_`s and
non-ascii-alphanumeric characters other than `_`, and upcasing.

Levels are mapped losslessly to journald `PRIORITY` values as follows:

- `ERROR` => Error (3)
- `WARN` => Warning (4)
- `INFO` => Notice (5)
- `DEBUG` => Informational (6)
- `TRACE` => Debug (7)

Note that the naming scheme differs slightly for the latter half.

The standard journald `CODE_LINE` and `CODE_FILE` fields are
automatically emitted. A `TARGET` field is emitted containing the
event's target. Enclosing spans are numbered counting up from the root,
and their fields and metadata are included in fields prefixed by `Sn_`
where `n` is that number.

User-defined fields other than the event `message` field have a prefix
applied by default to prevent collision with standard fields.

[1]: https://www.freedesktop.org/wiki/Software/systemd/export/
[2]: https://systemd-devel.freedesktop.narkive.com/i5tlUyjz/client-logging-to-journald-without-libsystemd-journal-so#post6
[3]: https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html
2020-06-29 12:07:24 -07:00
Eliza Weisman
7bc225a5e9
subscriber: handle explicit event parents properly in formatters (#767)
## Motivation

Currently, the default formatter implementations in
`tracing-subscriber`'s `fmt` module do not handle explicitly set parent
spans for events, such as

```rust
let span = tracing::info_span!("some_interesting_span");
tracing::info!(parent: &span, "something is happening!");
```

Instead, when formatting the span context of an event, the context is
_always_ generated from the current span, even when the event has an
overridden parent. This is not correct.

## Solution

This branch changes the default context formatters to use the explicit
parent ID, if it is present. Otherwise, the contexual parent is used, as
it was previously.

I've also added tests ensuring that this works correctly, and removed
some workarounds for the previous incorrect behavior from the examples.

Fixes #766

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-06-24 12:47:33 -07:00
David Barsky
6e223c4478
examples: add tokio-spawny-thing; some chores (#759)
Chores consisted of:

- Updating examples/README.md to include recent additions
- Settle on hyphens in example names
2020-06-22 12:40:16 -04:00
Eliza Weisman
971a46b46d
subscriber: prepare to release 0.2.6 (#757)
Fixed

- **fmt**: Fixed an issue in the JSON formatter where using
  `Span::record` would result in malformed spans (#709)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-06-19 09:55:47 -07:00
Eliza Weisman
556cba2b8d
style: fix warning in examples (#758)
This fixes a new compiler warning in the `tower-load` example.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-06-19 09:32:52 -07:00
Julian Tescher
1cd3a76512
opentelemetry: Upgrade to opentelemetry v0.6.0 (#745) 2020-06-02 13:42:18 -07:00
Julian Tescher
89eee6b9b9
tracing_opentelemetry: Switch to Context propagation (#713)
The [OpenTelemetry Propagation
Spec](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md)
has been changed from operating primarily on `SpanContext`s to a more
generic `Context` struct which is a propagation mechanism that carries
execution-scoped values across API boundaries and between logically
associated execution units.

The following APIs are updated to facilitate this change:

* OpenTelemetrySpanExt's `set_parent` now accepts a reference to an
  extracted parent context.
* OpenTelemetrySpanExt's `context` now returns a context.

Additionally the need to sample spans before their context can be
injected into `Carrier`s necessitates that a `Sampler` is stored in the
`OpenTelemetryLayer`. Accordingly:

* `OpenTelemetryLayer::with_tracer(tracer)` has been removed in favor of
  `tracing_opentelemetry::layer().with_tracer(tracer).with_sampler(sampler)`

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-05-12 21:56:17 -07:00
Julian Tescher
5a971befac
Import tracing-opentelemetry (#700)
Import `tracing-opentelemetry` from 
https://github.com/jtescher/tracing-opentelemetry

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-04-30 16:32:31 -07: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
Jane Lusby
280b664034
Add tracing-flame crate for generating flamegraphs/flamecharts (#631) 2020-04-21 14:38:41 -07:00
Eliza Weisman
351ac21809
subscriber: prepare to release 0.2.4 (#666)
# 0.2.4 (April 6, 2020)

This release includes several API ergonomics improvements, including
shorthand constructors for many types, and an extension trait for
initializing subscribers using method-chaining style. Additionally,
several bugs in less commonly used `fmt` APIs were fixed.

### Added

- **fmt**: Shorthand free functions for constructing most types in `fmt`
  (including `tracing_subscriber::fmt()` to return a
  `SubscriberBuilder`, `tracing_subscriber::fmt::layer()` to return a
  format `Layer`, etc) (#660)
- **registry**: Shorthand free function `tracing_subscriber::registry()`
  to construct a new registry (#660)
- Added `SubscriberInitExt` extension trait for more ergonomic
  subscriber initialization (#660)
  
### Changed

- **fmt**: Moved `LayerBuilder` methods to `Layer` (#655)

### Deprecated

- **fmt**: `LayerBuilder`, as `Layer` now implements all builder methods
  (#655)
  
### Fixed

- **fmt**: Fixed `Compact` formatter not omitting levels with
  `with_level(false)` (#657)
- **fmt**: Fixed `fmt::Layer` duplicating the fields for a new span if
  another layer has already formatted its fields (#634)
- **fmt**: Added missing space when using `record` to add new fields to
  a span that already has fields (#659)
- Updated outdated documentation (#647)


Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-04-06 10:21:48 -07:00
Eliza Weisman
62e0cc0a03
subscriber: add more ergonomic subscriber configuration APIs (#660)
* subscriber: add less-verbose configuration APIs

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

* even nicer easymode

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

* wip## Motivation

Users have said fairly frequently that configuring new subscribers in an
application is unnecessarily verbose and confusing. We should try to
make this nicer, especially as it's a common "on ramp" for new `tracing`
users.

## Solution 

This branch adds new APIs, inspired by `tonic` and `warp`, that should
make setting up a subscriber a little less verbose. This includes:

- Many modules in `tracing-subscriber` now expose free functions 
  that construct default instances of various types. This makes 
  configuring subscribers using these types more concise, a la `warp`.
- An extension trait for adding `.set_default`, `.init`, and `.try_init` 
  methods to subscribers. This generalizes the similar functions on
  `fmt`'s `SubscriberBuilder` to work with other subscribers.

All the old APIs are still left as they were previously. The new APIs
just provide shorthand for them.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-04-03 18:04:23 -07:00
Eliza Weisman
ae482f3829
examples: fix tower-util deprecation, remove broken examples (#645)
## Motivation

A recent change to `tower-util` contains a deprecation in `ServiceExt`.
The deprecation means that the `deny(warnings)` CI build fails for the
`tower-load` example.

Additionally, the `tower-h2` examples depend on a Git version of
`tower-h2`. These examples are currently commented out, since they used
an earlier version of `tower-h2`, but their dependencies are still
specified in the `examples` crate.

## Solution

I removed the use of the deprecated `ready` method.

Furthermore, I removed the broken `tower-h2` examples, and thus the git
dependency on a different version of Tower. There are 3 other examples
(`tower-client`, `tower-server`, and `tower-load`) that also demonstrate
using `tracing` together with Tower, so these broken examples aren't
really worth keeping around.

This ought to fix CI.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-03-30 12:40:49 -07:00
David Barsky
12fde2dd52
examples: await inner future (#628) 2020-03-10 19:41:21 -04:00
David Barsky
d0a3bdd63d
examples: update to std::future::Future; remove nightly-examples (#557) 2020-03-09 14:15:31 -04:00
Eliza Weisman
83886fcc7c
subscriber: prepare to release 0.2.3 (#625)
# 0.2.3 (March 5, 2020)

### Fixed

- **env-filter**: Regression where filter directives were selected in the order
  they were listed, rather than most specific first (#624)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-03-05 14:49:52 -08:00
Lucio Franco
77e589906d
subscriber: Prepare 0.2.2 release (#609)
### Added

- **fmt**: Added `flatten_event` to `SubscriberBuilder` (#599)
- **fmt**: Added `with_level` to `SubscriberBuilder` (#594)

Signed-off-by: Lucio Franco <luciofranco14@gmail.com>
2020-02-27 16:13:29 -08:00
Jane Lusby
503d93605d
error: add error instrumentation type and traits (#574)
## Motivation

The tracing_error crate should provide some basic functionality for
instrumenting Errors with `SpanTraces` generically. The goal is to make
it easy for users to instrument their errors without needing to add a
`SpanTrace` to every error they construct.

## Solution

Critically this trait provides 3 traits for instrumenting errors,
`InstrumentResult`, `InstrumentError`, and `ExtractSpanTrace`. The first
two traits expose a `in_current_span()` method that can work on a
`Result<T, E: InstrumentError>` and an `Error`, respectively, that wraps
the error type in a `TracedError` that stores the inner error and a
SpanTrace. The third trait, `ExtractSpanTrace`, is used to retrieve the
span_trace member of a `TracedError` from a `&dyn Error` trait object.

This is done by downcasting the error to a `TracedError` and returning
the inner `span_trace` if it is successful. By default this only works
because the inner error is stored in a Box as a trait object, which
prevents it from being part of the type signature for `TracedError`.

However, this crate also exposes a second version of `TracedError` that
does not box the inner error, thus avoiding the need for heap
allocation, which it accomplishes by type erasing the `TracedError<E>`
into a `TracedError<()>` while iterating through the error `source()`
chain.
2020-02-24 16:00:10 -08:00
Eliza Weisman
4dad420ee1
subscriber: prepare to release 0.2.1 (#586)
### Changed

- **filter**: `EnvFilter` directive selection now behaves correctly
  (i.e. like `env_logger`) (#583)

### Fixed

- **filter**: Fixed `EnvFilter` incorrectly allowing less-specific
  filter directives to enable events that are disabled by more-specific
  filters (#583)
- **filter**: Multiple significant `EnvFilter`  performance
  improvements, especially when filtering events generated by `log`
  records (#578, #583)
- **filter**: Replaced `BTreeMap` with `Vec` in `DirectiveSet`,
  improving iteration performance significantly with typical numbers of
  filter directives (#580)

A big thank-you to @samschlegel for lots of help with `EnvFilter` 
performance tuning in this release!

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-02-14 10:56:03 -08:00
Jane Lusby
d1416f17c1
Match changes to std::Backtrace output format (#584)
This PR changes the SpanTrace display format so that it no longer outputs a header prior to the output of the spans, and it changes the debug format to add one without newlines and support pretty formatting when formatting with `{:#?}`. These changes match recent changes made to the format of std::backtrace::Backtrace.
2020-02-13 15:06:22 -08:00
Kevin Liu
de2de896f5
chore: specify path dependencies for workspace crates (#568)
## Motivation

Intra-workspace dependencies can go out of sync if only referencing
crates.io, where changing one crate locally and testing the whole
library will result in errors stemming from two different versions of
the same trait etc. This is hard to keep track of and makes development
more difficult than it needs to be. 

## Solution

Afaik it's common practice to specify both a version and a path as per
[the cargo docs][1]. This is what tokio does with its subcrates too.

[1]: https://github.com/rust-lang/cargo/blob/master/src/doc/src/reference/specifying-dependencies.md#multiple-locations.
2020-02-07 10:54:49 -08:00
Eliza Weisman
6a00e9bbe3
error: prepare to release 0.1.0 (#571)
* error: add additional cargo metadata
* error: update tracing-subscriber to 0.2.0-stable
* error: add standard crate attrs, missing debug
* error: add changelog
* error: add README, improve docs
* error: fix fmt::Debug impl for ErrorLayer
* fix doctest

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-02-05 13:35:09 -08:00
Eliza Weisman
52b2c05bee
error: switch tracing-subscriber to crates.io dependency (#559)
This updates `tracing-error` to depend on `tracing-subscriber` from
crates.io, rather than via a path dependency. This means that git deps
on `tracing-error` should "actually work" now.

Additionally, I've updated the `tracing-subscriber` dep to only enable
the feature flags `tracing-error` requires. This means that depending on
`tracing-error` won't enable `tracing-subscriber`'s default features
unless they are actually needed.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-02-03 12:43:01 -08:00