From 01b78bd8711c6a37768d2b373c1bacf38b9398fb Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 22 Jul 2024 15:55:30 +0800 Subject: [PATCH] chore!: Use fastrace to replace deprecated minitrace Signed-off-by: Xuanwo --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 2 +- README.md | 2 +- examples/tracing.rs | 14 +++++++------- src/client/conn/tokio.rs | 2 +- src/codec/decoder/body.rs | 4 ++-- src/codec/decoder/dedup.rs | 2 +- src/codec/decoder/fragment.rs | 2 +- src/codec/decoder/mod.rs | 2 +- src/codec/decoder/ordered.rs | 2 +- src/codec/frame.rs | 2 +- src/io.rs | 2 +- src/server/handler/offline.rs | 4 ++-- src/server/incoming/tokio.rs | 4 ++-- src/utils/{minitrace.rs => fastrace.rs} | 4 ++-- src/utils/mod.rs | 4 ++-- src/utils/tests.rs | 10 +++++----- 17 files changed, 33 insertions(+), 33 deletions(-) rename src/utils/{minitrace.rs => fastrace.rs} (96%) 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..7d2b28c 100644 --- a/examples/tracing.rs +++ b/examples/tracing.rs @@ -6,8 +6,8 @@ use std::time::Duration; use bytes::Bytes; use futures::{SinkExt, StreamExt}; -use minitrace::collector::{SpanContext, SpanId, SpanRecord, TraceId}; -use minitrace::Span; +use fastrace::collector::{SpanContext, SpanId, SpanRecord, TraceId}; +use fastrace::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?; @@ -46,7 +46,7 @@ async fn main() -> Result<(), Box> { 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" + "Please run with `--features fastrace/enable` and try again" ); exit(0) }); @@ -71,7 +71,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..8340f17 100644 --- a/src/client/conn/tokio.rs +++ b/src/client/conn/tokio.rs @@ -3,7 +3,7 @@ use std::net::ToSocketAddrs; use std::sync::Arc; use futures::StreamExt; -use minitrace::Span; +use fastrace::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..1c81be1 100644 --- a/src/codec/decoder/body.rs +++ b/src/codec/decoder/body.rs @@ -2,8 +2,8 @@ use std::pin::Pin; use std::task::{Context, Poll}; use futures::{ready, Stream, StreamExt}; -use minitrace::local::LocalSpan; -use minitrace::Event; +use fastrace::local::LocalSpan; +use fastrace::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..24a2894 100644 --- a/src/codec/decoder/dedup.rs +++ b/src/codec/decoder/dedup.rs @@ -2,7 +2,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use futures::{ready, Stream, StreamExt}; -use minitrace::Span; +use fastrace::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..e155eed 100644 --- a/src/codec/decoder/fragment.rs +++ b/src/codec/decoder/fragment.rs @@ -7,7 +7,7 @@ use std::task::{Context, Poll}; use bytes::BufMut; use futures::{ready, Stream, StreamExt}; use lru::LruCache; -use minitrace::{Event, Span}; +use fastrace::{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..883ed58 100644 --- a/src/codec/decoder/mod.rs +++ b/src/codec/decoder/mod.rs @@ -7,7 +7,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use futures::Stream; -use minitrace::Span; +use fastrace::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..d5b851e 100644 --- a/src/codec/decoder/ordered.rs +++ b/src/codec/decoder/ordered.rs @@ -5,7 +5,7 @@ use std::task::{Context, Poll}; use bytes::Buf; use futures::{ready, Stream, StreamExt}; use log::warn; -use minitrace::{Event, Span}; +use fastrace::{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..389f838 100644 --- a/src/codec/frame.rs +++ b/src/codec/frame.rs @@ -6,7 +6,7 @@ use std::task::{ready, Context, Poll}; use bytes::{Buf, BytesMut}; use futures::{Sink, Stream}; use log::error; -use minitrace::{Event, Span}; +use fastrace::{Event, Span}; use super::AsyncSocket; use crate::errors::CodecError; diff --git a/src/io.rs b/src/io.rs index a108df7..869bca3 100644 --- a/src/io.rs +++ b/src/io.rs @@ -3,7 +3,7 @@ use std::task::{Context, Poll}; use bytes::Bytes; use futures::{Future, Sink, SinkExt, Stream}; -use minitrace::collector::TraceId; +use fastrace::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..e07d746 100644 --- a/src/server/handler/offline.rs +++ b/src/server/handler/offline.rs @@ -7,8 +7,8 @@ use std::task::{Context, Poll}; use bytes::Bytes; use futures::{ready, Sink, Stream}; use log::{debug, error, trace, warn}; -use minitrace::collector::SpanContext; -use minitrace::Span; +use fastrace::collector::SpanContext; +use fastrace::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..ba8b3aa 100644 --- a/src/server/incoming/tokio.rs +++ b/src/server/incoming/tokio.rs @@ -7,8 +7,8 @@ use std::task::{ready, Context, Poll}; use concurrent_queue::ConcurrentQueue; use futures::Stream; use log::{debug, error}; -use minitrace::collector::SpanContext; -use minitrace::Span; +use fastrace::collector::SpanContext; +use fastrace::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..f6ff607 100644 --- a/src/utils/minitrace.rs +++ b/src/utils/fastrace.rs @@ -2,8 +2,8 @@ use std::pin::Pin; use std::task::{Context, Poll}; use futures::Stream; -use minitrace::collector::{SpanContext, TraceId}; -use minitrace::Span; +use fastrace::collector::{SpanContext, TraceId}; +use fastrace::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..0f8ec86 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,12 +1,12 @@ mod bit_queue; mod log; -mod minitrace; +mod fastrace; mod reactor; mod seq_num; pub(crate) use self::bit_queue::*; pub(crate) use self::log::*; -pub(crate) use self::minitrace::*; +pub(crate) use self::fastrace::*; 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 }