rails-profiler 0.44.34 → 0.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/app/assets/builds/profiler-toolbar.js +2 -2
- data/app/assets/builds/profiler.css +1 -1
- data/app/assets/builds/profiler.js +5 -5
- data/lib/profiler/console_profiler.rb +12 -1
- data/lib/profiler/instrumentation/pry_instrumentation.rb +19 -0
- data/lib/profiler/middleware/toolbar_injector.rb +4 -0
- data/lib/profiler/railtie.rb +11 -2
- data/lib/profiler/version.rb +1 -1
- metadata +2 -1
|
@@ -25,10 +25,21 @@ module Profiler
|
|
|
25
25
|
Collectors::FlameGraphCollector
|
|
26
26
|
].freeze
|
|
27
27
|
|
|
28
|
+
RECORDING_KEY = :profiler_console_recording
|
|
29
|
+
|
|
28
30
|
def self.profile(expression:, &block)
|
|
29
31
|
return block.call unless Profiler.enabled? && Profiler.configuration.track_console
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
# IRB and Pry can both be loaded and both evaluate the same expression: only the
|
|
34
|
+
# outermost one records it.
|
|
35
|
+
return block.call if Thread.current[RECORDING_KEY]
|
|
36
|
+
|
|
37
|
+
begin
|
|
38
|
+
Thread.current[RECORDING_KEY] = true
|
|
39
|
+
new(expression: expression).run(&block)
|
|
40
|
+
ensure
|
|
41
|
+
Thread.current[RECORDING_KEY] = nil
|
|
42
|
+
end
|
|
32
43
|
end
|
|
33
44
|
|
|
34
45
|
def initialize(expression:)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Profiler
|
|
4
|
+
module Instrumentation
|
|
5
|
+
# Prepended to Pry. Pry commands (ls, cd...) do not go through #evaluate_ruby and are not profiled.
|
|
6
|
+
module PryInstrumentation
|
|
7
|
+
def evaluate_ruby(code)
|
|
8
|
+
Profiler.env_override_store.apply!
|
|
9
|
+
stripped = code.to_s.strip
|
|
10
|
+
skip = !Profiler.enabled? ||
|
|
11
|
+
!Profiler.configuration.track_console ||
|
|
12
|
+
stripped.empty?
|
|
13
|
+
return super if skip
|
|
14
|
+
|
|
15
|
+
Profiler::ConsoleProfiler.profile(expression: stripped) { super }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -333,7 +333,11 @@ module Profiler
|
|
|
333
333
|
color: var(--pf-amber);
|
|
334
334
|
font-weight: 600;
|
|
335
335
|
letter-spacing: .02em;
|
|
336
|
+
display: inline-flex;
|
|
337
|
+
align-items: center;
|
|
338
|
+
gap: 6px;
|
|
336
339
|
}
|
|
340
|
+
#profiler-toolbar .profiler-toolbar-logo-mark { flex: none; display: block; }
|
|
337
341
|
#profiler-toolbar .profiler-toolbar-logo:hover { color: var(--pf-amber-h); }
|
|
338
342
|
|
|
339
343
|
/* Error state: the profile could not be loaded, or a component failed. */
|
data/lib/profiler/railtie.rb
CHANGED
|
@@ -169,8 +169,17 @@ module Profiler
|
|
|
169
169
|
next unless Profiler.configuration.enabled && Profiler.configuration.track_console
|
|
170
170
|
|
|
171
171
|
require_relative "console_profiler"
|
|
172
|
-
|
|
173
|
-
IRB
|
|
172
|
+
|
|
173
|
+
# A console is IRB or Pry (pry-rails): instrument whichever is loaded, never assume IRB.
|
|
174
|
+
if defined?(IRB::Context)
|
|
175
|
+
require_relative "instrumentation/irb_instrumentation"
|
|
176
|
+
IRB::Context.prepend(Profiler::Instrumentation::IrbInstrumentation)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if defined?(Pry)
|
|
180
|
+
require_relative "instrumentation/pry_instrumentation"
|
|
181
|
+
Pry.prepend(Profiler::Instrumentation::PryInstrumentation)
|
|
182
|
+
end
|
|
174
183
|
end
|
|
175
184
|
|
|
176
185
|
rake_tasks do
|
data/lib/profiler/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-profiler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.45.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sébastien Duplessy
|
|
@@ -197,6 +197,7 @@ files:
|
|
|
197
197
|
- lib/profiler/instrumentation/executor_context_propagation.rb
|
|
198
198
|
- lib/profiler/instrumentation/irb_instrumentation.rb
|
|
199
199
|
- lib/profiler/instrumentation/net_http_instrumentation.rb
|
|
200
|
+
- lib/profiler/instrumentation/pry_instrumentation.rb
|
|
200
201
|
- lib/profiler/instrumentation/request_context.rb
|
|
201
202
|
- lib/profiler/instrumentation/sidekiq_middleware.rb
|
|
202
203
|
- lib/profiler/instrumentation/thread_context_propagation.rb
|