mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
chore: remove tracing. (#1680)
Historically, logging has been added haphazardly. Here, we entirely remove logging as none of it is particularly useful. In the future, we will add tracing back in order to expose useful data to the user of Tokio.
This commit is contained in:
@@ -29,8 +29,6 @@ thread-pool = ["num_cpus"]
|
||||
futures-util-preview = { version = "=0.3.0-alpha.19", features = ["channel"] }
|
||||
tokio-sync = { version = "=0.2.0-alpha.6", optional = true, path = "../tokio-sync" }
|
||||
|
||||
tracing = { version = "0.1.5", optional = true }
|
||||
|
||||
# current-thread dependencies
|
||||
crossbeam-channel = { version = "0.3.8", optional = true }
|
||||
|
||||
|
||||
@@ -71,10 +71,6 @@ macro_rules! thread_local {
|
||||
#[macro_use]
|
||||
mod tests;
|
||||
|
||||
#[cfg(any(feature = "current-thread", feature = "threadpool"))]
|
||||
#[macro_use]
|
||||
mod tracing;
|
||||
|
||||
mod enter;
|
||||
mod error;
|
||||
mod executor;
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
#![allow(unused_macros)]
|
||||
|
||||
//! This module provides a small facade that wraps the `tracing` APIs we use, so
|
||||
//! that when the `tracing` dependency is disabled, `tracing`'s macros expand to
|
||||
//! no-ops.
|
||||
//!
|
||||
//! This means we don't have to put a `#[cfg(feature = "tracing")]` on every
|
||||
//! individual use of a `tracing` macro.
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct Span {}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! trace {
|
||||
($($arg:tt)+) => {
|
||||
tracing::trace!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! trace {
|
||||
($($arg:tt)+) => {};
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! debug {
|
||||
($($arg:tt)+) => {
|
||||
tracing::debug!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! debug {
|
||||
($($arg:tt)+) => {};
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! warn {
|
||||
($($arg:tt)+) => {
|
||||
tracing::warn!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! warn {
|
||||
($($arg:tt)+) => {};
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! error {
|
||||
($($arg:tt)+) => {
|
||||
tracing::error!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! error {
|
||||
($($arg:tt)+) => {};
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! trace_span {
|
||||
($($arg:tt)+) => {
|
||||
tracing::trace_span!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! trace_span {
|
||||
($($arg:tt)+) => {
|
||||
crate::tracing::Span::new()
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
impl Span {
|
||||
pub(crate) fn new() -> Self {
|
||||
Span {}
|
||||
}
|
||||
|
||||
pub(crate) fn enter(&self) -> Span {
|
||||
Span {}
|
||||
}
|
||||
}
|
||||
@@ -59,15 +59,12 @@ uds = [
|
||||
"iovec",
|
||||
"libc",
|
||||
]
|
||||
log = ["tracing/log"]
|
||||
|
||||
[dependencies]
|
||||
tokio-executor = { version = "=0.2.0-alpha.6", features = ["blocking"], path = "../tokio-executor" }
|
||||
tokio-io = { version = "=0.2.0-alpha.6", path = "../tokio-io" }
|
||||
tokio-sync = { version = "=0.2.0-alpha.6", path = "../tokio-sync" }
|
||||
|
||||
tracing = { version = "0.1.5", optional = true }
|
||||
|
||||
# driver implementation
|
||||
crossbeam-utils = "0.6.0"
|
||||
futures-core-preview = "=0.3.0-alpha.19"
|
||||
@@ -98,9 +95,6 @@ version = "0.3"
|
||||
default-features = false
|
||||
optional = true
|
||||
|
||||
[target.'cfg(test)'.dependencies]
|
||||
tracing = { version = "0.1.5", features = ["log"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
||||
tokio-test = { version = "=0.2.0-alpha.6", path = "../tokio-test" }
|
||||
|
||||
@@ -210,7 +210,6 @@ impl Reactor {
|
||||
self.inner.io_dispatch.read().is_empty()
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(level = "debug"))]
|
||||
fn poll(&mut self, max_wait: Option<Duration>) -> io::Result<()> {
|
||||
// Block waiting for an event to happen, peeling out how many events
|
||||
// happened.
|
||||
@@ -221,17 +220,8 @@ impl Reactor {
|
||||
|
||||
// Process all the events that came in, dispatching appropriately
|
||||
|
||||
// event count is only used for tracing instrumentation.
|
||||
#[cfg(feature = "tracing")]
|
||||
let mut events = 0;
|
||||
|
||||
for event in self.events.iter() {
|
||||
#[cfg(feature = "tracing")]
|
||||
{
|
||||
events += 1;
|
||||
}
|
||||
let token = event.token();
|
||||
trace!(event.readiness = ?event.readiness(), event.token = ?token);
|
||||
|
||||
if token == TOKEN_WAKEUP {
|
||||
self.inner
|
||||
@@ -243,8 +233,6 @@ impl Reactor {
|
||||
}
|
||||
}
|
||||
|
||||
trace!(message = "loop process", events);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -400,7 +388,6 @@ impl Inner {
|
||||
};
|
||||
|
||||
let token = aba_guard | key;
|
||||
debug!(message = "adding I/O source", token);
|
||||
|
||||
self.io.register(
|
||||
source,
|
||||
@@ -418,13 +405,11 @@ impl Inner {
|
||||
}
|
||||
|
||||
pub(super) fn drop_source(&self, token: usize) {
|
||||
debug!(message = "dropping I/O source", token);
|
||||
self.io_dispatch.write().remove(token);
|
||||
}
|
||||
|
||||
/// Registers interest in the I/O resource associated with `token`.
|
||||
pub(super) fn register(&self, token: usize, dir: Direction, w: Waker) {
|
||||
debug!(message = "scheduling", direction = ?dir, token);
|
||||
let io_dispatch = self.io_dispatch.read();
|
||||
let sched = io_dispatch.get(token).unwrap();
|
||||
|
||||
|
||||
@@ -235,7 +235,6 @@ impl Registration {
|
||||
|
||||
if ready.is_empty() {
|
||||
if let Some(cx) = cx {
|
||||
debug!(message = "scheduling", ?direction, token = self.token);
|
||||
// Update the task info
|
||||
match direction {
|
||||
Direction::Read => sched.reader.register_by_ref(cx.waker()),
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
//! [`Registration`]: struct.Registration.html
|
||||
//! [`PollEvented`]: struct.PollEvented.html
|
||||
//! [reactor module]: https://docs.rs/tokio/0.1/tokio/reactor/index.html
|
||||
#[macro_use]
|
||||
mod tracing;
|
||||
|
||||
mod addr;
|
||||
pub use addr::ToSocketAddrs;
|
||||
|
||||
@@ -69,12 +69,11 @@ impl<T: Wait> OrphanQueue<T> for AtomicOrphanQueue<T> {
|
||||
while let Ok(mut orphan) = self.queue.pop() {
|
||||
match orphan.try_wait() {
|
||||
Ok(Some(_)) => {}
|
||||
Err(e) => error!(
|
||||
message = "leaking orphaned process due to try_wait() error",
|
||||
orphan.id =orphan.id(),
|
||||
error = %e,
|
||||
),
|
||||
|
||||
Err(_) => {
|
||||
// TODO: bubble up error some how. Is this an internal bug?
|
||||
// Shoudl we panic? Is it OK for this to be silently
|
||||
// dropped?
|
||||
}
|
||||
// Still not done yet, we need to put it back in the queue
|
||||
// when were done draining it, so that we don't get stuck
|
||||
// in an infinite loop here
|
||||
|
||||
@@ -659,7 +659,6 @@ impl TcpStream {
|
||||
unsafe {
|
||||
buf.advance_mut(n);
|
||||
}
|
||||
trace!(tcp.written.bytes = n);
|
||||
Poll::Ready(Ok(n))
|
||||
}
|
||||
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
//! This module provides a small facade that wraps the `tracing` APIs we use, so
|
||||
//! that when the `tracing` dependency is disabled, `tracing`'s macros expand to
|
||||
//! no-ops.
|
||||
//!
|
||||
//! This means we don't have to put a `#[cfg(feature = "tracing")]` on every
|
||||
//! individual use of a `tracing` macro.
|
||||
|
||||
// The macros in this module may or may not be used depending on the combination
|
||||
// of feature flags enabled. Rather than feature-flagging each individual macro
|
||||
// to only be defined when the features that use it are enabled, just allow
|
||||
// unused macros in some cases.
|
||||
#![allow(unused_macros)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct Span {}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! trace {
|
||||
($($arg:tt)+) => {
|
||||
tracing::trace!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! trace {
|
||||
($($arg:tt)+) => {{}};
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! debug {
|
||||
($($arg:tt)+) => {
|
||||
tracing::debug!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! debug {
|
||||
($($arg:tt)+) => {{}};
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! error {
|
||||
($($arg:tt)+) => {
|
||||
tracing::error!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! error {
|
||||
($($arg:tt)+) => {{}};
|
||||
}
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
macro_rules! trace_span {
|
||||
($($arg:tt)+) => {
|
||||
tracing::trace_span!($($arg)+)
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
macro_rules! trace_span {
|
||||
($($arg:tt)+) => {
|
||||
crate::tracing::Span::new()
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tracing"))]
|
||||
impl Span {
|
||||
pub(crate) fn new() -> Self {
|
||||
Span {}
|
||||
}
|
||||
|
||||
pub(crate) fn enter(&self) -> Span {
|
||||
Span {}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
#![cfg(feature = "process")]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||
use tokio_net::process::{Child, Command};
|
||||
|
||||
@@ -38,10 +35,7 @@ async fn feed_cat(mut cat: Child, n: usize) -> io::Result<ExitStatus> {
|
||||
|
||||
// Produce n lines on the child's stdout.
|
||||
let write = async {
|
||||
debug!("starting to feed");
|
||||
|
||||
for i in 0..n {
|
||||
debug!("sending line {} to child", i);
|
||||
let bytes = format!("line {}\n", i).into_bytes();
|
||||
stdin.write_all(&bytes).await.unwrap();
|
||||
}
|
||||
@@ -56,8 +50,6 @@ async fn feed_cat(mut cat: Child, n: usize) -> io::Result<ExitStatus> {
|
||||
// Try to read `n + 1` lines, ensuring the last one is empty
|
||||
// (i.e. EOF is reached after `n` lines.
|
||||
loop {
|
||||
debug!("starting read from child");
|
||||
|
||||
let data = reader
|
||||
.next()
|
||||
.await
|
||||
@@ -67,11 +59,6 @@ async fn feed_cat(mut cat: Child, n: usize) -> io::Result<ExitStatus> {
|
||||
let num_read = data.len();
|
||||
let done = num_lines >= n;
|
||||
|
||||
debug!(
|
||||
"read line {} from child ({} bytes, done: {})",
|
||||
num_lines, num_read, done
|
||||
);
|
||||
|
||||
match (done, num_read) {
|
||||
(false, 0) => panic!("broken pipe"),
|
||||
(true, n) if n != 0 => panic!("extraneous data"),
|
||||
|
||||
@@ -52,13 +52,11 @@ rt-full = [
|
||||
"timer",
|
||||
"tokio-executor/current-thread",
|
||||
"tokio-executor/thread-pool",
|
||||
"tracing-core",
|
||||
]
|
||||
signal = ["tokio-net/signal"]
|
||||
sync = ["tokio-sync"]
|
||||
tcp = ["io", "tokio-net/tcp"]
|
||||
timer = ["crossbeam-utils", "slab"]
|
||||
tracing = ["tracing-core"]
|
||||
udp = ["io", "tokio-net/udp"]
|
||||
uds = ["io", "tokio-net/uds"]
|
||||
process = ["io", "tokio-net/process"]
|
||||
@@ -78,11 +76,6 @@ tokio-executor = { version = "=0.2.0-alpha.6", optional = true, path = "../tokio
|
||||
tokio-macros = { version = "=0.2.0-alpha.6", optional = true, path = "../tokio-macros" }
|
||||
tokio-net = { version = "=0.2.0-alpha.6", optional = true, features = ["async-traits"], path = "../tokio-net" }
|
||||
tokio-sync = { version = "=0.2.0-alpha.6", optional = true, path = "../tokio-sync", features = ["async-traits"] }
|
||||
tracing-core = { version = "0.1", optional = true }
|
||||
|
||||
[target.'cfg(feature = "tracing")'.dependencies]
|
||||
tokio-net = { version = "=0.2.0-alpha.6", optional = true, path = "../tokio-net", features = ["tracing", "async-traits"] }
|
||||
tokio-executor = { version = "=0.2.0-alpha.6", optional = true, path = "../tokio-executor", features = ["tracing"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio-test = { version = "=0.2.0-alpha.6", path = "../tokio-test" }
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::timer::timer::{self, Timer};
|
||||
use tokio_executor::thread_pool;
|
||||
use tokio_net::driver::{self, Reactor};
|
||||
|
||||
use tracing_core as trace;
|
||||
use std::{fmt, io};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -241,13 +240,6 @@ impl Builder {
|
||||
// Get a handle to the clock for the runtime.
|
||||
let clock = self.clock.clone();
|
||||
|
||||
// Get the current trace dispatcher.
|
||||
// TODO(eliza): when `tokio-trace-core` is stable enough to take a
|
||||
// public API dependency, we should allow users to set a custom
|
||||
// subscriber for the runtime.
|
||||
let dispatch = trace::dispatcher::get_default(trace::Dispatch::clone);
|
||||
let trace = dispatch.clone();
|
||||
|
||||
let around_reactor_handles = reactor_handles.clone();
|
||||
let around_timer_handles = timer_handles.clone();
|
||||
|
||||
@@ -260,17 +252,15 @@ impl Builder {
|
||||
let _reactor = driver::set_default(&around_reactor_handles[index]);
|
||||
clock::with_default(&clock, || {
|
||||
let _timer = timer::set_default(&around_timer_handles[index]);
|
||||
trace::dispatcher::with_default(&dispatch, || {
|
||||
if let Some(after_start) = after_start.as_ref() {
|
||||
after_start();
|
||||
}
|
||||
if let Some(after_start) = after_start.as_ref() {
|
||||
after_start();
|
||||
}
|
||||
|
||||
next();
|
||||
next();
|
||||
|
||||
if let Some(before_stop) = before_stop.as_ref() {
|
||||
before_stop();
|
||||
}
|
||||
})
|
||||
if let Some(before_stop) = before_stop.as_ref() {
|
||||
before_stop();
|
||||
}
|
||||
})
|
||||
})
|
||||
.build_with_park(move |index| {
|
||||
@@ -286,7 +276,6 @@ impl Builder {
|
||||
pool,
|
||||
reactor_handles,
|
||||
timer_handles,
|
||||
trace,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ use crate::timer::timer;
|
||||
use tokio_executor::thread_pool::ThreadPool;
|
||||
use tokio_net::driver;
|
||||
|
||||
use tracing_core as trace;
|
||||
use std::future::Future;
|
||||
use std::io;
|
||||
|
||||
@@ -47,9 +46,6 @@ struct Inner {
|
||||
|
||||
/// Timer handles
|
||||
timer_handles: Vec<timer::Handle>,
|
||||
|
||||
/// Tracing dispatcher
|
||||
trace: trace::Dispatch,
|
||||
}
|
||||
|
||||
// ===== impl Runtime =====
|
||||
@@ -137,14 +133,10 @@ impl Runtime {
|
||||
where
|
||||
F: Future,
|
||||
{
|
||||
let trace = &self.inner().trace;
|
||||
|
||||
let _reactor = driver::set_default(&self.inner().reactor_handles[0]);
|
||||
let _timer = timer::set_default(&self.inner().timer_handles[0]);
|
||||
|
||||
trace::dispatcher::with_default(trace, || {
|
||||
self.inner().pool.block_on(future)
|
||||
})
|
||||
self.inner().pool.block_on(future)
|
||||
}
|
||||
|
||||
/// Return a handle to the runtime's spawner.
|
||||
|
||||
Reference in New Issue
Block a user