Class: NewRelic::Agent::Tracer::State

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/tracer.rb

Overview

This is THE location to store thread local information during a transaction Need a new piece of data? Add a method here, NOT a new thread local variable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State.



466
467
468
469
470
# File 'lib/new_relic/agent/tracer.rb', line 466

def initialize
  @untraced = []
  @current_transaction = nil
  @record_sql = nil
end

Instance Attribute Details

#current_transactionObject

Current transaction stack



483
484
485
# File 'lib/new_relic/agent/tracer.rb', line 483

def current_transaction
  @current_transaction
end

#record_sqlObject

TT’s and SQL



504
505
506
# File 'lib/new_relic/agent/tracer.rb', line 504

def record_sql
  @record_sql
end

#sql_sampler_transaction_dataObject

Sql Sampler Transaction Data



511
512
513
# File 'lib/new_relic/agent/tracer.rb', line 511

def sql_sampler_transaction_data
  @sql_sampler_transaction_data
end

#untracedObject

Execution tracing on current thread



486
487
488
# File 'lib/new_relic/agent/tracer.rb', line 486

def untraced
  @untraced
end

Instance Method Details

#is_execution_traced?Boolean Also known as: tracing_enabled?

Returns:

  • (Boolean)


497
498
499
# File 'lib/new_relic/agent/tracer.rb', line 497

def is_execution_traced?
  @untraced.nil? || @untraced.last != false
end

#is_sql_recorded?Boolean

Returns:

  • (Boolean)


506
507
508
# File 'lib/new_relic/agent/tracer.rb', line 506

def is_sql_recorded?
  @record_sql != false
end

#pop_tracedObject



492
493
494
495
# File 'lib/new_relic/agent/tracer.rb', line 492

def pop_traced
  # needs else branch coverage
  @untraced.pop if @untraced # rubocop:disable Style/SafeNavigation
end

#push_traced(should_trace) ⇒ Object



488
489
490
# File 'lib/new_relic/agent/tracer.rb', line 488

def push_traced(should_trace)
  @untraced << should_trace
end

#reset(transaction = nil) ⇒ Object

This starts the timer for the transaction.



473
474
475
476
477
478
479
480
# File 'lib/new_relic/agent/tracer.rb', line 473

def reset(transaction = nil)
  # We purposefully don't reset @untraced or @record_sql
  # since those are managed by NewRelic::Agent.disable_* calls explicitly
  # and (more importantly) outside the scope of a transaction

  @current_transaction = transaction
  @sql_sampler_transaction_data = nil
end