Skip to content

Commit

Permalink
feat: Add tracing support via minitrace (#175)
Browse files Browse the repository at this point in the history
* add minitrace into cargo.toml

* collect minitrace span in behavior tests

* mv jaeger to dev-dependencies

* adding span a key value property

* create trace::jaeger_tracing to trace behavior

* split tracing collecting  into next pull request

* remain tests/behavior unchanged

* keep env.example unchanged

Co-authored-by: Xuanwo <[email protected]>
  • Loading branch information
D2Lark and Xuanwo authored Mar 24, 2022
1 parent c2a4aa1 commit bbd3152
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ thiserror = "1"
time = "0.3.7"
tokio = { version = "1.17", features = ["full"] }
tower = "0.4"
minitrace = "0.4.0"


[dev-dependencies]
anyhow = "1.0"
Expand All @@ -58,3 +60,4 @@ rand = "0.8"
sha2 = "0.10"
size = "0.1"
uuid = { version = "0.8", features = ["serde", "v4"] }

10 changes: 6 additions & 4 deletions src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use log::error;
use log::info;
use log::warn;
use metrics::increment_counter;
use minitrace::prelude::*;
use once_cell::sync::Lazy;
use reqsign::services::aws::v4::Signer;
use time::format_description::well_known::Rfc2822;
Expand Down Expand Up @@ -379,6 +380,7 @@ impl Backend {

#[async_trait]
impl Accessor for Backend {
#[trace("read")]
async fn read(&self, args: &OpRead) -> Result<BoxedAsyncReader> {
increment_counter!("opendal_s3_read_requests");

Expand All @@ -402,7 +404,7 @@ impl Accessor for Backend {
_ => Err(parse_error_response(resp, "read", &p).await),
}
}

#[trace("write")]
async fn write(&self, r: BoxedAsyncReader, args: &OpWrite) -> Result<usize> {
let p = self.get_abs_path(&args.path);
info!("object {} write start: size {}", &p, args.size);
Expand All @@ -416,7 +418,7 @@ impl Accessor for Backend {
_ => Err(parse_error_response(resp, "write", &p).await),
}
}

#[trace("stat")]
async fn stat(&self, args: &OpStat) -> Result<Metadata> {
increment_counter!("opendal_s3_stat_requests");

Expand Down Expand Up @@ -489,7 +491,7 @@ impl Accessor for Backend {
_ => Err(parse_error_response(resp, "stat", &p).await),
}
}

#[trace("delete")]
async fn delete(&self, args: &OpDelete) -> Result<()> {
increment_counter!("opendal_s3_delete_requests");

Expand All @@ -506,7 +508,7 @@ impl Accessor for Backend {
_ => Err(parse_error_response(resp, "delete", &p).await),
}
}

#[trace("list")]
async fn list(&self, args: &OpList) -> Result<BoxedObjectStream> {
increment_counter!("opendal_s3_list_requests");

Expand Down

0 comments on commit bbd3152

Please sign in to comment.