@@ -124,7 +124,7 @@ impl ApolloTracing {
124
124
/// graph_ref - <ref>@<variant> Graph reference with variant
125
125
/// release_name - Your release version or release name from Git for example
126
126
/// batch_target - The number of traces to batch, it depends on your traffic
127
- pub fn new < ' a > (
127
+ pub fn new (
128
128
authorization_token : String ,
129
129
hostname : String ,
130
130
graph_ref : String ,
@@ -135,7 +135,7 @@ impl ApolloTracing {
135
135
uname : Uname :: new ( )
136
136
. ok ( )
137
137
. map ( |x| x. to_string ( ) )
138
- . unwrap_or ( "No uname provided" . to_string ( ) ) ,
138
+ . unwrap_or_else ( || "No uname provided" . to_string ( ) ) ,
139
139
hostname,
140
140
graph_ref,
141
141
service_version : release_name,
@@ -164,13 +164,13 @@ impl ApolloTracing {
164
164
}
165
165
None => {
166
166
let mut trace_and_stats = TracesAndStats :: new ( ) ;
167
- & trace_and_stats. mut_trace ( ) . push ( trace) ;
167
+ trace_and_stats. mut_trace ( ) . push ( trace) ;
168
168
169
169
hashmap. insert ( name, trace_and_stats) ;
170
170
}
171
171
}
172
172
173
- count = count + 1 ;
173
+ count += 1 ;
174
174
175
175
if count > batch_target {
176
176
use tracing:: { field, field:: debug, span, Level } ;
@@ -313,22 +313,28 @@ impl Extension for ApolloTracingExtension {
313
313
. data :: < ApolloTracingDataExt > ( )
314
314
. ok ( )
315
315
. cloned ( )
316
- . unwrap_or ( ApolloTracingDataExt :: default ( ) ) ;
316
+ . unwrap_or_else ( ApolloTracingDataExt :: default) ;
317
317
let client_name = tracing_extension
318
318
. client_name
319
- . unwrap_or ( "no client name" . to_string ( ) ) ;
319
+ . unwrap_or_else ( || "no client name" . to_string ( ) ) ;
320
320
let client_version = tracing_extension
321
321
. 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 ( ) ) ;
327
333
let method = tracing_extension. method . unwrap_or ( HTTPMethod :: UNKNOWN ) ;
328
334
let secure = tracing_extension. secure . unwrap_or ( false ) ;
329
335
let protocol = tracing_extension
330
336
. protocol
331
- . unwrap_or ( "no protocol " . to_string ( ) ) ;
337
+ . unwrap_or_else ( || "no operation " . to_string ( ) ) ;
332
338
let status_code = tracing_extension. status_code . unwrap_or ( 0 ) ;
333
339
334
340
let mut trace = Trace {
@@ -342,15 +348,15 @@ impl Extension for ApolloTracingExtension {
342
348
..Default :: default ( )
343
349
} ;
344
350
345
- & trace. set_details ( Trace_Details {
351
+ trace. set_details ( Trace_Details {
346
352
operation_name : operation_name
347
353
. map ( |x| x. to_string ( ) )
348
- . unwrap_or ( "no operation" . to_string ( ) ) ,
354
+ . unwrap_or_else ( || "no operation" . to_string ( ) ) ,
349
355
..Default :: default ( )
350
356
} ) ;
351
357
352
358
// Should come from Context / Headers
353
- & trace. set_http ( Trace_HTTP {
359
+ trace. set_http ( Trace_HTTP {
354
360
path,
355
361
host,
356
362
method : Trace_HTTP_Method :: from ( method) ,
@@ -360,33 +366,32 @@ impl Extension for ApolloTracingExtension {
360
366
..Default :: default ( )
361
367
} ) ;
362
368
363
- & trace. set_end_time ( Timestamp {
369
+ trace. set_end_time ( Timestamp {
364
370
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 ( ) ,
366
372
..Default :: default ( )
367
373
} ) ;
368
374
369
- & trace. set_start_time ( Timestamp {
375
+ trace. set_start_time ( Timestamp {
370
376
nanos : inner
371
377
. start_time
372
378
. timestamp_subsec_nanos ( )
373
379
. try_into ( )
374
380
. unwrap ( ) ,
375
- seconds : inner. start_time . timestamp ( ) . try_into ( ) . unwrap ( ) ,
381
+ seconds : inner. start_time . timestamp ( ) ,
376
382
..Default :: default ( )
377
383
} ) ;
378
384
379
385
let root_node = self . root_node . read ( ) . await ;
380
- & trace. set_root ( root_node. clone ( ) ) ;
386
+ trace. set_root ( root_node. clone ( ) ) ;
381
387
382
388
let sender = self . sender . clone ( ) ;
383
389
384
390
let operation_name = self . operation_name . read ( ) . await . clone ( ) ;
385
391
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
+ }
390
395
} ) ;
391
396
resp
392
397
}
@@ -439,8 +444,8 @@ impl Extension for ApolloTracingExtension {
439
444
Ok ( res) => Ok ( res) ,
440
445
Err ( e) => {
441
446
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 (
444
449
e. locations
445
450
. clone ( )
446
451
. into_iter ( )
@@ -455,7 +460,7 @@ impl Extension for ApolloTracingExtension {
455
460
Ok ( content) => content,
456
461
Err ( e) => serde_json:: json!( { "error" : format!( "{:?}" , e) } ) . to_string ( ) ,
457
462
} ;
458
- & error. set_json ( json) ;
463
+ error. set_json ( json) ;
459
464
node. write ( )
460
465
. await
461
466
. set_error ( RepeatedField :: from_vec ( vec ! [ error] ) ) ;
0 commit comments