Closed cernyjakub closed 3 years ago
We also ran into this and it's quite important for us to fix this issue.
I fixed it in https://github.com/shadabahmed/logstasher/pull/148. In the meantime, we will depend on our fork with the fix, since we can't afford waiting.
Hmm, does the db timing depend on config.logstasher.record_enabled
? I have that set to false because I don't need the full SQL statements logged, but it seems like with that set to false I don't get DB timings either.
I have same issue on latest version (v2.1.5) with both rails 6.1 and 7.0. DB timing seems depends on either record_enabled:true
or suppress_app_log:false
, otherwise it always be 0.0.
I've found a workaround.
class CustomLogSubscriber < ActiveRecord::LogSubscriber
def sql(event)
self.class.runtime += event.duration
end
end
CustomLogSubscriber.attach_to :active_record
Note that this might be broken after Rails 7.1 by https://github.com/rails/rails/pull/46041
Yeah looking at it now it seems like the log subscriber just won't be attached unless using those other options. It might be nice to have additional options if you want to log timing information but not the raw SQL or the view logs.
When I disable app log with
suppress_app_log
, it automatically switches all:db
fields to be0
.Rails 5.0.3. Happens both in development and production modes.
Anyway, thanks for great gem.