Class: NewRelic::Agent::ThreadProfiler
- Inherits:
-
Object
- Object
- NewRelic::Agent::ThreadProfiler
- Defined in:
- lib/new_relic/agent/thread_profiler.rb
Instance Attribute Summary collapse
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Class Method Summary collapse
Instance Method Summary collapse
- #finished? ⇒ Boolean
- #harvest ⇒ Object
- #respond_to_commands(commands, ¬ify_results) ⇒ Object
- #running? ⇒ Boolean
- #start(profile_id, duration, interval, profile_agent_code) ⇒ Object
- #stop(report_data) ⇒ Object
Instance Attribute Details
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
9 10 11 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 9 def profile @profile end |
Class Method Details
.is_supported? ⇒ Boolean
11 12 13 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 11 def self.is_supported? RUBY_VERSION >= "1.9.2" end |
Instance Method Details
#finished? ⇒ Boolean
61 62 63 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 61 def finished? @profile && @profile.finished? end |
#harvest ⇒ Object
31 32 33 34 35 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 31 def harvest profile = @profile @profile = nil profile end |
#respond_to_commands(commands, ¬ify_results) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 37 def respond_to_commands(commands, ¬ify_results) return if commands.empty? || commands.first.size < 2 # Doesn't deal with multiple commands in the return set as # we currently only have start/stop of thread profiling command_id = commands.first[0] command = commands.first[1] name = command["name"] arguments = command["arguments"] case name when "start_profiler" start_unless_running_and_notify(command_id, arguments, ¬ify_results) when "stop_profiler" stop_and_notify(command_id, arguments, ¬ify_results) end end |
#running? ⇒ Boolean
57 58 59 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 57 def running? !@profile.nil? end |
#start(profile_id, duration, interval, profile_agent_code) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 15 def start(profile_id, duration, interval, profile_agent_code) if !ThreadProfiler.is_supported? log.debug("Not starting thread profile as it isn't supported on this environment") @profile = nil else log.debug("Starting thread profile. profile_id=#{profile_id}, duration=#{duration}") @profile = ThreadProfile.new(profile_id, duration, interval, profile_agent_code) @profile.run end end |
#stop(report_data) ⇒ Object
26 27 28 29 |
# File 'lib/new_relic/agent/thread_profiler.rb', line 26 def stop(report_data) @profile.stop unless @profile.nil? @profile = nil if !report_data end |