Class: TingYun::Instrumentation::Support::TransactionNamer
- Inherits:
-
Object
- Object
- TingYun::Instrumentation::Support::TransactionNamer
- Defined in:
- lib/ting_yun/instrumentation/support/transaction_namer.rb
Class Method Summary collapse
- .klass_name(traced_obj, options = {}) ⇒ Object
- .name_for(txn, traced_obj, category, options = {}) ⇒ Object
- .path_name(traced_obj, options = {}) ⇒ Object
- .prefix_for_category(txn, category = nil) ⇒ Object
Class Method Details
.klass_name(traced_obj, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/ting_yun/instrumentation/support/transaction_namer.rb', line 58 def self.klass_name(traced_obj, ={}) return [:class_name] if [:class_name] if (traced_obj.is_a?(Class) || traced_obj.is_a?(Module)) traced_obj.name else traced_obj.class.name end end |
.name_for(txn, traced_obj, category, options = {}) ⇒ Object
37 38 39 |
# File 'lib/ting_yun/instrumentation/support/transaction_namer.rb', line 37 def self.name_for(txn, traced_obj, category, ={}) "#{prefix_for_category(txn, category)}#{path_name(traced_obj, )}" end |
.path_name(traced_obj, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ting_yun/instrumentation/support/transaction_namer.rb', line 41 def self.path_name(traced_obj, ={}) return [:path] if [:path] class_name = klass_name(traced_obj, ) if [:name] if class_name "#{class_name}/#{[:name]}" else [:name] end elsif traced_obj.respond_to?(:tingyun_metric_path) traced_obj.tingyun_metric_path else class_name end end |
.prefix_for_category(txn, category = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ting_yun/instrumentation/support/transaction_namer.rb', line 9 def self.prefix_for_category(txn, category = nil) category ||= (txn && txn.category) case category when :controller then ::TingYun::Agent::Transaction::CONTROLLER_PREFIX when :task then ::TingYun::Agent::Transaction::TASK_PREFIX when :rack then ::TingYun::Agent::Transaction::RACK_PREFIX when :uri then ::TingYun::Agent::Transaction::CONTROLLER_PREFIX when :sinatra then ::TingYun::Agent::Transaction::CONTROLLER_PREFIX when :middleware then ::TingYun::Agent::Transaction::MIDDLEWARE_PREFIX when :grape then ::TingYun::Agent::Transaction::GRAPE_PREFIX when :rake then ::TingYun::Agent::Transaction::RAKE_PREFIX when :action_cable then ::TingYun::Agent::Transaction::CABLE_PREFIX else "#{category.to_s}/" # for internal use only end end |