Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into dp-always-pass-di…
Browse files Browse the repository at this point in the history
…spatch-as-owned-tokio-rs#455

* upstream/master: (34 commits)
  subscriber: remove TraceLogger (tokio-rs#1052)
  subscriber: make Registry::enter/exit much faster (tokio-rs#1058)
  chore(deps): update env_logger requirement from 0.7 to 0.8 (tokio-rs#1050)
  chore: fix tracing-macros::dbg (tokio-rs#1054)
  chore(deps): update pin-project requirement from 0.4 to 1.0 (tokio-rs#1038)
  chore: remove duplicated section from tracing/README.md (tokio-rs#1046)
  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)
  subscriber: warn if trying to enable a statically disabled level (tokio-rs#990)
  subscriber: use macros for module declarations (tokio-rs#1009)
  chore: remove `stdlib.rs` (tokio-rs#1008)
  core: fix linked list tests reusing `Registration`s (tokio-rs#1016)
  subscriber: support dash in target names (tokio-rs#1012)
  ...
  • Loading branch information
dvdplm committed Oct 22, 2020
2 parents d7c449e + 0dc8ef2 commit bd22923
Show file tree
Hide file tree
Showing 99 changed files with 2,049 additions and 1,901 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, 1.40.0]
rust: [stable, 1.42.0]
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
Expand Down 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 @@ -145,7 +145,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta, nightly, 1.40.0]
rust: [stable, beta, nightly, 1.42.0]
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
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
26 changes: 26 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cargo",
"command": "build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo build"
},
{
"type": "cargo",
"command": "clippy",
"args": [
"--all"
],
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo clippy"
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ attachment that `Future::instrument` does.
## Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.40. The current Tracing version is not guaranteed to build on Rust
version is 1.42. The current Tracing version is not guaranteed to build on Rust
versions earlier than the minimum supported version.

Tracing follows the same compiler support policies as the rest of the Tokio
Expand Down
Binary file added assets/favicon.ico
Binary file not shown.
14 changes: 7 additions & 7 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ default = []
[dev-dependencies]

# tracing crates
tracing = { path = "../tracing", version = "0.1"}
tracing-core = { path = "../tracing-core", version = "0.1"}
tracing = { path = "../tracing", version = "0.2"}
tracing-core = { path = "../tracing-core", version = "0.2"}
tracing-error = { path = "../tracing-error" }
tracing-flame = { path = "../tracing-flame" }
tracing-tower = { version = "0.1.0", path = "../tracing-tower" }
tracing-subscriber = { path = "../tracing-subscriber", version = "0.2.12", features = ["json", "chrono"] }
tracing-futures = { version = "0.2.1", path = "../tracing-futures", features = ["futures-01"] }
tracing-attributes = { path = "../tracing-attributes", version = "0.1.2"}
tracing-log = { path = "../tracing-log", version = "0.1.1", features = ["env_logger"] }
tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", features = ["json", "chrono"] }
tracing-futures = { version = "0.3", path = "../tracing-futures", features = ["futures-01"] }
tracing-attributes = { path = "../tracing-attributes", version = "0.2"}
tracing-log = { path = "../tracing-log", version = "0.2", features = ["env_logger"] }
tracing-serde = { path = "../tracing-serde" }
tracing-opentelemetry = { path = "../tracing-opentelemetry" }
tracing-journald = { path = "../tracing-journald" }
Expand All @@ -30,7 +30,7 @@ futures = "0.3"
tokio = { version = "0.2.12", features = ["full"] }

# env-logger example
env_logger = "0.7"
env_logger = "0.8"

# tower examples
tower = "0.3"
Expand Down
7 changes: 7 additions & 0 deletions examples/examples/all-levels.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
use tracing::Level;

#[no_mangle]
#[inline(never)]
pub fn event() {
tracing::info!("general informational messages relevant to users");
}

fn main() {
tracing_subscriber::fmt()
// all spans/events with a level higher than TRACE (e.g, info, warn, etc.)
// will be written to stdout.
.with_max_level(Level::TRACE)
// sets this to be the default, global subscriber for this application.
.init();
event();

tracing::error!("SOMETHING IS SERIOUSLY WRONG!!!");
tracing::warn!("important informational messages; might indicate an error");
Expand Down
126 changes: 61 additions & 65 deletions examples/examples/hyper-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,75 @@ async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
uri = ?req.uri(),
headers = ?req.headers()
);
let _enter = span.enter();
info!("received request");
let mut response = Response::new(Body::empty());
async move {
info!("received request");
let mut response = Response::new(Body::empty());

let (rsp_span, resp) = match (req.method(), req.uri().path()) {
// Serve some instructions at /
(&Method::GET, "/") => {
const BODY: &str = "Try POSTing data to /echo";
*response.body_mut() = Body::from(BODY);
(span!(Level::INFO, "response", body = %(&BODY)), response)
}
match (req.method(), req.uri().path()) {
// Serve some instructions at /
(&Method::GET, "/") => {
const BODY: &str = "Try POSTing data to /echo";
*response.body_mut() = Body::from(BODY);
info!(body = %(&BODY), "response",);
Ok(response)
}

// Simply echo the body back to the client.
(&Method::POST, "/echo") => {
let span = span!(Level::INFO, "response", response_kind = %"echo");
*response.body_mut() = req.into_body();
(span, response)
}
// Simply echo the body back to the client.
(&Method::POST, "/echo") => {
info!(response_kind = %"echo", "response");
*response.body_mut() = req.into_body();
Ok(response)
}

// Convert to uppercase before sending back to client.
(&Method::POST, "/echo/uppercase") => {
let body = hyper::body::to_bytes(req).await?;
let upper = body
.iter()
.map(|byte| byte.to_ascii_uppercase())
.collect::<Vec<u8>>();
debug!(
body = ?str::from_utf8(&body[..]),
uppercased = ?str::from_utf8(&upper[..]),
"uppercased request body"
);
// Convert to uppercase before sending back to client.
(&Method::POST, "/echo/uppercase") => {
let body = hyper::body::to_bytes(req).await?;
let upper = body
.iter()
.map(|byte| byte.to_ascii_uppercase())
.collect::<Vec<u8>>();
debug!(
body = ?str::from_utf8(&body[..]),
uppercased = ?str::from_utf8(&upper[..]),
"uppercased request body"
);

*response.body_mut() = Body::from(upper);
(
span!(Level::INFO, "response", response_kind = %"uppercase"),
response,
)
}
info!(response_kind = %"uppercase", "response");
*response.body_mut() = Body::from(upper);
Ok(response)
}

// Reverse the entire body before sending back to the client.
(&Method::POST, "/echo/reversed") => {
let span = span!(Level::TRACE, "response", response_kind = %"reversed");
let _enter = span.enter();
let body = hyper::body::to_bytes(req).await?;
let reversed = body.iter().rev().cloned().collect::<Vec<u8>>();
debug!(
body = ?str::from_utf8(&body[..]),
"reversed request body"
);
*response.body_mut() = Body::from(reversed);
(
span!(Level::INFO, "reversed", body = ?(&response.body())),
response,
)
}
// Reverse the entire body before sending back to the client.
(&Method::POST, "/echo/reversed") => {
async move {
let body = hyper::body::to_bytes(req).await?;
let reversed = body.iter().rev().cloned().collect::<Vec<u8>>();
debug!(
body = ?str::from_utf8(&body[..]),
"reversed request body"
);
*response.body_mut() = Body::from(reversed);
info!(body = ?(&response.body()), "response");
Ok(response)
}
.instrument(span!(Level::TRACE, "response", response_kind = %"reversed"))
.await
}

// The 404 Not Found route...
_ => {
*response.status_mut() = StatusCode::NOT_FOUND;
(
span!(
Level::TRACE,
"response",
// The 404 Not Found route...
_ => {
*response.status_mut() = StatusCode::NOT_FOUND;
info!(
body = ?(),
status = ?StatusCode::NOT_FOUND,
),
response,
)
"response",
);
Ok(response)
}
}
};
let f = async { resp }.instrument(rsp_span);
Ok(f.await)
}
.instrument(span)
.await
}

#[tokio::main]
Expand All @@ -107,14 +104,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let local_addr: std::net::SocketAddr = ([127, 0, 0, 1], 3000).into();
let server_span = span!(Level::TRACE, "server", %local_addr);
let _enter = server_span.enter();

let service = make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(echo)) });
let server = Server::bind(&local_addr)
.serve(service)
.instrument(server_span.clone());

info!("listening...");
info!(parent: &server_span, "listening...");
server.await?;

Ok(())
Expand Down
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
8 changes: 4 additions & 4 deletions tracing-appender/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tracing-appender"
version = "0.1.1"
version = "0.2.0"
authors = [
"Zeki Sherif <zekshi@amazon.com>",
"Tokio Contributors <team@tokio.rs>"
Expand All @@ -20,15 +20,15 @@ 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]
path = "../tracing-subscriber"
version = "0.2.7"
version = "0.3"
default-features = false
features = ["fmt"]

[dev-dependencies]
tracing = { path = "../tracing", version = "0.1" }
tracing = { path = "../tracing", version = "0.2" }
tempdir = "0.3"
4 changes: 2 additions & 2 deletions tracing-appender/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allows events and spans to be recorded in a non-blocking manner through a
dedicated logging thread. It also provides a [`RollingFileAppender`][file_appender]
that can be used with _or_ without the non-blocking writer.

*Compiler support: [requires `rustc` 1.40+][msrv]*
*Compiler support: [requires `rustc` 1.42+][msrv]*

[msrv]: #supported-rust-versions

Expand Down Expand Up @@ -146,7 +146,7 @@ fn main() {
## Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.40. The current Tracing version is not guaranteed to build on Rust
version is 1.42. The current Tracing version is not guaranteed to build on Rust
versions earlier than the minimum supported version.

Tracing follows the same compiler support policies as the rest of the Tokio
Expand Down
Loading

0 comments on commit bd22923

Please sign in to comment.