-
Notifications
You must be signed in to change notification settings - Fork 136
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
Hotshots client not writing to telegraf server in process.on('exit') blocks, so I can't send exit codes as metrics #239
Comments
So I did some code searching in a forked repo and I think what's happening is that on the on-close when we try to flush, we do a non-synchronous socket send and then there's no callback handler to let us cycle until we've finished flushing. So the on(exit) just kills the process before we can send our message. And this is very very awkward.
So there's no on-send, and there's no receipt |
OK, so what I think is happening even more is that we're not tracking socket sends so if we do a sudden shutdown, there's no finally block saying "Hey, wait up, you're in the middle of sending 3 metrics" I have ripped libs/statsd.js to shreds adding callbacks and synchronous infinite while loops until callback done and since we're not tracking these metrics, we're just in callback hell. Also, there's no way to get a callback on SUCCESS of a close. So there's no way in process.on('exit') to wait on our callbacks until the flush and close has completed. |
Update: This is because our socket calls aren't calling their callbacks.
I stick a console.log('Handling Callback') into
in lib/statsd.js
Before process.on('exit')
(Ignore the line numbers, I'm doing printf debugging + breakpoints)
So what I think is happening is that the socket call doesn't work because you're never allowed to go async in process.on('exit')
I don't know for sure, but I do know that that socket call doesn't call its callback because I put a breakpoint on it and it fires outside of process.on('exit'), but not in it. So once you've caught an unhandled exception, there's no good way to send metrics from your application and we can't containerize/orchestrate this, so I guess we're going to run a 3rd-party application that does nothing but run a StatsD call, wait for the callbacks, then quit.
Original Post:
When I write metrics synchronously, I get metrics out
When I write metrics from process.on('uncaughtExceptionMonitor') or process.on('exit') blocks, the log messages all show up in my stderr, none of my metrics send. What am I doing wrong on hotshots 9.3.0?
The text was updated successfully, but these errors were encountered: