@@ -124,7 +124,7 @@ impl ApolloTracing {
124124 /// graph_ref - <ref>@<variant> Graph reference with variant
125125 /// release_name - Your release version or release name from Git for example
126126 /// batch_target - The number of traces to batch, it depends on your traffic
127- pub fn new < ' a > (
127+ pub fn new (
128128 authorization_token : String ,
129129 hostname : String ,
130130 graph_ref : String ,
@@ -135,7 +135,7 @@ impl ApolloTracing {
135135 uname : Uname :: new ( )
136136 . ok ( )
137137 . map ( |x| x. to_string ( ) )
138- . unwrap_or ( "No uname provided" . to_string ( ) ) ,
138+ . unwrap_or_else ( || "No uname provided" . to_string ( ) ) ,
139139 hostname,
140140 graph_ref,
141141 service_version : release_name,
@@ -164,13 +164,13 @@ impl ApolloTracing {
164164 }
165165 None => {
166166 let mut trace_and_stats = TracesAndStats :: new ( ) ;
167- & trace_and_stats. mut_trace ( ) . push ( trace) ;
167+ trace_and_stats. mut_trace ( ) . push ( trace) ;
168168
169169 hashmap. insert ( name, trace_and_stats) ;
170170 }
171171 }
172172
173- count = count + 1 ;
173+ count += 1 ;
174174
175175 if count > batch_target {
176176 use tracing:: { field, field:: debug, span, Level } ;
@@ -313,22 +313,28 @@ impl Extension for ApolloTracingExtension {
313313 . data :: < ApolloTracingDataExt > ( )
314314 . ok ( )
315315 . cloned ( )
316- . unwrap_or ( ApolloTracingDataExt :: default ( ) ) ;
316+ . unwrap_or_else ( ApolloTracingDataExt :: default) ;
317317 let client_name = tracing_extension
318318 . client_name
319- . unwrap_or ( "no client name" . to_string ( ) ) ;
319+ . unwrap_or_else ( || "no client name" . to_string ( ) ) ;
320320 let client_version = tracing_extension
321321 . client_version
322- . unwrap_or ( "no client version" . to_string ( ) ) ;
323- let userid = tracing_extension. userid . unwrap_or ( "anonymous" . to_string ( ) ) ;
324-
325- let path = tracing_extension. path . unwrap_or ( "no path" . to_string ( ) ) ;
326- let host = tracing_extension. host . unwrap_or ( "no host" . to_string ( ) ) ;
322+ . unwrap_or_else ( || "no client version" . to_string ( ) ) ;
323+ let userid = tracing_extension
324+ . userid
325+ . unwrap_or_else ( || "anonymous" . to_string ( ) ) ;
326+
327+ let path = tracing_extension
328+ . path
329+ . unwrap_or_else ( || "no path" . to_string ( ) ) ;
330+ let host = tracing_extension
331+ . host
332+ . unwrap_or_else ( || "no host" . to_string ( ) ) ;
327333 let method = tracing_extension. method . unwrap_or ( HTTPMethod :: UNKNOWN ) ;
328334 let secure = tracing_extension. secure . unwrap_or ( false ) ;
329335 let protocol = tracing_extension
330336 . protocol
331- . unwrap_or ( "no protocol " . to_string ( ) ) ;
337+ . unwrap_or_else ( || "no operation " . to_string ( ) ) ;
332338 let status_code = tracing_extension. status_code . unwrap_or ( 0 ) ;
333339
334340 let mut trace = Trace {
@@ -342,15 +348,15 @@ impl Extension for ApolloTracingExtension {
342348 ..Default :: default ( )
343349 } ;
344350
345- & trace. set_details ( Trace_Details {
351+ trace. set_details ( Trace_Details {
346352 operation_name : operation_name
347353 . map ( |x| x. to_string ( ) )
348- . unwrap_or ( "no operation" . to_string ( ) ) ,
354+ . unwrap_or_else ( || "no operation" . to_string ( ) ) ,
349355 ..Default :: default ( )
350356 } ) ;
351357
352358 // Should come from Context / Headers
353- & trace. set_http ( Trace_HTTP {
359+ trace. set_http ( Trace_HTTP {
354360 path,
355361 host,
356362 method : Trace_HTTP_Method :: from ( method) ,
@@ -360,33 +366,32 @@ impl Extension for ApolloTracingExtension {
360366 ..Default :: default ( )
361367 } ) ;
362368
363- & trace. set_end_time ( Timestamp {
369+ trace. set_end_time ( Timestamp {
364370 nanos : inner. end_time . timestamp_subsec_nanos ( ) . try_into ( ) . unwrap ( ) ,
365- seconds : inner. end_time . timestamp ( ) . try_into ( ) . unwrap ( ) ,
371+ seconds : inner. end_time . timestamp ( ) ,
366372 ..Default :: default ( )
367373 } ) ;
368374
369- & trace. set_start_time ( Timestamp {
375+ trace. set_start_time ( Timestamp {
370376 nanos : inner
371377 . start_time
372378 . timestamp_subsec_nanos ( )
373379 . try_into ( )
374380 . unwrap ( ) ,
375- seconds : inner. start_time . timestamp ( ) . try_into ( ) . unwrap ( ) ,
381+ seconds : inner. start_time . timestamp ( ) ,
376382 ..Default :: default ( )
377383 } ) ;
378384
379385 let root_node = self . root_node . read ( ) . await ;
380- & trace. set_root ( root_node. clone ( ) ) ;
386+ trace. set_root ( root_node. clone ( ) ) ;
381387
382388 let sender = self . sender . clone ( ) ;
383389
384390 let operation_name = self . operation_name . read ( ) . await . clone ( ) ;
385391 tokio:: spawn ( async move {
386- match sender. send ( ( operation_name, trace) ) . await {
387- Err ( e) => error ! ( error = ?e) ,
388- _ => { }
389- } ;
392+ if let Err ( e) = sender. send ( ( operation_name, trace) ) . await {
393+ error ! ( error = ?e) ;
394+ }
390395 } ) ;
391396 resp
392397 }
@@ -439,8 +444,8 @@ impl Extension for ApolloTracingExtension {
439444 Ok ( res) => Ok ( res) ,
440445 Err ( e) => {
441446 let mut error = Trace_Error :: new ( ) ;
442- & error. set_message ( e. message . clone ( ) ) ;
443- & error. set_location ( RepeatedField :: from_vec (
447+ error. set_message ( e. message . clone ( ) ) ;
448+ error. set_location ( RepeatedField :: from_vec (
444449 e. locations
445450 . clone ( )
446451 . into_iter ( )
@@ -455,7 +460,7 @@ impl Extension for ApolloTracingExtension {
455460 Ok ( content) => content,
456461 Err ( e) => serde_json:: json!( { "error" : format!( "{:?}" , e) } ) . to_string ( ) ,
457462 } ;
458- & error. set_json ( json) ;
463+ error. set_json ( json) ;
459464 node. write ( )
460465 . await
461466 . set_error ( RepeatedField :: from_vec ( vec ! [ error] ) ) ;
0 commit comments