cucumber icon indicating copy to clipboard operation
cucumber copied to clipboard

Allow setting `with_span_events` on the `tracing` `Layer`

Open RemiBardon opened this issue 1 year ago • 4 comments

I'd like to set .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) on the tracing Layer when running Cucumber, but there is no API for it. I have tried plenty of workarounds, but I always get duplicated, unordered or missing logs. Could you please provide an API for customizing your tracing Layer?

RemiBardon avatar Jan 06 '25 16:01 RemiBardon

@RemiBardon could you elaborate more on this? It's hard for me to understand why .configure_and_init_tracing() doesn't solve your problem, given that you're free to do pretty much everything with the fmt_layer passed to the closure?

tyranron avatar Jan 20 '25 12:01 tyranron

@tyranron fmt_layer is not a Layer, it's a Layered, which means it doesn't have the with_span_events function. Your library doesn't expose a way to access this function on the non-Layered Layer (which is what I need).

RemiBardon avatar Jan 20 '25 13:01 RemiBardon

@RemiBardon actually, the struct Layered implements the Layer trait. However, you're referring to the fmt::Layer struct and its method, not the Layer trait. I see... and you want to access the initialized fmt::layer() directly to tweak it. Layered::downcast_ref() won't be much help here too, because the required methods have the self receiver, and we don't have Layered::downcast_mut() to mem::swap() it in any way too.

Ok. I will play with possible API extensions to support it and will ask your opinion on it. Thanks for making this clear!

tyranron avatar Jan 20 '25 14:01 tyranron

@tyranron Oh yes sorry I was on my phone I tried to remember my previous explorations. Thank you for looking into it!

RemiBardon avatar Jan 20 '25 14:01 RemiBardon