tracing/tracing-error
Eliza Weisman 30a6556128
error: introduce tracing-error crate (#556)
## Motivation

A lot of folks have expressed interest in being able to capture the
current `tracing` span context when an error type is _constructed_, so
it can eventually be displayed when the error is handled. Since span
entry is stackful, the error may not be formatted or otherwise handled
within a span context that is in any way related to the one where the
error occurred — and this is only made worse when "channels" are
involved.

## Solution

This branch introduces a new crate, `tracing-error`, which will contain
integrations and types for enriching errors with `tracing` span contexts.

Currently, this crate contains the following:

- A `SpanTrace` type, which captures the current span and allows it to be
  inspected later.

- A `Layer` implementation which may be added to a `Subscriber` to 
  enable capturing traces for errors. This layer will format fields and
  insert them into span extensions, **if no other layer has already 
  added such an extension** using the same formatter. This reuses the
  formatting traits from `tracing-subscriber`'s `fmt` module.

## Notes

Note that we have not actually added any new error types or error
wrapper types. I would like to provide these in the future, so that
span capturing can be seamlessly integrated into the rest of the Rust
error handling ecosystem. However, this will take some additional
experimentation. For now, we want to release the `SpanTrace` type so
that other libraries and applications may use _it_ as an integration point.

We'll need to add more documentation and examples for these APIs, and
can do that in follow-up branches.

Closes #464

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Jane Lusby <jlusby@yaah.dev>
2020-02-03 09:52:41 -08:00
..