我有一个很棒的模型:
class Account < ActiveRecord::Base
devise ::trackable我想看看在Librato中创建和登录Account的次数。
发布于 2015-10-09 07:45:21
使用Librato的log stream parsing,您可以使用$stdout.puts记录事件。
我建议将此日志提取到concern中,并使用model callbacks监视更改。
我们可以在lib/librato/account.rb中创建一个文件
module Librato
module Account
extend ActiveSupport::Concern
included do
after_create do
$stdout.puts 'count#account.create=1'
end
after_save if: :current_sign_in_at_changed? do
$stdout.puts 'count#account.sign_in=1'
end
end
end
end然后将其包含在模型中,如下所示:
class Account < ActiveRecord::Base
include Librato::Accounthttps://stackoverflow.com/questions/33027721
复制相似问题