-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't seem to intercept tracing - ends up in global default instead of overridden subscriber #1187
Comments
From what I see I guess what you want is to move That said it's still not as easy as just set up a span. |
I don't think it's using my subscriber because traces within my subscriber don't go to stdout. Only the global default subscriber is set to redirect to stdout. It feels like there's a manual thread (or maybe even multiple) being spawned somewhere (ie outside tokio) and if so that would be the problem because the default subscriber takes over and I'd need hooks similar to tokio runtime where I get notified of thread start and stop (or alternatively can inject a hook that is given the body of the thread to run within a scope). This would make sense since a bunch of threads are named after xitca. I don't think it's an issue around scope/instrument macros which I believe simply relate traces together vs change where they're sent. |
The server create a specific runtime to spawn worker thread, that's certainly why it goes to the default global subscriber instead of your own, However there is a Maybe you can set your specific subscriber there. |
Nope, installing a subscriber doesn't seem to do anything to the output. I don't think it's the worker threads. I think the logs are coming from a thread that xitca is spawning to do the main work. I put a log message when I install the thread local storage. As you can see on_worker_start is working as expected. However you can see "Got INFO log from xitca at default subscriber" is followed by "xitca_server::net: Started Tcp listening" which indicates that that message is from some other thread. A similar effect is observed for
Here's the full log from my test case
|
The problem is this line:
There's no mechanism to intercept that. Maybe I can hack it by giving a custom |
Interesting. Would removing the scoped thread make thing work? |
Not sure. I would think so but I also took a stab at plumbing through a bunch of callbacks that would let me install the span and that didn't seem to work (didn't debug it too thoroughly so not sure) |
I would look into how the scope thread can be removed so tokio's call track won't be broken by it. |
xitca is an internal implementation detail within my library and I want to redirect its logs to my own tracing subscriber. So in my app I have something like:
In my
my_lib::init()
fn I have something that simplifies to:However when I run my executable, I get messages like:
Obviously my goal isn't to actually turn off the messages. I want them to be silently redirected to my logging endpoint instead rather than bubbling all the way up. I'm just using the "off" as a simple way to verify my subscriber is the one receiving the messages instead of the global default. Any tips on what I'm doing wrong would be appreciated.
Apologies if the example code contains typos - I was trying to reduce it to the smallest possible example without having to build an entirely new working project.
The text was updated successfully, but these errors were encountered: