@@ -18,6 +18,7 @@ use chrono::{DateTime, Utc};
18
18
use futures:: lock:: Mutex ;
19
19
use protobuf:: well_known_types:: Timestamp ;
20
20
use protobuf:: RepeatedField ;
21
+ use std:: convert:: TryFrom ;
21
22
22
23
use async_graphql:: extensions:: {
23
24
Extension , ExtensionContext , ExtensionFactory , NextExecute , NextParseQuery , NextResolve ,
@@ -404,7 +405,7 @@ impl Extension for ApolloTracingExtension {
404
405
let field_name = info. path_node . field_name ( ) . to_string ( ) ;
405
406
let parent_type = info. parent_type . to_string ( ) ;
406
407
let return_type = info. return_type . to_string ( ) ;
407
- let start_time = Utc :: now ( ) ;
408
+ let start_time = Utc :: now ( ) - self . inner . lock ( ) . await . start_time ;
408
409
let path_node = info. path_node ;
409
410
410
411
let node: Trace_Node = Trace_Node {
@@ -417,7 +418,13 @@ impl Extension for ApolloTracingExtension {
417
418
Some ( Trace_Node_oneof_id :: index ( index. try_into ( ) . unwrap_or ( 0 ) ) )
418
419
}
419
420
} ,
420
- start_time : start_time. timestamp_nanos ( ) . try_into ( ) . unwrap ( ) ,
421
+ start_time : match start_time
422
+ . num_nanoseconds ( )
423
+ . and_then ( |x| u64:: try_from ( x) . ok ( ) )
424
+ {
425
+ Some ( duration) => duration,
426
+ None => Utc :: now ( ) . timestamp_nanos ( ) . try_into ( ) . unwrap ( ) ,
427
+ } ,
421
428
parent_type : parent_type. to_string ( ) ,
422
429
original_field_name : field_name,
423
430
field_type : return_type,
0 commit comments