@@ -276,54 +276,56 @@ pub fn serve(store: Arc<StoreContainer>) -> Result<()> {
276
276
) ?;
277
277
}
278
278
ClientToServerMessage :: Query { id } => {
279
- let message = if let Some ( ( span, is_graph) ) =
280
- state. store . read ( ) . span ( id)
281
- {
282
- let span_start = span. start ( ) ;
283
- let span_end = span. end ( ) ;
284
- let duration = span. corrected_total_time ( ) ;
285
- let allocations = span. total_allocations ( ) ;
286
- let deallocations = span. total_deallocations ( ) ;
287
- let allocation_count = span. total_allocation_count ( ) ;
288
- let persistent_allocations =
289
- span. total_persistent_allocations ( ) ;
290
- let args = span
291
- . args ( )
292
- . map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) )
293
- . collect ( ) ;
294
- let mut path = Vec :: new ( ) ;
295
- let mut current = span;
296
- while let Some ( parent) = current. parent ( ) {
297
- path. push ( parent. nice_name ( ) . 1 . to_string ( ) ) ;
298
- current = parent;
299
- }
300
- path. reverse ( ) ;
301
- ServerToClientMessage :: QueryResult {
302
- id,
303
- is_graph,
304
- start : span_start,
305
- end : span_end,
306
- duration,
307
- allocations,
308
- deallocations,
309
- allocation_count,
310
- persistent_allocations,
311
- args,
312
- path,
313
- }
314
- } else {
315
- ServerToClientMessage :: QueryResult {
316
- id,
317
- is_graph : false ,
318
- start : 0 ,
319
- end : 0 ,
320
- duration : 0 ,
321
- allocations : 0 ,
322
- deallocations : 0 ,
323
- allocation_count : 0 ,
324
- persistent_allocations : 0 ,
325
- args : Vec :: new ( ) ,
326
- path : Vec :: new ( ) ,
279
+ let message = {
280
+ let store = state. store . read ( ) ;
281
+ if let Some ( ( span, is_graph) ) = store. span ( id) {
282
+ let root_start = store. root_span ( ) . start ( ) ;
283
+ let span_start = span. start ( ) - root_start;
284
+ let span_end = span. end ( ) - root_start;
285
+ let duration = span. corrected_total_time ( ) ;
286
+ let allocations = span. total_allocations ( ) ;
287
+ let deallocations = span. total_deallocations ( ) ;
288
+ let allocation_count = span. total_allocation_count ( ) ;
289
+ let persistent_allocations =
290
+ span. total_persistent_allocations ( ) ;
291
+ let args = span
292
+ . args ( )
293
+ . map ( |( k, v) | ( k. to_string ( ) , v. to_string ( ) ) )
294
+ . collect ( ) ;
295
+ let mut path = Vec :: new ( ) ;
296
+ let mut current = span;
297
+ while let Some ( parent) = current. parent ( ) {
298
+ path. push ( parent. nice_name ( ) . 1 . to_string ( ) ) ;
299
+ current = parent;
300
+ }
301
+ path. reverse ( ) ;
302
+ ServerToClientMessage :: QueryResult {
303
+ id,
304
+ is_graph,
305
+ start : span_start,
306
+ end : span_end,
307
+ duration,
308
+ allocations,
309
+ deallocations,
310
+ allocation_count,
311
+ persistent_allocations,
312
+ args,
313
+ path,
314
+ }
315
+ } else {
316
+ ServerToClientMessage :: QueryResult {
317
+ id,
318
+ is_graph : false ,
319
+ start : 0 ,
320
+ end : 0 ,
321
+ duration : 0 ,
322
+ allocations : 0 ,
323
+ deallocations : 0 ,
324
+ allocation_count : 0 ,
325
+ persistent_allocations : 0 ,
326
+ args : Vec :: new ( ) ,
327
+ path : Vec :: new ( ) ,
328
+ }
327
329
}
328
330
} ;
329
331
let message = serde_json:: to_string ( & message) . unwrap ( ) ;
0 commit comments