Sha256: 29f6b6bb5e8885a3ae2c2943e2bc419ad5b9d0a0129ccc584dbac4c1d2626ab9

Contents?: true

Size: 1001 Bytes

Versions: 15

Compression:

Stored size: 1001 Bytes

Contents

[Back to Guides](../README.md)

# Instrumentation

ActiveModelSerializers uses the
[ActiveSupport::Notification API](http://guides.rubyonrails.org/active_support_instrumentation.html#subscribing-to-an-event),
which allows for subscribing to events, such as for logging.

## Events

Name:

`render.active_model_serializers`

Payload (example):

```ruby
{
  serializer: PostSerializer,
  adapter: ActiveModelSerializers::Adapter::Attributes
}
```

Subscribing:

```ruby
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`.

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
active_model_serializers_custom-0.10.90 docs/general/instrumentation.md
active_model_serializers-0.10.9 docs/general/instrumentation.md
active_model_serializers-0.10.8 docs/general/instrumentation.md
active_model_serializers-0.10.7 docs/general/instrumentation.md
active_model_serializers-0.10.6 docs/general/instrumentation.md
active_model_serializers-0.10.5 docs/general/instrumentation.md
active_model_serializers-0.10.4 docs/general/instrumentation.md
agi_active_model_serializers-0.10.9 docs/general/instrumentation.md
agi_active_model_serializers-0.10.8 docs/general/instrumentation.md
agi_active_model_serializers-0.10.7 docs/general/instrumentation.md
active_model_serializers-0.10.3 docs/general/instrumentation.md
active_model_serializers-0.10.2 docs/general/instrumentation.md
active_model_serializers-0.10.1 docs/general/instrumentation.md
active_model_serializers-0.10.0 docs/general/instrumentation.md
active_model_serializers-0.10.0.rc5 docs/general/instrumentation.md