Skip to content

Commit

Permalink
Merge branch 'master' into instrument-arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw authored May 3, 2021
2 parents d06c7d8 + e1e6c29 commit e73ee61
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
ignore:
- dependency-name: opentelemetry-jaeger
versions:
- 0.12.0
- dependency-name: opentelemetry
versions:
- 0.13.0
- dependency-name: tokio-test
versions:
- 0.4.0
- dependency-name: matchers
versions:
- 0.1.0
- dependency-name: hyper
versions:
- 0.14.2
- dependency-name: tower
versions:
- 0.4.1
- dependency-name: bytes
versions:
- 1.0.0
13 changes: 13 additions & 0 deletions tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,19 @@ where
}
}

impl<'a, T: ?Sized> crate::sealed::Sealed for &'a mut T where T: Value + crate::sealed::Sealed + 'a {}

impl<'a, T: ?Sized> Value for &'a mut T
where
T: Value + 'a,
{
fn record(&self, key: &Field, visitor: &mut dyn Visit) {
// Don't use `(*self).record(key, visitor)`, otherwise would
// cause stack overflow due to `unconditional_recursion`.
T::record(self, key, visitor)
}
}

impl<'a> crate::sealed::Sealed for fmt::Arguments<'a> {}

impl<'a> Value for fmt::Arguments<'a> {
Expand Down
12 changes: 6 additions & 6 deletions tracing-subscriber/src/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,14 +1268,14 @@ pub(crate) mod tests {
.and_then(StringSubscriber2("subscriber_2".into()))
.and_then(StringSubscriber3("subscriber_3".into()))
.with_collector(NopCollector);
let subscriber =
Collect::downcast_ref::<StringSubscriber>(&s).expect("subscriber 2 should downcast");
let subscriber = <dyn Collect>::downcast_ref::<StringSubscriber>(&s)
.expect("subscriber 2 should downcast");
assert_eq!(&subscriber.0, "subscriber_1");
let subscriber =
Collect::downcast_ref::<StringSubscriber2>(&s).expect("subscriber 2 should downcast");
let subscriber = <dyn Collect>::downcast_ref::<StringSubscriber2>(&s)
.expect("subscriber 2 should downcast");
assert_eq!(&subscriber.0, "subscriber_2");
let subscriber =
Collect::downcast_ref::<StringSubscriber3>(&s).expect("subscriber 3 should downcast");
let subscriber = <dyn Collect>::downcast_ref::<StringSubscriber3>(&s)
.expect("subscriber 3 should downcast");
assert_eq!(&subscriber.0, "subscriber_3");
}
}
19 changes: 19 additions & 0 deletions tracing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,25 @@
//! # fn main() {}
//! ```
//!
//! For functions which don't have built-in tracing support and can't have
//! the `#[instrument]` attribute applied (such as from an external crate,
//! the [`Span` struct][`Span`] has a [`in_scope()` method][`in_scope`]
//! which can be used to easily wrap synchonous code in a span.
//!
//! For example:
//! ```rust
//! use tracing::info_span;
//!
//! # fn doc() -> Result<(), ()> {
//! # mod serde_json {
//! # pub(crate) fn from_slice(buf: &[u8]) -> Result<(), ()> { Ok(()) }
//! # }
//! # let buf: [u8; 0] = [];
//! let json = info_span!("json.parse").in_scope(|| serde_json::from_slice(&buf))?;
//! # let _ = json; // suppress unused variable warning
//! # Ok(())
//! # }
//! ```
//!
//! You can find more examples showing how to use this crate [here][examples].
//!
Expand Down

0 comments on commit e73ee61

Please sign in to comment.