Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(service/fastrace): rename minitrace to fastrace #4906

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ layers-metrics = ["dep:metrics"]
layers-prometheus = ["dep:prometheus"]
# Enable layers prometheus support, with prometheus-client crate
layers-prometheus-client = ["dep:prometheus-client"]
# Enable layers minitrace support.
layers-minitrace = ["dep:minitrace"]
# Enable layers fastrace support.
layers-fastrace = ["dep:fastrace"]
# Enable layers tracing support.
layers-tracing = ["dep:tracing"]
# Enable layers oteltrace support.
Expand Down Expand Up @@ -358,8 +358,8 @@ await-tree = { version = "0.1.1", optional = true }
governor = { version = "0.6.0", optional = true, features = ["std"] }
# for layers-metrics
metrics = { version = "0.23", optional = true }
# for layers-minitrace
minitrace = { version = "0.6", optional = true }
# for layers-fastrace
fastrace = { version = "0.6", optional = true }
# for layers-opentelemetry
opentelemetry = { version = "0.21.0", optional = true }
# for layers-prometheus
Expand All @@ -377,8 +377,8 @@ getrandom = { version = "0.2", features = ["js"] }
[dev-dependencies]
criterion = { version = "0.5", features = ["async", "async_tokio"] }
dotenvy = "0.15"
fastrace = { version = "0.6", features = ["enable"] }
libtest-mimic = "0.6"
minitrace = { version = "0.6", features = ["enable"] }
opentelemetry = { version = "0.21", default-features = false, features = [
"trace",
] }
Expand Down
6 changes: 3 additions & 3 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ OpenDAL supports the following storage [layers](https://docs.rs/opendal/latest/o
| [`DtraceLayer`] | [probe] | Support User Statically-Defined Tracing(aka USDT) on Linux |
| [`LoggingLayer`] | [log] | Add log for every operations. |
| [`MetricsLayer`] | [metrics] | Add metrics for every operations. |
| [`MinitraceLayer`] | [minitrace] | Add minitrace for every operations. |
| [`FastraceLayer`] | [fastrace] | Add fastrace for every operations. |
| [`OtelTraceLayer`] | [opentelemetry::trace] | Add opentelemetry::trace for every operations. |
| [`PrometheusClientLayer`] | [prometheus_client] | Add prometheus metrics for every operations. |
| [`PrometheusLayer`] | [prometheus] | Add prometheus metrics for every operations. |
Expand All @@ -139,8 +139,8 @@ OpenDAL supports the following storage [layers](https://docs.rs/opendal/latest/o
[log]: https://github.com/rust-lang/log
[`MetricsLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.MetricsLayer.html
[metrics]: https://github.com/metrics-rs/metrics
[`MinitraceLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.MinitraceLayer.html
[minitrace]: https://github.com/tikv/minitrace-rust
[`FastraceLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.FastraceLayer.html
[fastrace]: https://github.com/fastracelabs/fastrace
[`OtelTraceLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.OtelTraceLayer.html
[opentelemetry::trace]: https://docs.rs/opentelemetry/latest/opentelemetry/trace/index.html
[`PrometheusClientLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.PrometheusClientLayer.html
Expand Down
88 changes: 44 additions & 44 deletions core/src/layers/minitrace.rs → core/src/layers/fastrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ use std::fmt::Debug;
use std::future::Future;
use std::sync::Arc;

use fastrace::prelude::*;
use futures::FutureExt;
use minitrace::prelude::*;

use crate::raw::oio::ListOperation;
use crate::raw::oio::ReadOperation;
use crate::raw::oio::WriteOperation;
use crate::raw::*;
use crate::*;

/// Add [minitrace](https://docs.rs/minitrace/) for every operations.
/// Add [fastrace](https://docs.rs/fastrace/) for every operations.
///
/// # Examples
///
/// ## Basic Setup
///
/// ```no_build
/// use anyhow::Result;
/// use opendal::layers::MinitraceLayer;
/// use opendal::layers::FastraceLayer;
/// use opendal::services;
/// use opendal::Operator;
///
/// let _ = Operator::new(services::Memory::default())
/// .expect("must init")
/// .layer(MinitraceLayer)
/// .layer(FastraceLayer)
/// .finish();
/// ```
///
Expand All @@ -53,17 +53,17 @@ use crate::*;
///
/// use anyhow::Result;
/// use futures::executor::block_on;
/// use minitrace::collector::Config;
/// use minitrace::prelude::*;
/// use opendal::layers::MinitraceLayer;
/// use fastrace::collector::Config;
/// use fastrace::prelude::*;
/// use opendal::layers::FastraceLayer;
/// use opendal::services;
/// use opendal::Operator;
///
/// fn main() -> Result<(), Box<dyn Error + MaybeSend + Sync + 'static>> {
/// let reporter =
/// minitrace_jaeger::JaegerReporter::new("127.0.0.1:6831".parse().unwrap(), "opendal")
/// fastrace_jaeger::JaegerReporter::new("127.0.0.1:6831".parse().unwrap(), "opendal")
/// .unwrap();
/// minitrace::set_reporter(reporter, Config::default());
/// fastrace::set_reporter(reporter, Config::default());
///
/// {
/// let root = Span::root("op", SpanContext::random());
Expand All @@ -73,7 +73,7 @@ use crate::*;
/// let _ = dotenvy::dotenv();
/// let op = Operator::new(services::Memory::default())
/// .expect("init operator must succeed")
/// .layer(MinitraceLayer)
/// .layer(FastraceLayer)
/// .finish();
/// op.write("test", "0".repeat(16 * 1024 * 1024).into_bytes())
/// .await
Expand All @@ -85,55 +85,55 @@ use crate::*;
/// );
/// }
///
/// minitrace::flush();
/// fastrace::flush();
///
/// Ok(())
/// }
/// ```
///
/// # Output
///
/// OpenDAL is using [`minitrace`](https://docs.rs/minitrace/latest/minitrace/) for tracing internally.
/// OpenDAL is using [`fastrace`](https://docs.rs/fastrace/latest/fastrace/) for tracing internally.
///
/// To enable minitrace output, please init one of the reporter that `minitrace` supports.
/// To enable fastrace output, please init one of the reporter that `fastrace` supports.
///
/// For example:
///
/// ```no_build
/// extern crate minitrace_jaeger;
/// extern crate fastrace_jaeger;
///
/// use minitrace::collector::Config;
/// use fastrace::collector::Config;
///
/// let reporter =
/// minitrace_jaeger::JaegerReporter::new("127.0.0.1:6831".parse().unwrap(), "opendal")
/// fastrace_jaeger::JaegerReporter::new("127.0.0.1:6831".parse().unwrap(), "opendal")
/// .unwrap();
/// minitrace::set_reporter(reporter, Config::default());
/// fastrace::set_reporter(reporter, Config::default());
/// ```
///
/// For real-world usage, please take a look at [`minitrace-datadog`](https://crates.io/crates/minitrace-datadog) or [`minitrace-jaeger`](https://crates.io/crates/minitrace-jaeger) .
pub struct MinitraceLayer;
/// For real-world usage, please take a look at [`fastrace-datadog`](https://crates.io/crates/fastrace-datadog) or [`fastrace-jaeger`](https://crates.io/crates/fastrace-jaeger) .
pub struct FastraceLayer;

impl<A: Access> Layer<A> for MinitraceLayer {
type LayeredAccess = MinitraceAccessor<A>;
impl<A: Access> Layer<A> for FastraceLayer {
type LayeredAccess = FastraceAccessor<A>;

fn layer(&self, inner: A) -> Self::LayeredAccess {
MinitraceAccessor { inner }
FastraceAccessor { inner }
}
}

#[derive(Debug)]
pub struct MinitraceAccessor<A> {
pub struct FastraceAccessor<A> {
inner: A,
}

impl<A: Access> LayeredAccess for MinitraceAccessor<A> {
impl<A: Access> LayeredAccess for FastraceAccessor<A> {
type Inner = A;
type Reader = MinitraceWrapper<A::Reader>;
type BlockingReader = MinitraceWrapper<A::BlockingReader>;
type Writer = MinitraceWrapper<A::Writer>;
type BlockingWriter = MinitraceWrapper<A::BlockingWriter>;
type Lister = MinitraceWrapper<A::Lister>;
type BlockingLister = MinitraceWrapper<A::BlockingLister>;
type Reader = FastraceWrapper<A::Reader>;
type BlockingReader = FastraceWrapper<A::BlockingReader>;
type Writer = FastraceWrapper<A::Writer>;
type BlockingWriter = FastraceWrapper<A::BlockingWriter>;
type Lister = FastraceWrapper<A::Lister>;
type BlockingLister = FastraceWrapper<A::BlockingLister>;

fn inner(&self) -> &Self::Inner {
&self.inner
Expand All @@ -157,7 +157,7 @@ impl<A: Access> LayeredAccess for MinitraceAccessor<A> {
v.map(|(rp, r)| {
(
rp,
MinitraceWrapper::new(Span::enter_with_local_parent("ReadOperation"), r),
FastraceWrapper::new(Span::enter_with_local_parent("ReadOperation"), r),
)
})
})
Expand All @@ -172,7 +172,7 @@ impl<A: Access> LayeredAccess for MinitraceAccessor<A> {
v.map(|(rp, r)| {
(
rp,
MinitraceWrapper::new(Span::enter_with_local_parent("WriteOperation"), r),
FastraceWrapper::new(Span::enter_with_local_parent("WriteOperation"), r),
)
})
})
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<A: Access> LayeredAccess for MinitraceAccessor<A> {
v.map(|(rp, s)| {
(
rp,
MinitraceWrapper::new(Span::enter_with_local_parent("ListOperation"), s),
FastraceWrapper::new(Span::enter_with_local_parent("ListOperation"), s),
)
})
})
Expand All @@ -234,7 +234,7 @@ impl<A: Access> LayeredAccess for MinitraceAccessor<A> {
self.inner.blocking_read(path, args).map(|(rp, r)| {
(
rp,
MinitraceWrapper::new(Span::enter_with_local_parent("ReadOperation"), r),
FastraceWrapper::new(Span::enter_with_local_parent("ReadOperation"), r),
)
})
}
Expand All @@ -244,7 +244,7 @@ impl<A: Access> LayeredAccess for MinitraceAccessor<A> {
self.inner.blocking_write(path, args).map(|(rp, r)| {
(
rp,
MinitraceWrapper::new(Span::enter_with_local_parent("WriteOperation"), r),
FastraceWrapper::new(Span::enter_with_local_parent("WriteOperation"), r),
)
})
}
Expand Down Expand Up @@ -274,39 +274,39 @@ impl<A: Access> LayeredAccess for MinitraceAccessor<A> {
self.inner.blocking_list(path, args).map(|(rp, it)| {
(
rp,
MinitraceWrapper::new(Span::enter_with_local_parent("PageOperation"), it),
FastraceWrapper::new(Span::enter_with_local_parent("PageOperation"), it),
)
})
}
}

pub struct MinitraceWrapper<R> {
pub struct FastraceWrapper<R> {
span: Span,
inner: R,
}

impl<R> MinitraceWrapper<R> {
impl<R> FastraceWrapper<R> {
fn new(span: Span, inner: R) -> Self {
Self { span, inner }
}
}

impl<R: oio::Read> oio::Read for MinitraceWrapper<R> {
impl<R: oio::Read> oio::Read for FastraceWrapper<R> {
#[trace(enter_on_poll = true)]
async fn read(&mut self) -> Result<Buffer> {
self.inner.read().await
}
}

impl<R: oio::BlockingRead> oio::BlockingRead for MinitraceWrapper<R> {
impl<R: oio::BlockingRead> oio::BlockingRead for FastraceWrapper<R> {
fn read(&mut self) -> Result<Buffer> {
let _g = self.span.set_local_parent();
let _span = LocalSpan::enter_with_local_parent(ReadOperation::BlockingRead.into_static());
self.inner.read()
}
}

impl<R: oio::Write> oio::Write for MinitraceWrapper<R> {
impl<R: oio::Write> oio::Write for FastraceWrapper<R> {
fn write(&mut self, bs: Buffer) -> impl Future<Output = Result<()>> + MaybeSend {
let _g = self.span.set_local_parent();
let _span = LocalSpan::enter_with_local_parent(WriteOperation::Write.into_static());
Expand All @@ -326,7 +326,7 @@ impl<R: oio::Write> oio::Write for MinitraceWrapper<R> {
}
}

impl<R: oio::BlockingWrite> oio::BlockingWrite for MinitraceWrapper<R> {
impl<R: oio::BlockingWrite> oio::BlockingWrite for FastraceWrapper<R> {
fn write(&mut self, bs: Buffer) -> Result<()> {
let _g = self.span.set_local_parent();
let _span = LocalSpan::enter_with_local_parent(WriteOperation::BlockingWrite.into_static());
Expand All @@ -340,14 +340,14 @@ impl<R: oio::BlockingWrite> oio::BlockingWrite for MinitraceWrapper<R> {
}
}

impl<R: oio::List> oio::List for MinitraceWrapper<R> {
impl<R: oio::List> oio::List for FastraceWrapper<R> {
#[trace(enter_on_poll = true)]
async fn next(&mut self) -> Result<Option<oio::Entry>> {
self.inner.next().await
}
}

impl<R: oio::BlockingList> oio::BlockingList for MinitraceWrapper<R> {
impl<R: oio::BlockingList> oio::BlockingList for FastraceWrapper<R> {
fn next(&mut self) -> Result<Option<oio::Entry>> {
let _g = self.span.set_local_parent();
let _span = LocalSpan::enter_with_local_parent(ListOperation::BlockingNext.into_static());
Expand Down
Loading
Loading