Module: Mtracker
- Defined in:
- lib/mtracker.rb,
lib/mtracker/version.rb
Overview
module for tracking time
Constant Summary collapse
- VERSION =
'0.3.4'
Instance Attribute Summary collapse
-
#mtracker_log_pid_and_tid ⇒ Object
Returns the value of attribute mtracker_log_pid_and_tid.
-
#mtracker_slack_url ⇒ Object
Returns the value of attribute mtracker_slack_url.
Instance Method Summary collapse
Instance Attribute Details
#mtracker_log_pid_and_tid ⇒ Object
Returns the value of attribute mtracker_log_pid_and_tid.
5 6 7 |
# File 'lib/mtracker.rb', line 5 def mtracker_log_pid_and_tid @mtracker_log_pid_and_tid end |
#mtracker_slack_url ⇒ Object
Returns the value of attribute mtracker_slack_url.
5 6 7 |
# File 'lib/mtracker.rb', line 5 def mtracker_slack_url @mtracker_slack_url end |
Instance Method Details
#track(label, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mtracker.rb', line 7 def track(label, = {}) slack = [:slack] # Bool newrelic = [:newrelic] || false # Bool nr_tracer = NewRelic::Agent::Tracer if defined?(NewRelic::Agent::Tracer) && newrelic start_time = Time.now increment_nest_level start_msg = "#{indent}[start#{pid_and_tid}] #{label}" put_track_info start_msg, slack if nr_tracer nr_segment = nr_tracer.start_segment(name: "Custom/#{label}", parent: nr_tracer.current_segment) Thread.current[:nr_transaction]&.add_segment(nr_segment) end result = yield finish_msg = "#{indent}[end #{pid_and_tid}] #{label} (#{sprintf('%.3f', Time.now - start_time)} sec)" put_track_info finish_msg, slack nr_segment&.finish decrement_nest_level result end |