提交 fb6c661f 编写于 作者: R Rafael Mendonça França

Merge pull request #10145 from wangjohn/instrumentation_registry_creation

Consolidating thread locals in AS::Notifications
......@@ -177,7 +177,33 @@ def unsubscribe(args)
end
def instrumenter
Thread.current[:"instrumentation_#{notifier.object_id}"] ||= Instrumenter.new(notifier)
InstrumentationRegistry.instrumenter_for(notifier)
end
end
# This class is a registry which holds all of the +Instrumenter+ objects
# in a particular thread local. To access the +Instrumenter+ object for a
# particular +notifier+, you can call the following method:
#
# InstrumentationRegistry.instrumenter_for(notifier)
#
# The instrumenters for multiple notifiers are held in a single instance of
# this class.
class InstrumentationRegistry # :nodoc:
class << self
delegate :instrumenter_for, to: :current
def current
Thread.current[:instrumentation_registry] ||= new
end
end
def initialize
@registry = {}
end
def instrumenter_for(notifier)
@registry[notifier] ||= Instrumenter.new(notifier)
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册