@@ -18,6 +18,7 @@ use chrono::{DateTime, Utc};
1818use futures:: lock:: Mutex ;
1919use protobuf:: well_known_types:: Timestamp ;
2020use protobuf:: RepeatedField ;
21+ use std:: convert:: TryFrom ;
2122
2223use async_graphql:: extensions:: {
2324 Extension , ExtensionContext , ExtensionFactory , NextExecute , NextParseQuery , NextResolve ,
@@ -404,7 +405,7 @@ impl Extension for ApolloTracingExtension {
404405 let field_name = info. path_node . field_name ( ) . to_string ( ) ;
405406 let parent_type = info. parent_type . to_string ( ) ;
406407 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 ;
408409 let path_node = info. path_node ;
409410
410411 let node: Trace_Node = Trace_Node {
@@ -417,7 +418,13 @@ impl Extension for ApolloTracingExtension {
417418 Some ( Trace_Node_oneof_id :: index ( index. try_into ( ) . unwrap_or ( 0 ) ) )
418419 }
419420 } ,
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+ } ,
421428 parent_type : parent_type. to_string ( ) ,
422429 original_field_name : field_name,
423430 field_type : return_type,
0 commit comments