File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -429,11 +429,6 @@ where
429429 Fut : Future < Output = KvResult < ( Resp , u32 ) > > + Send ,
430430 Resp : TraceAttributes ,
431431 {
432- // Fast path: skip tracing overhead when no subscriber is listening
433- if !tracing:: span_enabled!( tracing:: Level :: TRACE ) {
434- return op_fn ( req) . await . map ( |( resp, _) | resp) ;
435- }
436-
437432 let result = self
438433 . tracing
439434 . orchestrate_dispatch_span (
Original file line number Diff line number Diff line change @@ -287,6 +287,11 @@ impl TracingComponent {
287287 Fut : Future < Output = T > + Send ,
288288 F : FnOnce ( & T ) -> EndDispatchFields + Send ,
289289 {
290+ // Fast path: skip tracing overhead when no subscriber is listening
291+ if !tracing:: span_enabled!( tracing:: Level :: TRACE ) {
292+ return operation. await ;
293+ }
294+
290295 let span = self . create_dispatch_span ( & begin_fields) ;
291296 let result = operation. instrument ( span. clone ( ) ) . await ;
292297 let end_fields = end_fields_provider ( & result) ;
Original file line number Diff line number Diff line change @@ -128,6 +128,11 @@ impl CouchbaseTracingClient {
128128 & self ,
129129 f : impl FnOnce ( ) -> crate :: error:: Result < T > ,
130130 ) -> crate :: error:: Result < T > {
131+ // Fast path: skip tracing overhead when no subscriber is listening
132+ if !tracing:: span_enabled!( Level :: TRACE ) {
133+ return f ( ) ;
134+ }
135+
131136 let span = trace_span ! (
132137 target: "couchbase::tracing" ,
133138 SPAN_NAME_REQUEST_ENCODING ,
@@ -152,8 +157,8 @@ impl CouchbaseTracingClient {
152157 ) -> OperationContext < ' a > {
153158 let operation_name = span. name ( ) ;
154159
155- // Fast- path: if tracing is not enabled, avoid fetching the cluster labels.
156- let tracing_enabled = tracing:: enabled !( Level :: TRACE ) ;
160+ // Fast path: skip tracing overhead when no subscriber is listening
161+ let tracing_enabled = tracing:: span_enabled !( Level :: TRACE ) ;
157162
158163 let cluster_labels: Option < ClusterLabels > = if tracing_enabled {
159164 self . get_cluster_labels ( ) . await . unwrap_or_default ( )
You can’t perform that action at this time.
0 commit comments