Store the profiler in the context instead of a thread-local variable (#1364)

This commit is contained in:
Dylan Thacker-Smith
2020-12-09 10:04:20 -05:00
committed by GitHub
parent 7361220af6
commit 60214b957c
3 changed files with 33 additions and 26 deletions
+16 -1
View File
@@ -3,10 +3,25 @@
module Liquid
module BlockBodyProfilingHook
def render_node(context, output, node)
Profiler.profile_node_render(node, context.template_name) do
if (profiler = context.profiler)
profiler.profile_node(node, context.template_name) do
super
end
else
super
end
end
end
BlockBody.prepend(BlockBodyProfilingHook)
module ContextProfilingHook
attr_accessor :profiler
def new_isolated_subcontext
new_context = super
new_context.profiler = profiler
new_context
end
end
Context.prepend(ContextProfilingHook)
end