Class: NewRelic::Agent::TransactionInfo
- Inherits:
-
Object
- Object
- NewRelic::Agent::TransactionInfo
- Defined in:
- lib/new_relic/agent/transaction_info.rb
Instance Attribute Summary collapse
-
#capture_deep_tt ⇒ Object
Returns the value of attribute capture_deep_tt.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#token ⇒ Object
Returns the value of attribute token.
-
#transaction_name ⇒ Object
Returns the value of attribute transaction_name.
Class Method Summary collapse
- .clear ⇒ Object
- .get ⇒ Object
- .get_token(request) ⇒ Object
-
.reset(request = nil) ⇒ Object
clears any existing transaction info object and initializes a new one.
-
.sanitize_token(token) ⇒ Object
Run through a collection of unsafe characters ( in the context of the token ) and set the token to an empty string if any of them are found in the token so that potential XSS attacks via the token are avoided.
- .set(instance) ⇒ Object
Instance Method Summary collapse
- #duration ⇒ Object
- #force_persist_sample?(sample) ⇒ Boolean
- #guid ⇒ Object
- #guid=(value) ⇒ Object
- #ignore_end_user=(value) ⇒ Object
- #ignore_end_user? ⇒ Boolean
- #include_guid? ⇒ Boolean
-
#initialize ⇒ TransactionInfo
constructor
A new instance of TransactionInfo.
Constructor Details
#initialize ⇒ TransactionInfo
Returns a new instance of TransactionInfo.
10 11 12 13 14 15 |
# File 'lib/new_relic/agent/transaction_info.rb', line 10 def initialize @guid = "" @transaction_name = "(unknown)" @start_time = Time.now @ignore_end_user = false end |
Instance Attribute Details
#capture_deep_tt ⇒ Object
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_time ⇒ Object (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 |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/new_relic/agent/transaction_info.rb', line 7 def token @token end |
#transaction_name ⇒ Object
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
.clear ⇒ Object
53 54 55 |
# File 'lib/new_relic/agent/transaction_info.rb', line 53 def self.clear Thread.current[:newrelic_transaction_info] = nil end |
.get ⇒ Object
45 46 47 |
# File 'lib/new_relic/agent/transaction_info.rb', line 45 def self.get() Thread.current[:newrelic_transaction_info] ||= TransactionInfo.new end |
.get_token(request) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/new_relic/agent/transaction_info.rb', line 65 def self.get_token(request) return nil unless request agent_flag = request.['NRAGENT'] if agent_flag and agent_flag.instance_of? String s = agent_flag.split("=") if s.length == 2 if s[0] == "tk" && s[1] ERB::Util.h(sanitize_token(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.
59 60 61 62 63 |
# File 'lib/new_relic/agent/transaction_info.rb', line 59 def self.reset(request=nil) clear instance = get instance.token = get_token(request) end |
.sanitize_token(token) ⇒ Object
Run through a collection of unsafe characters ( in the context of the token ) and set the token to an empty string if any of them are found in the token so that potential XSS attacks via the token are avoided
84 85 86 87 88 89 90 |
# File 'lib/new_relic/agent/transaction_info.rb', line 84 def self.sanitize_token(token) if ( /[<>'"]/ =~ token ) token.replace("") end token end |
.set(instance) ⇒ Object
49 50 51 |
# File 'lib/new_relic/agent/transaction_info.rb', line 49 def self.set(instance) Thread.current[:newrelic_transaction_info] = instance end |
Instance Method Details
#duration ⇒ Object
33 34 35 |
# File 'lib/new_relic/agent/transaction_info.rb', line 33 def duration Time.now - start_time end |
#force_persist_sample?(sample) ⇒ Boolean
17 18 19 |
# File 'lib/new_relic/agent/transaction_info.rb', line 17 def force_persist_sample?(sample) token && sample.duration > Agent.config[:apdex_t] end |
#guid ⇒ Object
25 26 27 |
# File 'lib/new_relic/agent/transaction_info.rb', line 25 def guid @guid end |
#guid=(value) ⇒ Object
29 30 31 |
# File 'lib/new_relic/agent/transaction_info.rb', line 29 def guid=(value) @guid = value end |
#ignore_end_user=(value) ⇒ Object
41 42 43 |
# File 'lib/new_relic/agent/transaction_info.rb', line 41 def ignore_end_user=(value) @ignore_end_user = value end |
#ignore_end_user? ⇒ Boolean
37 38 39 |
# File 'lib/new_relic/agent/transaction_info.rb', line 37 def ignore_end_user? @ignore_end_user end |