Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into dp-target-is-cow
Browse files Browse the repository at this point in the history
* upstream/master:
  opentelemetry: prepare for 0.8.0 release (tokio-rs#1036)
  docs: add favicon for extra pretty docs (tokio-rs#1033)
  subscriber: fix `reload` ergonomics (tokio-rs#1035)
  chore(deps): update crossbeam-channel requirement from 0.4.2 to 0.5.0 (tokio-rs#1031)
  opentelemetry: Assign default ids if missing (tokio-rs#1027)
  chore: remove deprecated add-path from CI (tokio-rs#1026)
  attributes:  fix `#[instrument(err)]` in case of early returns (tokio-rs#1006)
  core: remove mandatory liballoc dependency with no-std (tokio-rs#1017)
  chore(deps): update cfg-if requirement from 0.1.10 to 1.0.0 (tokio-rs#1023)
  • Loading branch information
dvdplm committed Oct 16, 2020
2 parents b250109 + 549c919 commit e29d3ca
Show file tree
Hide file tree
Showing 44 changed files with 829 additions and 549 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
with:
path: ${{ runner.tool_cache }}/cargo-hack/bin
key: cargo-hack-bin-${{ hashFiles('.github/caching/cargo-hack.lock') }}
- run: echo "::add-path::${{ runner.tool_cache }}/cargo-hack/bin"
- run: echo "${{ runner.tool_cache }}/cargo-hack/bin" >> $GITHUB_PATH
# if `cargo-hack` somehow doesn't exist after loading it from the cache,
# make *sure* it's there.
- run: cargo hack --help || { cargo install --force cargo-hack; }
Expand Down Expand Up @@ -303,5 +303,5 @@ jobs:
with:
command: install
args: --root ${{ runner.tool_cache }}/cargo-audit --force cargo-audit
- run: echo "::add-path::${{ runner.tool_cache }}/cargo-audit/bin"
- run: echo "${{ runner.tool_cache }}/cargo-audit/bin" >> $GITHUB_PATH
- run: cargo audit
Binary file added assets/favicon.ico
Binary file not shown.
23 changes: 7 additions & 16 deletions examples/examples/tower-load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,20 @@ impl<T> Service<T> for MakeSvc {
}
}

struct AdminSvc<S> {
handle: Handle<EnvFilter, S>,
struct AdminSvc {
handle: Handle<EnvFilter>,
}

impl<S> Clone for AdminSvc<S> {
impl Clone for AdminSvc {
fn clone(&self) -> Self {
Self {
handle: self.handle.clone(),
}
}
}

impl<'a, S> Service<&'a AddrStream> for AdminSvc<S>
where
S: tracing::Subscriber,
{
type Response = AdminSvc<S>;
impl<'a> Service<&'a AddrStream> for AdminSvc {
type Response = AdminSvc;
type Error = hyper::Error;
type Future = Ready<Result<Self::Response, Self::Error>>;

Expand All @@ -214,10 +211,7 @@ where
}
}

impl<S> Service<Request<Body>> for AdminSvc<S>
where
S: tracing::Subscriber + 'static,
{
impl Service<Request<Body>> for AdminSvc {
type Response = Response<Body>;
type Error = Err;
type Future = Pin<Box<dyn Future<Output = Result<Response<Body>, Err>> + std::marker::Send>>;
Expand Down Expand Up @@ -252,10 +246,7 @@ where
}
}

impl<S> AdminSvc<S>
where
S: tracing::Subscriber + 'static,
{
impl AdminSvc {
fn set_from(&self, bytes: Bytes) -> Result<(), String> {
use std::str;
let body = str::from_utf8(&bytes.as_ref()).map_err(|e| format!("{}", e))?;
Expand Down
2 changes: 1 addition & 1 deletion tracing-appender/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ keywords = ["logging", "tracing", "file-appender", "non-blocking-writer"]
edition = "2018"

[dependencies]
crossbeam-channel = "0.4.2"
crossbeam-channel = "0.5.0"
chrono = "0.4.11"

[dependencies.tracing-subscriber]
Expand Down
1 change: 1 addition & 0 deletions tracing-appender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
#![doc(html_root_url = "https://docs.rs/tracing-appender/0.1.1")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
html_favicon_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/favicon.ico",
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
)]
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
Expand Down
4 changes: 3 additions & 1 deletion tracing-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#![doc(html_root_url = "https://docs.rs/tracing-attributes/0.1.11")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
html_favicon_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/favicon.ico",
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
)]
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
Expand Down Expand Up @@ -468,7 +469,8 @@ fn gen_body(
quote_spanned!(block.span()=>
let __tracing_attr_span = #span;
let __tracing_attr_guard = __tracing_attr_span.enter();
match { #block } {
let f = move || #return_type { #block };
match f() {
Ok(x) => Ok(x),
Err(e) => {
tracing::error!(error = %e);
Expand Down
21 changes: 21 additions & 0 deletions tracing-attributes/tests/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ fn test() {
handle.assert_finished();
}

#[instrument(err)]
fn err_early_return() -> Result<u8, TryFromIntError> {
u8::try_from(1234)?;
Ok(5)
}

#[test]
fn test_early_return() {
let span = span::mock().named("err_early_return");
let (subscriber, handle) = subscriber::mock()
.new_span(span.clone())
.enter(span.clone())
.event(event::mock().at_level(Level::ERROR))
.exit(span.clone())
.drop_span(span)
.done()
.run_with_handle();
with_default(subscriber, || err_early_return().ok());
handle.assert_finished();
}

#[instrument(err)]
async fn err_async(polls: usize) -> Result<u8, TryFromIntError> {
let future = PollN::new_ok(polls);
Expand Down
3 changes: 2 additions & 1 deletion tracing-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ edition = "2018"

[features]
default = ["std"]
std = ["lazy_static"]
alloc = []
std = ["lazy_static", "alloc"]

[badges]
maintenance = { status = "actively-developed" }
Expand Down
Loading

0 comments on commit e29d3ca

Please sign in to comment.