dbader/node-datadog-metrics

Flush won't call callback when buffer is empty which cause having long running app

Closed this issue · 1 comments

Hello :)
I'm not sure if I am missing anything here or not but I expect when I call flush(onSuccess, onError) method, it calls at least one of the callbacks even if there's no metric to flush.
But apparently, according to this part of code, when buffer is empty, non of the callbacks are being called.

My use case is, I need to make sure all buffered metrics are sent before I intentionally exit my app which make sense to me since your Readme is also suggesting that:

It can be useful to trigger a manual flush by calling if you want to make sure pending metrics have been sent before you quit the application process, for example.

metrics.flush(() => {
    process.exit(0) // <-- this will never being executed
})

I can solve the issue in my app in a hacky way but I prefer to correct it either by fixing upstream or by a better solution.

Thanks! Published to npm in v0.6.0.