tracing-test icon indicating copy to clipboard operation
tracing-test copied to clipboard

Using in combination with tracing-fluent-assertions not possible

Open matthiasbeyer opened this issue 6 months ago • 2 comments

I would love to use both crates, the tracing-fluent-assertions one to test whether a particular span was entered, this one to test whether a specific log output was generated.

Unfortunately, it is not possible, as this crate sets a global subscriber but tracing-fluent-assertions also needs to set the global subscriber.

It would be lovely if there was a plumbing API for this crate that allowed me to get the relevant Layers for this subscriber so that I can combine both this library and tracing-fluent-assertions with one global subscriber.

Would that be possible?

matthiasbeyer avatar Aug 07 '25 08:08 matthiasbeyer

This is tricky, because the initialization logic is injected into every test using the macro: https://github.com/dbrgn/tracing-test/blob/5d645cb8ef31aee22023c4590b6ee14cbe7577a5/tracing-test-macro/src/lib.rs#L67-L88

If you have a good suggestion on to achieve this: I'm open to suggestions.

But it might be better to ask tracing, to consider whether there could be a system where multiple global subscribers could be set...

dbrgn avatar Aug 08 '25 13:08 dbrgn

Well, the idea would be not to use the macro, but set up tracing infra at the first line of every test myself!

matthiasbeyer avatar Aug 08 '25 14:08 matthiasbeyer