ocharles / prometheus-effect

Yet another Haskell Prometheus client
https://hackage.haskell.org/package/prometheus-effect
BSD 3-Clause "New" or "Revised" License
11 stars 1 forks source link

Is it expected that gc stats collecting thread never fails? #1

Closed qrilka closed 6 years ago

qrilka commented 6 years ago

ghcStats returns IO action to fork a thread but gives (almost) no way to control its lifetime. If I understand it correctly the only way to find out if ThreadId is alive is to call threadCapability which looks a bit odd. Also that thread exits with a message in STDOUT if GC stats are not enabled. Wouldn't it be better for this function to have a type m (Maybe (IO ())) so Nothing would mean that GC stats are not enableds and return IO () could be e.g. linked to the main thread using link from async package. Or maybe I miss something here and there is easier way to control ghc metrics thread lifetime?

qrilka commented 6 years ago

I've found threadStatus but it still looks inconvenient to add extra code to check (periodically) that thread is alive

ocharles commented 6 years ago

Given the simplicity of that code, I would expect it to never die. That said, nothing guarantees that. Perhaps what you're looking for is to have the guarantee that it won't die, rather than doing monitoring of it yourself?

qrilka commented 6 years ago

Yes, some guarantee, I guess I could do that by adding setUncaughtExceptionHandler. And regarding thread exit when GC isn't enabled I see that you can't do that inside of MonadState but probably it's worth to warn about it in haddocks?

ocharles commented 6 years ago

And regarding thread exit when GC isn't enabled I see that you can't do that inside of MonadState but probably it's worth to warn about it in haddocks?

I don't quite understand this comment.

ocharles commented 6 years ago

Can you check master now and see if the latest commit does what you want?

qrilka commented 6 years ago

thanks, it great