haskell-github-trust / ekg-statsd

Flush system metrics to statsd
BSD 3-Clause "New" or "Revised" License
26 stars 23 forks source link

Killing the statsd thread kills the calling thread #19

Closed tswelsh closed 6 years ago

tswelsh commented 6 years ago

We are using forkStatsd to start collecting stats, and later on stopping the stats collection by calling killThread on the statsdThreadId, as indicated in the documentation. However, the implementation of forkStatsd rethrows all exceptions coming from the forked thread to the thread that called forkStatsd in the first place, including any ThreadKilled exceptions. This was confusing to say the least!

Is this the expected behaviour, or am I missing a better way of doing this? It feels a bit clumsy to control the Statsd by throwing an exception that you then have to remember to catch, and you have no guarantee that the exception you catch is the one you threw in the first place. This also feels inconsistent with a normal forkIO which swallows ThreadKilled (and Blocked*) exceptions so you don't see them in the main thread.

tibbe commented 6 years ago

Rethrowing that exception back to the caller wasn't intended.