Last active
February 2, 2024 19:18
-
-
Save luizpvas/b9ec1ffc58f7aed39a38fccefe86549c to your computer and use it in GitHub Desktop.
rails instrumentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.development? | |
::ActiveSupport::Notifications.subscribe 'µ-case' do |*args| | |
result = args.extract_options![:result] | |
description = result.use_case.class.name | |
Rack::MiniProfiler.step("µ-case: #{description}") do | |
Rails.logger.warn "µ-case called: #{description}" | |
end | |
end | |
module Micro | |
class Case | |
class Result | |
class Transitions | |
MapEverything = ->(result, use_case_attributes) do | |
::ActiveSupport::Notifications.instrument 'µ-case', result: result do | |
{ | |
use_case: { class: result.use_case.class, attributes: use_case_attributes }, | |
result.to_sym => { type: result.type, result: result.data }, | |
accessible_attributes: result.accessible_attributes | |
} | |
end | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment