discourse / prometheus_exporter

A framework for collecting and aggregating prometheus metrics
MIT License
525 stars 153 forks source link

FIX: ThreadError Handling #175

Closed keerthivaasan-kanagaraj closed 3 years ago

keerthivaasan-kanagaraj commented 3 years ago

Hi @SamSaffron

We observed ThreadError was raised from prometheus_exporter when sidekiq triggers SHUTDOWN EXCEPTION.It was due to some improper shutdowns.

As per ruby ThreadError will raise only when main thread is killed then we are trying to create child thread for that main thread

if (GET_VM()->main_thread->status == THREAD_KILLED)
rb_raise(rb_eThreadError, "can't alloc thread");

So need to catch exception in Prometheus gem to handle this error.

Ref. PR: (opentelemetry-ruby) https://github.com/open-telemetry/opentelemetry-ruby/pull/607

SamSaffron commented 3 years ago

Seems good to me, a tiny bit fragile in case Ruby change the text on the exception but I guess that is the best we can do here.