Guides > Instrumentation

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: ActiveModelSerializers::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

ActiveModelSerializers includes an ActiveModelSerializers::LogSubscriber that attaches to render.active_model_serializers.

results matching ""

    No results matching ""