README.md in jsonapi-serializers-1.0.1 vs README.md in jsonapi-serializers-2.0.0.pre.beta.1
- old
+ new
@@ -27,10 +27,11 @@
* [Sparse fieldsets](#sparse-fieldsets)
* [Relationships](#relationships)
* [Compound documents and includes](#compound-documents-and-includes)
* [Relationship path handling](#relationship-path-handling)
* [Control links and data in relationships](#control-links-and-data-in-relationships)
+* [Instrumentation](#instrumentation)
* [Rails example](#rails-example)
* [Sinatra example](#sinatra-example)
* [Unfinished business](#unfinished-business)
* [Contributing](#contributing)
@@ -637,9 +638,33 @@
"data": {
"type": "users",
"id": "1"
}
}
+```
+
+## Instrumentation
+
+Using [ActiveSupport::Notifications](https://api.rubyonrails.org/classes/ActiveSupport/Notifications.html) you can subscribe to key notifications to better understand the performance of your serialization.
+
+The following notifications can be subscribed to:
+
+* `render.jsonapi_serializers.serialize_primary` - time spent serializing a single object
+* `render.jsonapi_serializers.find_recursive_relationships` - time spent finding objects to serialize through relationships
+
+This is an example of how you might subscribe to all events that come from `jsonapi-serializers`.
+
+```ruby
+require 'active_support/notifications'
+
+ActiveSupport::Notifications.subscribe(/^render\.jsonapi_serializers\..*/) do |*args|
+ event = ActiveSupport::Notifications::Event.new(*args)
+
+ puts event.name
+ puts event.time
+ puts event.end
+ puts event.payload
+end
```
## Rails example
```ruby