aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-02-18 20:39:55 +0100
committerAlex Auvolat <alex@adnab.me>2022-03-14 10:52:30 +0100
commitbb04d94fa92740eebeee513030faf136bfd26da7 (patch)
tree5e353982171819f00f03211855baef078156964b /src/model
parent8c2fb0c066af7f68fdcfcdec96fa030af059bf63 (diff)
downloadgarage-bb04d94fa92740eebeee513030faf136bfd26da7.tar.gz
garage-bb04d94fa92740eebeee513030faf136bfd26da7.zip
Update to Netapp 0.4 which supports distributed tracing
Diffstat (limited to 'src/model')
-rw-r--r--src/model/Cargo.toml3
-rw-r--r--src/model/block.rs24
2 files changed, 24 insertions, 3 deletions
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index 4465af1c..8083445e 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -39,4 +39,5 @@ tokio = { version = "1.0", default-features = false, features = ["rt", "rt-multi
opentelemetry = "0.17"
#netapp = { version = "0.3.0", git = "https://git.deuxfleurs.fr/lx/netapp" }
-netapp = "0.3.0"
+#netapp = { version = "0.4", path = "../../../netapp" }
+netapp = "0.4"
diff --git a/src/model/block.rs b/src/model/block.rs
index ddda5e57..3799c6aa 100644
--- a/src/model/block.rs
+++ b/src/model/block.rs
@@ -14,7 +14,10 @@ use tokio::fs;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::sync::{watch, Mutex, Notify};
-use opentelemetry::KeyValue;
+use opentelemetry::{
+ trace::{FutureExt as OtelFutureExt, TraceContextExt, Tracer},
+ Context, KeyValue,
+};
use garage_util::data::*;
use garage_util::error::*;
@@ -554,7 +557,24 @@ impl BlockManager {
let start_time = SystemTime::now();
let hash = Hash::try_from(&hash_bytes[..]).unwrap();
- let res = self.resync_block(&hash).await;
+
+ let tracer = opentelemetry::global::tracer("garage");
+ let trace_id = gen_uuid();
+ let span = tracer
+ .span_builder("Resync block")
+ .with_trace_id(
+ opentelemetry::trace::TraceId::from_hex(&hex::encode(
+ &trace_id.as_slice()[..16],
+ ))
+ .unwrap(),
+ )
+ .with_attributes(vec![KeyValue::new("block", format!("{:?}", hash))])
+ .start(&tracer);
+
+ let res = self
+ .resync_block(&hash)
+ .with_context(Context::current_with_span(span))
+ .await;
self.metrics.resync_counter.add(1);
self.metrics