Class: ActionDispatch::ServerTiming::Subscriber
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
::Singleton
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/middleware/server_timing.rb |
Constant Summary
-
KEY =
# File 'actionpack/lib/action_dispatch/middleware/server_timing.rb', line 11:action_dispatch_server_timing_events
Class Method Summary
- .new ⇒ Subscriber constructor
Instance Attribute Summary
::Singleton
- Included
#duplicable? |
|
Instance Method Summary
Constructor Details
.new ⇒ Subscriber
# File 'actionpack/lib/action_dispatch/middleware/server_timing.rb', line 13
def initialize @mutex = Mutex.new end
Instance Method Details
#call(event)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/server_timing.rb', line 17
def call(event) if events = ActiveSupport::IsolatedExecutionState[KEY] events << event end end
#collect_events
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/server_timing.rb', line 23
def collect_events events = [] ActiveSupport::IsolatedExecutionState[KEY] = events yield events ensure ActiveSupport::IsolatedExecutionState.delete(KEY) end
#ensure_subscribed
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/server_timing.rb', line 32
def ensure_subscribed @mutex.synchronize do # Subscribe to all events, except those beginning with "!" Ideally we would be # more selective of what is being measured @subscriber ||= ActiveSupport::Notifications.subscribe(/\A[^!]/, self) end end
#unsubscribe
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/server_timing.rb', line 40
def unsubscribe @mutex.synchronize do ActiveSupport::Notifications.unsubscribe @subscriber @subscriber = nil end end