Skip to content

Commit f865c66

Browse files
committed
feat(tracing): align resource attributes with OpenTelemetry semantic conventions
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 3959bb9 commit f865c66

File tree

39 files changed

+278
-216
lines changed

39 files changed

+278
-216
lines changed

Cargo.lock

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dragonfly-client-backend/src/hdfs.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ pub struct Hdfs {
3939
/// Hdfs implements the Backend trait.
4040
impl Hdfs {
4141
/// new returns a new HDFS backend.
42-
#[instrument(skip_all)]
4342
pub fn new() -> Self {
4443
Self {
4544
scheme: HDFS_SCHEME.to_string(),
4645
}
4746
}
4847

4948
/// operator initializes the operator with the parsed URL and HDFS config.
50-
#[instrument(skip_all)]
5149
pub fn operator(
5250
&self,
5351
url: Url,
@@ -84,7 +82,6 @@ impl Hdfs {
8482
#[tonic::async_trait]
8583
impl super::Backend for Hdfs {
8684
/// scheme returns the scheme of the HDFS backend.
87-
#[instrument(skip_all)]
8885
fn scheme(&self) -> String {
8986
self.scheme.clone()
9087
}

dragonfly-client-backend/src/http.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub struct HTTP {
4343
/// HTTP implements the http interface.
4444
impl HTTP {
4545
/// new returns a new HTTP.
46-
#[instrument(skip_all)]
4746
pub fn new(scheme: &str) -> Result<HTTP> {
4847
// Default TLS client config with no validation.
4948
let client_config_builder = rustls::ClientConfig::builder()
@@ -75,7 +74,6 @@ impl HTTP {
7574
}
7675

7776
/// client returns a new reqwest client.
78-
#[instrument(skip_all)]
7977
fn client(
8078
&self,
8179
client_cert: Option<Vec<CertificateDer<'static>>>,
@@ -117,7 +115,6 @@ impl HTTP {
117115
#[tonic::async_trait]
118116
impl super::Backend for HTTP {
119117
/// scheme returns the scheme of the HTTP backend.
120-
#[instrument(skip_all)]
121118
fn scheme(&self) -> String {
122119
self.scheme.clone()
123120
}

dragonfly-client-backend/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use std::str::FromStr;
2727
use std::{collections::HashMap, pin::Pin, time::Duration};
2828
use std::{fmt::Debug, fs};
2929
use tokio::io::{AsyncRead, AsyncReadExt};
30-
use tracing::{error, info, instrument, warn};
30+
use tracing::{error, info, warn};
3131
use url::Url;
3232

3333
pub mod hdfs;
@@ -227,7 +227,6 @@ pub struct BackendFactory {
227227
/// https://github.com/dragonflyoss/client/tree/main/dragonfly-client-backend/examples/plugin/.
228228
impl BackendFactory {
229229
/// new returns a new BackendFactory.
230-
#[instrument(skip_all)]
231230
pub fn new(plugin_dir: Option<&Path>) -> Result<Self> {
232231
let mut backend_factory = Self::default();
233232
backend_factory.load_builtin_backends()?;
@@ -243,13 +242,11 @@ impl BackendFactory {
243242
}
244243

245244
/// supported_download_directory returns whether the scheme supports directory download.
246-
#[instrument(skip_all)]
247245
pub fn supported_download_directory(scheme: &str) -> bool {
248246
object_storage::Scheme::from_str(scheme).is_ok() || scheme == hdfs::HDFS_SCHEME
249247
}
250248

251249
/// build returns the backend by the scheme of the url.
252-
#[instrument(skip_all)]
253250
pub fn build(&self, url: &str) -> Result<&(dyn Backend + Send + Sync)> {
254251
let url = Url::parse(url).or_err(ErrorType::ParseError)?;
255252
let scheme = url.scheme();
@@ -260,7 +257,6 @@ impl BackendFactory {
260257
}
261258

262259
/// load_builtin_backends loads the builtin backends.
263-
#[instrument(skip_all)]
264260
fn load_builtin_backends(&mut self) -> Result<()> {
265261
self.backends.insert(
266262
"http".to_string(),
@@ -330,7 +326,6 @@ impl BackendFactory {
330326
}
331327

332328
/// load_plugin_backends loads the plugin backends.
333-
#[instrument(skip_all)]
334329
fn load_plugin_backends(&mut self, plugin_dir: &Path) -> Result<()> {
335330
let backend_plugin_dir = plugin_dir.join(NAME);
336331
if !backend_plugin_dir.exists() {

dragonfly-client-backend/src/object_storage.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ pub struct ObjectStorage {
177177
/// ObjectStorage implements the ObjectStorage trait.
178178
impl ObjectStorage {
179179
/// Returns ObjectStorage that implements the Backend trait.
180-
#[instrument(skip_all)]
181180
pub fn new(scheme: Scheme) -> ClientResult<ObjectStorage> {
182181
// Initialize the reqwest client.
183182
let client = reqwest::Client::builder()
@@ -196,7 +195,6 @@ impl ObjectStorage {
196195
}
197196

198197
/// operator initializes the operator with the parsed URL and object storage.
199-
#[instrument(skip_all)]
200198
pub fn operator(
201199
&self,
202200
parsed_url: &super::object_storage::ParsedURL,
@@ -223,7 +221,6 @@ impl ObjectStorage {
223221
}
224222

225223
/// s3_operator initializes the S3 operator with the parsed URL and object storage.
226-
#[instrument(skip_all)]
227224
pub fn s3_operator(
228225
&self,
229226
parsed_url: &super::object_storage::ParsedURL,
@@ -276,7 +273,6 @@ impl ObjectStorage {
276273
}
277274

278275
/// gcs_operator initializes the GCS operator with the parsed URL and object storage.
279-
#[instrument(skip_all)]
280276
pub fn gcs_operator(
281277
&self,
282278
parsed_url: &super::object_storage::ParsedURL,
@@ -311,7 +307,6 @@ impl ObjectStorage {
311307
}
312308

313309
/// abs_operator initializes the ABS operator with the parsed URL and object storage.
314-
#[instrument(skip_all)]
315310
pub fn abs_operator(
316311
&self,
317312
parsed_url: &super::object_storage::ParsedURL,
@@ -354,7 +349,6 @@ impl ObjectStorage {
354349
}
355350

356351
/// oss_operator initializes the OSS operator with the parsed URL and object storage.
357-
#[instrument(skip_all)]
358352
pub fn oss_operator(
359353
&self,
360354
parsed_url: &super::object_storage::ParsedURL,
@@ -398,7 +392,6 @@ impl ObjectStorage {
398392
}
399393

400394
/// obs_operator initializes the OBS operator with the parsed URL and object storage.
401-
#[instrument(skip_all)]
402395
pub fn obs_operator(
403396
&self,
404397
parsed_url: &super::object_storage::ParsedURL,
@@ -487,7 +480,6 @@ impl ObjectStorage {
487480
#[tonic::async_trait]
488481
impl crate::Backend for ObjectStorage {
489482
/// scheme returns the scheme of the object storage.
490-
#[instrument(skip_all)]
491483
fn scheme(&self) -> String {
492484
self.scheme.to_string()
493485
}

dragonfly-client-init/src/bin/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ async fn main() -> Result<(), anyhow::Error> {
9191
args.log_max_files,
9292
None,
9393
None,
94+
false,
9495
args.log_to_stdout,
9596
);
9697

dragonfly-client-storage/src/content.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ pub struct WritePersistentCacheTaskResponse {
6767
/// Content implements the content storage.
6868
impl Content {
6969
/// new returns a new content.
70-
#[instrument(skip_all)]
7170
pub async fn new(config: Arc<Config>, dir: &Path) -> Result<Content> {
7271
let dir = dir.join(DEFAULT_CONTENT_DIR);
7372

@@ -85,21 +84,18 @@ impl Content {
8584
}
8685

8786
/// available_space returns the available space of the disk.
88-
#[instrument(skip_all)]
8987
pub fn available_space(&self) -> Result<u64> {
9088
let stat = fs2::statvfs(&self.dir)?;
9189
Ok(stat.available_space())
9290
}
9391

9492
/// total_space returns the total space of the disk.
95-
#[instrument(skip_all)]
9693
pub fn total_space(&self) -> Result<u64> {
9794
let stat = fs2::statvfs(&self.dir)?;
9895
Ok(stat.total_space())
9996
}
10097

10198
/// has_enough_space checks if the storage has enough space to store the content.
102-
#[instrument(skip_all)]
10399
pub fn has_enough_space(&self, content_length: u64) -> Result<bool> {
104100
let available_space = self.available_space()?;
105101
if available_space < content_length {
@@ -115,7 +111,6 @@ impl Content {
115111
}
116112

117113
/// is_same_dev_inode checks if the source and target are the same device and inode.
118-
#[instrument(skip_all)]
119114
async fn is_same_dev_inode<P: AsRef<Path>, Q: AsRef<Path>>(
120115
&self,
121116
source: P,
@@ -141,7 +136,6 @@ impl Content {
141136
}
142137

143138
/// is_same_dev_inode_as_task checks if the task and target are the same device and inode.
144-
#[instrument(skip_all)]
145139
pub async fn is_same_dev_inode_as_task(&self, task_id: &str, to: &Path) -> Result<bool> {
146140
let task_path = self.get_task_path(task_id);
147141
self.is_same_dev_inode(&task_path, to).await
@@ -152,6 +146,7 @@ impl Content {
152146
/// Behavior of `create_task`:
153147
/// 1. If the task already exists, return the task path.
154148
/// 2. If the task does not exist, create the task directory and file.
149+
#[instrument(skip_all)]
155150
pub async fn create_task(&self, task_id: &str, length: u64) -> Result<PathBuf> {
156151
let task_path = self.get_task_path(task_id);
157152
if task_path.exists() {
@@ -244,7 +239,6 @@ impl Content {
244239
}
245240

246241
/// delete_task deletes the task content.
247-
#[instrument(skip_all)]
248242
pub async fn delete_task(&self, task_id: &str) -> Result<()> {
249243
info!("delete task content: {}", task_id);
250244
let task_path = self.get_task_path(task_id);
@@ -378,7 +372,6 @@ impl Content {
378372
}
379373

380374
/// get_task_path returns the task path by task id.
381-
#[instrument(skip_all)]
382375
fn get_task_path(&self, task_id: &str) -> PathBuf {
383376
// The task needs split by the first 3 characters of task id(sha256) to
384377
// avoid too many files in one directory.
@@ -388,7 +381,6 @@ impl Content {
388381

389382
/// is_same_dev_inode_as_persistent_cache_task checks if the persistent cache task and target
390383
/// are the same device and inode.
391-
#[instrument(skip_all)]
392384
pub async fn is_same_dev_inode_as_persistent_cache_task(
393385
&self,
394386
task_id: &str,
@@ -403,6 +395,7 @@ impl Content {
403395
/// Behavior of `create_persistent_cache_task`:
404396
/// 1. If the persistent cache task already exists, return the persistent cache task path.
405397
/// 2. If the persistent cache task does not exist, create the persistent cache task directory and file.
398+
#[instrument(skip_all)]
406399
pub async fn create_persistent_cache_task(
407400
&self,
408401
task_id: &str,
@@ -593,7 +586,6 @@ impl Content {
593586
}
594587

595588
/// delete_task deletes the persistent cache task content.
596-
#[instrument(skip_all)]
597589
pub async fn delete_persistent_cache_task(&self, task_id: &str) -> Result<()> {
598590
info!("delete persistent cache task content: {}", task_id);
599591
let persistent_cache_task_path = self.get_persistent_cache_task_path(task_id);
@@ -606,7 +598,6 @@ impl Content {
606598
}
607599

608600
/// get_persistent_cache_task_path returns the persistent cache task path by task id.
609-
#[instrument(skip_all)]
610601
fn get_persistent_cache_task_path(&self, task_id: &str) -> PathBuf {
611602
// The persistent cache task needs split by the first 3 characters of task id(sha256) to
612603
// avoid too many files in one directory.

dragonfly-client-storage/src/lib.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub struct Storage {
5656
/// Storage implements the storage.
5757
impl Storage {
5858
/// new returns a new storage.
59-
#[instrument(skip_all)]
6059
pub async fn new(config: Arc<Config>, dir: &Path, log_dir: PathBuf) -> Result<Self> {
6160
let metadata = metadata::Metadata::new(config.clone(), dir, &log_dir)?;
6261
let content = content::Content::new(config.clone(), dir).await?;
@@ -71,19 +70,16 @@ impl Storage {
7170
}
7271

7372
/// total_space returns the total space of the disk.
74-
#[instrument(skip_all)]
7573
pub fn total_space(&self) -> Result<u64> {
7674
self.content.total_space()
7775
}
7876

7977
/// available_space returns the available space of the disk.
80-
#[instrument(skip_all)]
8178
pub fn available_space(&self) -> Result<u64> {
8279
self.content.available_space()
8380
}
8481

8582
/// has_enough_space checks if the storage has enough space to store the content.
86-
#[instrument(skip_all)]
8783
pub fn has_enough_space(&self, content_length: u64) -> Result<bool> {
8884
self.content.has_enough_space(content_length)
8985
}
@@ -102,14 +98,12 @@ impl Storage {
10298

10399
/// is_same_dev_inode_as_task checks if the task content is on the same device inode as the
104100
/// destination.
105-
#[instrument(skip_all)]
106101
pub async fn is_same_dev_inode_as_task(&self, id: &str, to: &Path) -> Result<bool> {
107102
self.content.is_same_dev_inode_as_task(id, to).await
108103
}
109104

110105
/// prepare_download_task_started prepares the metadata of the task when the task downloads
111106
/// started.
112-
#[instrument(skip_all)]
113107
pub async fn prepare_download_task_started(&self, id: &str) -> Result<metadata::Task> {
114108
self.metadata.download_task_started(id, None, None, None)
115109
}
@@ -227,7 +221,6 @@ impl Storage {
227221

228222
/// is_same_dev_inode_as_persistent_cache_task checks if the persistent cache task content is on the same device inode as the
229223
/// destination.
230-
#[instrument(skip_all)]
231224
pub async fn is_same_dev_inode_as_persistent_cache_task(
232225
&self,
233226
id: &str,
@@ -633,7 +626,6 @@ impl Storage {
633626
}
634627

635628
/// get_piece returns the piece metadata.
636-
#[instrument(skip_all)]
637629
pub fn get_piece(&self, piece_id: &str) -> Result<Option<metadata::Piece>> {
638630
self.metadata.get_piece(piece_id)
639631
}
@@ -645,13 +637,13 @@ impl Storage {
645637
}
646638

647639
/// get_pieces returns the piece metadatas.
640+
#[instrument(skip_all)]
648641
pub fn get_pieces(&self, task_id: &str) -> Result<Vec<metadata::Piece>> {
649642
self.metadata.get_pieces(task_id)
650643
}
651644

652645
/// piece_id returns the piece id.
653646
#[inline]
654-
#[instrument(skip_all)]
655647
pub fn piece_id(&self, task_id: &str, number: u32) -> String {
656648
self.metadata.piece_id(task_id, number)
657649
}
@@ -789,7 +781,6 @@ impl Storage {
789781

790782
/// persistent_cache_piece_id returns the persistent cache piece id.
791783
#[inline]
792-
#[instrument(skip_all)]
793784
pub fn persistent_cache_piece_id(&self, task_id: &str, number: u32) -> String {
794785
self.metadata.piece_id(task_id, number)
795786
}

0 commit comments

Comments
 (0)