@@ -29,14 +29,11 @@ use bytes::Bytes;
29
29
use chroma_config:: registry:: Registry ;
30
30
use chroma_config:: Configurable ;
31
31
use chroma_error:: ChromaError ;
32
- use chroma_tracing:: util:: get_current_trace_id;
33
32
use futures:: future:: BoxFuture ;
34
33
use futures:: stream;
35
34
use futures:: FutureExt ;
36
35
use futures:: Stream ;
37
36
use futures:: StreamExt ;
38
- use opentelemetry:: metrics:: Meter ;
39
- use opentelemetry:: KeyValue ;
40
37
use rand:: Rng ;
41
38
use std:: clone:: Clone ;
42
39
use std:: ops:: Range ;
@@ -45,42 +42,12 @@ use std::time::Duration;
45
42
use tokio:: io:: AsyncReadExt ;
46
43
use tracing:: Instrument ;
47
44
48
- #[ derive( Clone , Debug ) ]
49
- pub struct S3StorageMetrics {
50
- num_get_requests : opentelemetry:: metrics:: Histogram < u64 > ,
51
- num_put_requests : opentelemetry:: metrics:: Histogram < u64 > ,
52
- num_delete_requests : opentelemetry:: metrics:: Histogram < u64 > ,
53
- }
54
-
55
- impl S3StorageMetrics {
56
- pub fn new ( meter : Meter ) -> Self {
57
- Self {
58
- num_get_requests : meter
59
- . u64_histogram ( "s3_num_get_requests" )
60
- . with_description ( "The number of GET requests to S3." )
61
- . with_unit ( "requests" )
62
- . build ( ) ,
63
- num_put_requests : meter
64
- . u64_histogram ( "s3_num_put_requests" )
65
- . with_description ( "The number of PUT requests to S3." )
66
- . with_unit ( "requests" )
67
- . build ( ) ,
68
- num_delete_requests : meter
69
- . u64_histogram ( "s3_num_delete_requests" )
70
- . with_description ( "The number of DELETE requests to S3." )
71
- . with_unit ( "requests" )
72
- . build ( ) ,
73
- }
74
- }
75
- }
76
-
77
45
#[ derive( Clone ) ]
78
46
pub struct S3Storage {
79
47
pub ( super ) bucket : String ,
80
48
pub ( super ) client : aws_sdk_s3:: Client ,
81
49
pub ( super ) upload_part_size_bytes : usize ,
82
50
pub ( super ) download_part_size_bytes : usize ,
83
- pub ( super ) metrics : S3StorageMetrics ,
84
51
}
85
52
86
53
impl S3Storage {
@@ -96,7 +63,6 @@ impl S3Storage {
96
63
client,
97
64
upload_part_size_bytes,
98
65
download_part_size_bytes,
99
- metrics : S3StorageMetrics :: new ( opentelemetry:: global:: meter ( "chroma" ) ) ,
100
66
}
101
67
}
102
68
@@ -159,9 +125,6 @@ impl S3Storage {
159
125
. instrument ( tracing:: trace_span!( "cold S3 get" ) )
160
126
. await ;
161
127
162
- let trace_id = get_current_trace_id ( ) . to_string ( ) ;
163
- let attribute = [ KeyValue :: new ( "trace_id" , trace_id) ] ;
164
- self . metrics . num_get_requests . record ( 1 , & attribute) ;
165
128
match res {
166
129
Ok ( res) => {
167
130
let byte_stream = res. body ;
@@ -217,9 +180,6 @@ impl S3Storage {
217
180
. key ( key)
218
181
. send ( )
219
182
. await ;
220
- let trace_id = get_current_trace_id ( ) . to_string ( ) ;
221
- let attribute = [ KeyValue :: new ( "trace_id" , trace_id) ] ;
222
- self . metrics . num_get_requests . record ( 1 , & attribute) ;
223
183
let ( content_length, e_tag) = match head_res {
224
184
Ok ( res) => match res. content_length {
225
185
Some ( len) => ( len, res. e_tag ) ,
@@ -265,9 +225,6 @@ impl S3Storage {
265
225
. send ( )
266
226
. instrument ( tracing:: trace_span!( "cold S3 get" ) )
267
227
. await ;
268
- let trace_id = get_current_trace_id ( ) . to_string ( ) ;
269
- let attribute = [ KeyValue :: new ( "trace_id" , trace_id) ] ;
270
- self . metrics . num_get_requests . record ( 1 , & attribute) ;
271
228
match res {
272
229
Ok ( output) => Ok ( output) ,
273
230
Err ( e) => {
@@ -473,9 +430,6 @@ impl S3Storage {
473
430
. await
474
431
}
475
432
} ;
476
- let trace_id = get_current_trace_id ( ) . to_string ( ) ;
477
- let attribute = [ KeyValue :: new ( "trace_id" , trace_id) ] ;
478
- self . metrics . num_put_requests . record ( 1 , & attribute) ;
479
433
res
480
434
}
481
435
@@ -519,9 +473,6 @@ impl S3Storage {
519
473
}
520
474
} ) ?;
521
475
522
- let trace_id = get_current_trace_id ( ) . to_string ( ) ;
523
- let attribute = [ KeyValue :: new ( "trace_id" , trace_id) ] ;
524
- self . metrics . num_put_requests . record ( 1 , & attribute) ;
525
476
Ok ( resp. e_tag . map ( ETag ) )
526
477
}
527
478
@@ -598,9 +549,6 @@ impl S3Storage {
598
549
source : Arc :: new ( err. into_service_error ( ) ) ,
599
550
} ) ?;
600
551
601
- let trace_id = get_current_trace_id ( ) . to_string ( ) ;
602
- let attribute = [ KeyValue :: new ( "trace_id" , trace_id) ] ;
603
- self . metrics . num_put_requests . record ( 1 , & attribute) ;
604
552
Ok ( CompletedPart :: builder ( )
605
553
. e_tag ( upload_part_res. e_tag . unwrap_or_default ( ) )
606
554
. part_number ( part_number)
@@ -702,9 +650,6 @@ impl S3Storage {
702
650
}
703
651
} ;
704
652
705
- let trace_id = get_current_trace_id ( ) . to_string ( ) ;
706
- let attribute = [ KeyValue :: new ( "trace_id" , trace_id) ] ;
707
- self . metrics . num_delete_requests . record ( 1 , & attribute) ;
708
653
res
709
654
}
710
655
0 commit comments