Class: OneApm::Agent::Threading::AgentThread
- Inherits:
-
Object
- Object
- OneApm::Agent::Threading::AgentThread
- Defined in:
- lib/one_apm/agent/threading/agent_thread.rb
Class Method Summary collapse
- .backing_thread_class ⇒ Object
- .backing_thread_class=(clazz) ⇒ Object
- .bucket_thread(thread, profile_agent_code) ⇒ Object
- .create(label, &blk) ⇒ Object
- .list ⇒ Object
- .scrub_backtrace(thread, profile_agent_code) ⇒ Object
Class Method Details
.backing_thread_class ⇒ Object
62 63 64 |
# File 'lib/one_apm/agent/threading/agent_thread.rb', line 62 def backing_thread_class @backing_thread_class end |
.backing_thread_class=(clazz) ⇒ Object
66 67 68 |
# File 'lib/one_apm/agent/threading/agent_thread.rb', line 66 def backing_thread_class=(clazz) @backing_thread_class = clazz end |
.bucket_thread(thread, profile_agent_code) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/one_apm/agent/threading/agent_thread.rb', line 36 def bucket_thread(thread, profile_agent_code) if thread.key?(:oneapm_label) profile_agent_code ? :agent : :ignore else state = TransactionState.tl_state_for(thread) if state.in_background_transaction? :background elsif state.in_web_transaction? :request else :other end end end |
.create(label, &blk) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/one_apm/agent/threading/agent_thread.rb', line 12 def create(label, &blk) OneApm::Manager.logger.debug("Creating OneApm thread: #{label}") wrapped_blk = Proc.new do begin blk.call rescue => e OneApm::Manager.logger.error("Thread #{label} exited with error", e) rescue Exception => e OneApm::Manager.logger.error("Thread #{label} exited with exception. Re-raising in case of interupt.", e) raise ensure OneApm::Manager.logger.debug("Exiting OneApm thread: #{label}") end end thread = backing_thread_class.new(&wrapped_blk) thread[:oneapm_label] = label thread end |
.list ⇒ Object
32 33 34 |
# File 'lib/one_apm/agent/threading/agent_thread.rb', line 32 def list backing_thread_class.list end |
.scrub_backtrace(thread, profile_agent_code) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/one_apm/agent/threading/agent_thread.rb', line 51 def scrub_backtrace(thread, profile_agent_code) begin bt = thread.backtrace rescue Exception => e OneApm::Manager.logger.debug("Failed to backtrace #{thread.inspect}: #{e.class.name}: #{e.to_s}") end return nil unless bt bt.reject! { |t| t.include?('one_apm') } unless profile_agent_code bt end |