Class: NewRelic::Agent::TransactionInfo

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTransactionInfo

Returns a new instance of TransactionInfo.



10
11
12
13
14
# File 'lib/new_relic/agent/transaction_info.rb', line 10

def initialize
  @guid = ""
  @transaction_name = "(unknown)"
  @start_time = Time.now
end

Instance Attribute Details

#capture_deep_ttObject

Returns the value of attribute capture_deep_tt.



7
8
9
# File 'lib/new_relic/agent/transaction_info.rb', line 7

def capture_deep_tt
  @capture_deep_tt
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



8
9
10
# File 'lib/new_relic/agent/transaction_info.rb', line 8

def start_time
  @start_time
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/new_relic/agent/transaction_info.rb', line 7

def token
  @token
end

#transaction_nameObject

Returns the value of attribute transaction_name.



7
8
9
# File 'lib/new_relic/agent/transaction_info.rb', line 7

def transaction_name
  @transaction_name
end

Class Method Details

.clearObject



44
45
46
# File 'lib/new_relic/agent/transaction_info.rb', line 44

def self.clear
  Thread.current[:newrelic_transaction_info] = nil
end

.getObject



36
37
38
# File 'lib/new_relic/agent/transaction_info.rb', line 36

def self.get()
  Thread.current[:newrelic_transaction_info] ||= TransactionInfo.new
end

.get_token(request) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/new_relic/agent/transaction_info.rb', line 56

def self.get_token(request)
  return nil unless request
  
  agent_flag = request.cookies['NRAGENT']
  if agent_flag
    s = agent_flag.split("=")
    if s.length == 2
      if s[0] == "tk" && s[1]
        ERB::Util.h(s[1])
      end
    end
  else
    nil
  end
end

.reset(request = nil) ⇒ Object

clears any existing transaction info object and initializes a new one. This starts the timer for the transaction.



50
51
52
53
54
# File 'lib/new_relic/agent/transaction_info.rb', line 50

def self.reset(request=nil)
  clear
  instance = get
  instance.token = get_token(request)
end

.set(instance) ⇒ Object



40
41
42
# File 'lib/new_relic/agent/transaction_info.rb', line 40

def self.set(instance)
  Thread.current[:newrelic_transaction_info] = instance
end

Instance Method Details

#durationObject



32
33
34
# File 'lib/new_relic/agent/transaction_info.rb', line 32

def duration
  Time.now - start_time
end

#force_persist_sample?(sample) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/new_relic/agent/transaction_info.rb', line 16

def force_persist_sample?(sample)
  token && sample.duration > NewRelic::Control.instance.apdex_t
end

#guidObject



24
25
26
# File 'lib/new_relic/agent/transaction_info.rb', line 24

def guid
  @guid
end

#guid=(value) ⇒ Object



28
29
30
# File 'lib/new_relic/agent/transaction_info.rb', line 28

def guid=(value)
  @guid = value
end

#include_guid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/new_relic/agent/transaction_info.rb', line 20

def include_guid?
  token && duration > NewRelic::Control.instance.apdex_t
end