Class: Callstacking::Rails::Trace
- Inherits:
-
Object
- Object
- Callstacking::Rails::Trace
- Includes:
- Helpers::HeadsUpDisplayHelper
- Defined in:
- lib/callstacking/rails/trace.rb
Constant Summary collapse
- TRACE_CALL_ENTRY =
'TraceCallEntry'
- TRACE_CALL_RETURN =
'TraceCallReturn'
- TRACE_MESSAGE =
'TraceMessage'
- TRACE_EXCEPTION =
'TraceException'
- ICON =
'💥'
- MAX_TRACE_ENTRIES =
3000
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#lock ⇒ Object
Returns the value of attribute lock.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#spans ⇒ Object
Returns the value of attribute spans.
-
#traces ⇒ Object
Returns the value of attribute traces.
Class Method Summary collapse
Instance Method Summary collapse
- #begin_trace(controller) ⇒ Object
- #end_trace(controller, exception) ⇒ Object
-
#initialize(spans) ⇒ Trace
constructor
A new instance of Trace.
Methods included from Helpers::HeadsUpDisplayHelper
Constructor Details
#initialize(spans) ⇒ Trace
Returns a new instance of Trace.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/callstacking/rails/trace.rb', line 26 def initialize(spans) @traces = [] @spans = spans @settings = Callstacking::Rails::Settings.new @lock = Mutex.new @client = Callstacking::Rails::Client::Trace.new(settings.url, settings.auth_token) init_uuids(nil, nil) init_callbacks(nil) end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
15 16 17 |
# File 'lib/callstacking/rails/trace.rb', line 15 def client @client end |
#lock ⇒ Object
Returns the value of attribute lock.
15 16 17 |
# File 'lib/callstacking/rails/trace.rb', line 15 def lock @lock end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
16 17 18 |
# File 'lib/callstacking/rails/trace.rb', line 16 def settings @settings end |
#spans ⇒ Object
Returns the value of attribute spans.
15 16 17 |
# File 'lib/callstacking/rails/trace.rb', line 15 def spans @spans end |
#traces ⇒ Object
Returns the value of attribute traces.
15 16 17 |
# File 'lib/callstacking/rails/trace.rb', line 15 def traces @traces end |
Class Method Details
.trace_log_clear ⇒ Object
64 65 66 |
# File 'lib/callstacking/rails/trace.rb', line 64 def self.trace_log_clear trace_log.clear end |
Instance Method Details
#begin_trace(controller) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/callstacking/rails/trace.rb', line 39 def begin_trace(controller) @trace_id, @tuid = init_uuids(controller.request&.request_id || SecureRandom.uuid, TimeBasedUUID.generate) trace_log[@trace_id] = controller.request&.original_url init_callbacks(@tuid) start_request(@trace_id, @tuid, controller.action_name, controller.controller_name, controller.action_name, controller.request.format, ::Rails.root.to_s, controller.request&.original_url, controller.request.headers, controller.request.params, @traces) end |
#end_trace(controller, exception) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/callstacking/rails/trace.rb', line 52 def end_trace(controller, exception) return if @trace_id.nil? || @tuid.nil? complete_request(@trace_id, @tuid, exception, controller.action_name, controller.controller_name, controller.action_name, controller.request.format, controller.request&.original_url, @traces, MAX_TRACE_ENTRIES) inject_hud(@settings, controller.request, controller.response) if ::Rails.env.development? || ::Rails.env.test? end |