From 9cc009dc3a835021fe47c82daab15b58769d53fd Mon Sep 17 00:00:00 2001 From: Zahari Dichev Date: Mon, 6 Sep 2021 11:43:52 +0000 Subject: [PATCH] subscriber: look at event parents to determine resource id Signed-off-by: Zahari Dichev --- console-subscriber/src/lib.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/console-subscriber/src/lib.rs b/console-subscriber/src/lib.rs index 0c91eb750..29eb02ac1 100644 --- a/console-subscriber/src/lib.rs +++ b/console-subscriber/src/lib.rs @@ -403,8 +403,8 @@ where } // else unknown waker event... what to do? can't trace it from here... } else if self.poll_op_callsites.contains(event.metadata()) { - match ctx.current_span().id() { - Some(resource_id) if self.is_id_resource(resource_id, &ctx) => { + match ctx.event_span(event) { + Some(resource_span) if self.is_resource(resource_span.metadata()) => { let mut poll_op_visitor = PollOpVisitor::default(); event.record(&mut poll_op_visitor); if let Some((op_name, is_ready)) = poll_op_visitor.result() { @@ -422,21 +422,28 @@ where self.send(Event::PollOp { metadata, at, - resource_id: resource_id.clone(), + resource_id: resource_span.id(), op_name, async_op_id, task_id, is_ready, }); + } else { + eprintln!( + "poll op event should be emitted in the context of an async op and task spans: {:?}", + event + ) } - // else poll op event should be emitted in the context of an async op and task spans } } - _ => {} // poll op event should be emitted in the context of a resource span + _ => eprintln!( + "poll op event should have a resource span parent: {:?}", + event + ), } } else if self.state_update_callsites.contains(event.metadata()) { - match ctx.current_span().id() { - Some(resource_id) if self.is_id_resource(resource_id, &ctx) => { + match ctx.event_span(event) { + Some(resource_span) if self.is_resource(resource_span.metadata()) => { let meta_id = event.metadata().into(); let mut state_update_visitor = StateUpdateVisitor::new(meta_id); event.record(&mut state_update_visitor); @@ -445,13 +452,13 @@ where self.send(Event::StateUpdate { metadata, at, - resource_id: resource_id.clone(), + resource_id: resource_span.id(), update, }); } } _ => eprintln!( - "state update event should be emitted in the context of a resource span: {:?}", + "state update event should have a resource span parent: {:?}", event ), }