Skip to content

Add Instrumentation Support with ActiveSupport::Notifications #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 19, 2019
Merged

Add Instrumentation Support with ActiveSupport::Notifications #127

merged 8 commits into from
Nov 19, 2019

Conversation

djones
Copy link
Collaborator

@djones djones commented Nov 13, 2019

Using ActiveSupport::Notifications this PR allows you to 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.

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

@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec", "~> 3.2"
spec.add_development_dependency "factory_girl", "~> 4.5"
spec.add_development_dependency "activemodel", "~> 4.2"
spec.add_development_dependency "pry"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove if you want but it was nice to have.

@@ -16,6 +17,7 @@ def serialize_primary(object, options = {})
primary_data = serialize_primary(nil, {serializer: MyApp::PostSerializer})
expect(primary_data).to be_nil
end

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

@fotinakis fotinakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌮

We'll make this a major version bump.

@fotinakis fotinakis merged commit 406be39 into fotinakis:master Nov 19, 2019
@fotinakis
Copy link
Owner

released in jsonapi-serializers (2.0.0.pre.beta.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants