discourse / prometheus_exporter

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

"super: no superclass method `async_exec'" error in v2.0.4. #252

Closed snowfield702 closed 1 year ago

snowfield702 commented 1 year ago

After upgrading to 2.0.4, the following error occurred when starting Ruby on Rails.

ERROR -- : super: no superclass method `async_exec' for #<PG::Connection:0x00007ff19d120b38 host=example.com port=5432 user=sample>
Did you mean?  sync_exec
               async_reset (NoMethodError)
/vendor/bundle/ruby/3.1.0/gems/prometheus_exporter-2.0.4/lib/prometheus_exporter/instrumentation/method_profiler.rb:63:in `async_exec'

We choose :prepend for the style of method patching. https://github.com/discourse/prometheus_exporter#choosing-the-style-of-method-patching

I think that it is the effect of changing prepend_instument to klass in the following correspondence. https://github.com/discourse/prometheus_exporter/pull/250/files#diff-cb9a335ee1d17a77e55d1bc374c4c76ebbf05e6b84de4ce41f1fbc560bda41b7R63

oakcask commented 1 year ago

Hi maintainers,

Checked the code and wrote a patch below, I thought it would fix this https://github.com/discourse/prometheus_exporter/pull/254 Could you please take a time to check this up?

I and my colleagues are always helped by prometheus_exporter gem. Thank you.

SamSaffron commented 1 year ago

thanks heaps for the PR and bug report, just working through the test cases atm, will try to do a release tomorrow once sorted