mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
966 B
966 B
Instrumentation
ActiveModelSerializers uses the ActiveSupport::Notification API, which allows for subscribing to events, such as for logging.
Events
Name:
render.active_model_serializers
Payload (example):
{
serializer: PostSerializer,
adapter: ActiveModel::Serializer::Adapter::Attributes
}
Subscribing:
ActiveSupport::Notifications.subscribe 'render.active_model_serializers' do |name, started, finished, unique_id, data|
# whatever
end
ActiveSupport::Notifications.subscribe 'render.active_model_serializers' do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
# event.payload
# whatever
end
## [LogSubscriber](http://api.rubyonrails.org/classes/ActiveSupport/LogSubscriber.html)
ActiveModelSerializers includes an `ActiveModelSerializers::LogSubscriber` that attaches to
`render.active_model_serializers`.