Skip to content

Commit

Permalink
chore!: Use fastrace to replace deprecated minitrace
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo committed Jul 22, 2024
1 parent 4f71fa0 commit 01b78bd
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions examples/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -16,10 +16,10 @@ use tokio::net::UdpSocket;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
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?;
Expand All @@ -46,7 +46,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
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)
});
Expand All @@ -71,7 +71,7 @@ async fn main() -> Result<(), Box<dyn Error>> {

client(local_addr).await?;

minitrace::flush();
fastrace::flush();
display(spans.lock().clone());
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/conn/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/codec/decoder/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/codec/decoder/dedup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/codec/decoder/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/codec/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion src/codec/decoder/ordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/codec/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/server/handler/offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/server/incoming/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/utils/minitrace.rs → src/utils/fastrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand Down
10 changes: 5 additions & 5 deletions src/utils/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<SpanId, SpanRecord> = spans
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit 01b78bd

Please sign in to comment.