diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 899dabd..7e36884 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,12 +44,12 @@ jobs: run: sccache --zero-stats > /dev/null - name: Run test with codecov - run: cargo llvm-cov --no-report nextest --all-features --features minitrace/enable + run: cargo llvm-cov --no-report nextest --all-features --features fastrace/enable - name: Run example with codecov run: | cargo llvm-cov --no-report run --example proxy - cargo llvm-cov --no-report run --example tracing --features minitrace/enable + cargo llvm-cov --no-report run --example tracing --features fastrace/enable - name: Run bench with codecov run: | diff --git a/Cargo.toml b/Cargo.toml index c654c75..c9f3104 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ futures = "0.3" futures-async-stream = "0.2" log = "0.4" lru = "0.12" -minitrace = "0.6" +fastrace = "0.6" parking_lot = "0.12" pin-project-lite = "0.2" rand = "0.8" diff --git a/README.md b/README.md index 1acc2f7..5cbb841 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Yet another project rewritten in Rust. - Support `Unreliable`, `Reliable` and `ReliableOrdered` packets. - Support multiple order channels. - Support `ACK`/`NACK` mechanism. -- Full tracing powered by [minitrace-rust](https://github.com/tikv/minitrace-rust). +- Full tracing powered by [fastrace](https://github.com/fastracelabs/fastrace). - You can track a packet's span during deduplication, fragmentation, ... ## Roadmap diff --git a/examples/tracing.rs b/examples/tracing.rs index ea718bb..0b01284 100644 --- a/examples/tracing.rs +++ b/examples/tracing.rs @@ -5,9 +5,9 @@ use std::process::exit; use std::time::Duration; use bytes::Bytes; +use fastrace::collector::{SpanContext, SpanId, SpanRecord, TraceId}; +use fastrace::Span; use futures::{SinkExt, StreamExt}; -use minitrace::collector::{SpanContext, SpanId, SpanRecord, TraceId}; -use minitrace::Span; use raknet_rs::client::{self, ConnectTo}; use raknet_rs::io::{TraceInfo, IO}; use raknet_rs::server::{self, MakeIncoming}; @@ -16,10 +16,10 @@ use tokio::net::UdpSocket; #[tokio::main] async fn main() -> Result<(), Box> { - let (reporter, spans) = minitrace::collector::TestReporter::new(); - minitrace::set_reporter( + let (reporter, spans) = fastrace::collector::TestReporter::new(); + fastrace::set_reporter( reporter, - minitrace::collector::Config::default().report_before_root_finish(true), + fastrace::collector::Config::default().report_before_root_finish(true), ); let socket = UdpSocket::bind("127.0.0.1:0").await?; @@ -45,9 +45,7 @@ async fn main() -> Result<(), Box> { loop { if let Some(data) = read.next().await { let trace_id = read.last_trace_id().unwrap_or_else(|| { - eprintln!( - "Please run with `--features minitrace/enable` and try again" - ); + eprintln!("Please run with `--features fastrace/enable` and try again"); exit(0) }); let root_span = Span::root( @@ -71,7 +69,7 @@ async fn main() -> Result<(), Box> { client(local_addr).await?; - minitrace::flush(); + fastrace::flush(); display(spans.lock().clone()); Ok(()) } diff --git a/src/client/conn/tokio.rs b/src/client/conn/tokio.rs index 8f27bb8..5820303 100644 --- a/src/client/conn/tokio.rs +++ b/src/client/conn/tokio.rs @@ -2,8 +2,8 @@ use std::io; use std::net::ToSocketAddrs; use std::sync::Arc; +use fastrace::Span; use futures::StreamExt; -use minitrace::Span; use tokio::net::UdpSocket as TokioUdpSocket; use super::ConnectTo; diff --git a/src/codec/decoder/body.rs b/src/codec/decoder/body.rs index a4f1bfb..7e9ee01 100644 --- a/src/codec/decoder/body.rs +++ b/src/codec/decoder/body.rs @@ -1,9 +1,9 @@ use std::pin::Pin; use std::task::{Context, Poll}; +use fastrace::local::LocalSpan; +use fastrace::Event; use futures::{ready, Stream, StreamExt}; -use minitrace::local::LocalSpan; -use minitrace::Event; use pin_project_lite::pin_project; use crate::errors::CodecError; diff --git a/src/codec/decoder/dedup.rs b/src/codec/decoder/dedup.rs index 61779d7..15c78c5 100644 --- a/src/codec/decoder/dedup.rs +++ b/src/codec/decoder/dedup.rs @@ -1,8 +1,8 @@ use std::pin::Pin; use std::task::{Context, Poll}; +use fastrace::Span; use futures::{ready, Stream, StreamExt}; -use minitrace::Span; use pin_project_lite::pin_project; use crate::errors::CodecError; diff --git a/src/codec/decoder/fragment.rs b/src/codec/decoder/fragment.rs index 29934e2..7c74a07 100644 --- a/src/codec/decoder/fragment.rs +++ b/src/codec/decoder/fragment.rs @@ -5,9 +5,9 @@ use std::pin::Pin; use std::task::{Context, Poll}; use bytes::BufMut; +use fastrace::{Event, Span}; use futures::{ready, Stream, StreamExt}; use lru::LruCache; -use minitrace::{Event, Span}; use pin_project_lite::pin_project; use crate::errors::CodecError; diff --git a/src/codec/decoder/mod.rs b/src/codec/decoder/mod.rs index 20b45fb..a4b4e44 100644 --- a/src/codec/decoder/mod.rs +++ b/src/codec/decoder/mod.rs @@ -6,8 +6,8 @@ mod ordered; use std::pin::Pin; use std::task::{Context, Poll}; +use fastrace::Span; use futures::Stream; -use minitrace::Span; use pin_project_lite::pin_project; pub(super) use self::body::*; diff --git a/src/codec/decoder/ordered.rs b/src/codec/decoder/ordered.rs index 17cfa4d..feef3c9 100644 --- a/src/codec/decoder/ordered.rs +++ b/src/codec/decoder/ordered.rs @@ -3,9 +3,9 @@ use std::pin::Pin; use std::task::{Context, Poll}; use bytes::Buf; +use fastrace::{Event, Span}; use futures::{ready, Stream, StreamExt}; use log::warn; -use minitrace::{Event, Span}; use pin_project_lite::pin_project; use crate::errors::CodecError; diff --git a/src/codec/frame.rs b/src/codec/frame.rs index 6acbbc8..a426978 100644 --- a/src/codec/frame.rs +++ b/src/codec/frame.rs @@ -4,9 +4,9 @@ use std::pin::Pin; use std::task::{ready, Context, Poll}; use bytes::{Buf, BytesMut}; +use fastrace::{Event, Span}; use futures::{Sink, Stream}; use log::error; -use minitrace::{Event, Span}; use super::AsyncSocket; use crate::errors::CodecError; diff --git a/src/io.rs b/src/io.rs index a108df7..8279e3d 100644 --- a/src/io.rs +++ b/src/io.rs @@ -2,8 +2,8 @@ use std::pin::Pin; use std::task::{Context, Poll}; use bytes::Bytes; +use fastrace::collector::TraceId; use futures::{Future, Sink, SinkExt, Stream}; -use minitrace::collector::TraceId; use pin_project_lite::pin_project; use crate::errors::Error; diff --git a/src/server/handler/offline.rs b/src/server/handler/offline.rs index 1d352df..7cd4c01 100644 --- a/src/server/handler/offline.rs +++ b/src/server/handler/offline.rs @@ -5,10 +5,10 @@ use std::pin::Pin; use std::task::{Context, Poll}; use bytes::Bytes; +use fastrace::collector::SpanContext; +use fastrace::Span; use futures::{ready, Sink, Stream}; use log::{debug, error, trace, warn}; -use minitrace::collector::SpanContext; -use minitrace::Span; use pin_project_lite::pin_project; use crate::errors::CodecError; diff --git a/src/server/incoming/tokio.rs b/src/server/incoming/tokio.rs index 4f92988..b519e59 100644 --- a/src/server/incoming/tokio.rs +++ b/src/server/incoming/tokio.rs @@ -5,10 +5,10 @@ use std::sync::Arc; use std::task::{ready, Context, Poll}; use concurrent_queue::ConcurrentQueue; +use fastrace::collector::SpanContext; +use fastrace::Span; use futures::Stream; use log::{debug, error}; -use minitrace::collector::SpanContext; -use minitrace::Span; use pin_project_lite::pin_project; use tokio::net::UdpSocket as TokioUdpSocket; diff --git a/src/utils/minitrace.rs b/src/utils/fastrace.rs similarity index 96% rename from src/utils/minitrace.rs rename to src/utils/fastrace.rs index 4d4affb..b0077df 100644 --- a/src/utils/minitrace.rs +++ b/src/utils/fastrace.rs @@ -1,9 +1,9 @@ use std::pin::Pin; use std::task::{Context, Poll}; +use fastrace::collector::{SpanContext, TraceId}; +use fastrace::Span; use futures::Stream; -use minitrace::collector::{SpanContext, TraceId}; -use minitrace::Span; use pin_project_lite::pin_project; use crate::io::TraceInfo; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 654ef61..cd909a0 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,12 +1,12 @@ mod bit_queue; +mod fastrace; mod log; -mod minitrace; mod reactor; mod seq_num; pub(crate) use self::bit_queue::*; +pub(crate) use self::fastrace::*; pub(crate) use self::log::*; -pub(crate) use self::minitrace::*; pub(crate) use self::reactor::*; pub(crate) use self::seq_num::*; diff --git a/src/utils/tests.rs b/src/utils/tests.rs index 0b9f405..5350afb 100644 --- a/src/utils/tests.rs +++ b/src/utils/tests.rs @@ -3,7 +3,7 @@ use std::sync::atomic::AtomicBool; use std::sync::Arc; use std::task::Waker; -use minitrace::collector::{SpanId, SpanRecord, TraceId}; +use fastrace::collector::{SpanId, SpanRecord, TraceId}; use parking_lot::Mutex; pub(crate) struct TestTraceLogGuard { @@ -13,7 +13,7 @@ pub(crate) struct TestTraceLogGuard { impl Drop for TestTraceLogGuard { #[allow(clippy::print_stderr)] fn drop(&mut self) { - minitrace::flush(); + fastrace::flush(); let spans = self.spans.lock().clone(); let spans_map: HashMap = spans @@ -97,10 +97,10 @@ impl Drop for TestTraceLogGuard { #[must_use = "guard should be kept alive to keep the trace log"] pub(crate) fn test_trace_log_setup() -> TestTraceLogGuard { std::env::set_var("RUST_LOG", "trace"); - let (reporter, spans) = minitrace::collector::TestReporter::new(); - minitrace::set_reporter( + let (reporter, spans) = fastrace::collector::TestReporter::new(); + fastrace::set_reporter( reporter, - minitrace::collector::Config::default().report_before_root_finish(true), + fastrace::collector::Config::default().report_before_root_finish(true), ); let _ignore = env_logger::try_init(); TestTraceLogGuard { spans }