module TingYun::Agent::Transaction::InstanceMethod
Constants
- GUID_LENGTH
- HEX_DIGITS
- WEB_TRANSACTION_CATEGORIES
Public Instance Methods
assign_agent_attributes(state)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 85 def assign_agent_attributes(state) @attributes.add_agent_attribute(:threadName, "pid-#{$$}"); if @request_attributes @request_attributes.assign_agent_attributes @attributes @request_attributes.assign_user_info_attributes @attributes end @attributes.add_agent_attribute(:tx_id, @guid); @attributes.add_agent_attribute(:tmd5, state.transaction_name_md5); @attributes.add_agent_attribute(:metric_name, best_name); @attributes.add_agent_attribute(:trace_id, state.trace_id || "0") @attributes.add_agent_attribute(:refid, state.extenel_req_id) @attributes.add_agent_attribute(:cross, state.call_list) end
best_name()
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 49 def best_name @frozen_name || @default_name || ::TingYun::Agent::UNKNOWN_METRIC end
create_nested_frame(state, category, options)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 16 def create_nested_frame(state, category, options) if options[:filtered_params] && !options[:filtered_params].empty? attributes.merge_request_parameters(options[:filtered_params]) end state.add_current_node_params(:method => options[:method]) unless options[:method].nil? @has_children = true frame_stack.push TingYun::Agent::MethodTracerHelpers.trace_execution_scoped_header(state, Time.now.to_f) name_last_frame(options[:transaction_name]) set_default_transaction_name("#{state.action_type}/#{options[:transaction_name]}", category) end
freeze_name_and_execute() { || ... }
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 137 def freeze_name_and_execute unless @frozen_name @frozen_name = best_name end state = TingYun::Agent::TransactionState.tl_get unless @frozen_name.start_with? CONTROLLER_PREFIX, BACKGROUND_PREFIX, COSS_CONTROLLER_PREFIX @frozen_name = state.action_type + @frozen_name end yield if block_given? end
ignore!()
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 8 def ignore! @ignore_this_transaction = true end
ignore?()
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 12 def ignore? @ignore_this_transaction end
influences_transaction_name?(category)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 54 def influences_transaction_name?(category) !category || frame_stack.size == 1 || similar_category?(category) end
instrumentation_state()
click to toggle source
This transaction-local hash may be used as temprory storage by instrumentation that needs to pass data from one instrumentation point to another.
For example, if both A and B are instrumented, and A calls B but some piece of state needed by the instrumentation at B is only available at A, the instrumentation at A may write into the hash, call through, and then remove the key afterwards, allowing the instrumentation at B to read the value in between.
Keys should be symbols, and care should be taken to not generate key names dynamically, and to ensure that keys are removed upon return from the method that creates them.
# File lib/ting_yun/agent/transaction/instance_method.rb, line 117 def instrumentation_state @instrumentation_state ||= {} end
make_transaction_name(name, category=nil)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 39 def make_transaction_name(name, category=nil) namer = TingYun::Instrumentation::Support::TransactionNamer "#{namer.prefix_for_category(self, category)}#{name}" end
name_last_frame(name)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 44 def name_last_frame(name) frame_stack.last.name = name end
needs_middleware_summary_metrics?(name)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 69 def needs_middleware_summary_metrics?(name) name.start_with?(MIDDLEWARE_PREFIX) end
Also aliased as: ignore
record_summary_metrics(state, outermost_node_name,end_time)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 75 def record_summary_metrics(state, outermost_node_name,end_time) unless @frozen_name == outermost_node_name time = (end_time - start_time) * 1000 @metrics.record_unscoped(@frozen_name, time) if @frozen_name.start_with?('WebAction') state.current_transaction.base_quantile_hash[@frozen_name] = time end end end
set_default_transaction_name(name, category)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 28 def set_default_transaction_name(name, category) if @frozen_name TingYun::Agent.logger.warn("Attempted to rename transaction to '#{name}' after transaction name was already frozen as '#{@frozen_name}'.") return end if influences_transaction_name?(category) @default_name = name @category = category if category end end
similar_category?(category)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 64 def similar_category?(category) web_category?(@category) == web_category?(category) end
web_category?(category)
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 60 def web_category?(category) WEB_TRANSACTION_CATEGORIES.include?(category) end
with_database_metric_name(model, method, product=nil) { || ... }
click to toggle source
# File lib/ting_yun/agent/transaction/instance_method.rb, line 121 def with_database_metric_name(model, method, product=nil) previous = self.instrumentation_state[:datastore_override] model_name = case model when Class model.name when String model else model.to_s end @instrumentation_state[:datastore_override] = [method, model_name, product] yield ensure @instrumentation_state[:datastore_override] = previous end
Private Instance Methods
generate_guid()
click to toggle source
generate a random 64 bit uuid
# File lib/ting_yun/agent/transaction/instance_method.rb, line 155 def generate_guid guid = '' GUID_LENGTH.times do guid << HEX_DIGITS[rand(16)] end guid end